@activecollab/components 2.0.416 → 2.0.417

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.
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":["PORTABLE_TEXT_DEFAULT_MARKS","MEDIA_IMAGE_VARIANTS","screenshot","illustration","isPortableTextMediaImageVariant","value","DEFAULT_BLOCK_TYPES","paragraph","heading","list","media","table","divider","PORTABLE_TEXT_DEFAULT_BLOCKS","Object","keys","isRecord","isPortableTextSpan","text","isPortableTextTableRow","Array","isArray","every","cell","isPortableTextObjectNode","type","_type","isPortableTextBlock","children","child","src","title","content","undefined","isPortableTextContent","code","language","header","rows","node"],"sources":["../../../../src/components/PortableText/types.ts"],"sourcesContent":["import { ComponentType, ReactNode } from \"react\";\n\n/**\n * Portable Text envelope — the general content contract for structured,\n * renderer-independent content (in-app messages, help, changelogs).\n *\n * The design system owns this envelope and the universal default set below.\n * It never hardcodes a product element: concrete elements (callout,\n * button-reference, doc-link, …) are defined in the application catalog and\n * injected into the Portable Text engine through {@link PortableTextComponents}.\n * See README.md next to this file for the full contract.\n */\n\n/* ---- Spans and marks ------------------------------------------------- */\n\n/**\n * A mark with data. Parameterless marks travel as plain strings (\"strong\");\n * marks that need data travel as objects discriminated by `type`.\n */\nexport interface PortableTextMarkObject {\n type: string;\n [data: string]: unknown;\n}\n\n/** The one default mark that carries data. */\nexport interface PortableTextLinkMark extends PortableTextMarkObject {\n type: \"link\";\n href: string;\n}\n\nexport type PortableTextMark = string | PortableTextMarkObject;\n\n/** The leaf of every text run: a piece of text plus the marks wrapping it. */\nexport interface PortableTextSpan {\n text: string;\n marks?: PortableTextMark[];\n}\n\n/** Marks every client understands without injection. */\nexport const PORTABLE_TEXT_DEFAULT_MARKS = [\n \"strong\",\n \"em\",\n \"code\",\n \"link\",\n] as const;\n\nexport type PortableTextDefaultMark =\n (typeof PORTABLE_TEXT_DEFAULT_MARKS)[number];\n\n/* ---- Blocks ----------------------------------------------------------- */\n\nexport interface PortableTextParagraphBlock {\n type: \"paragraph\";\n children: PortableTextSpan[];\n}\n\n/** 1 maps to Title1, 2 to Title2, 3 to Header2 typography. */\nexport type PortableTextHeadingLevel = 1 | 2 | 3;\n\nexport interface PortableTextHeadingBlock {\n type: \"heading\";\n level: PortableTextHeadingLevel;\n children: PortableTextSpan[];\n}\n\nexport type PortableTextListStyle = \"bullet\" | \"number\";\n\n/**\n * A list item's children are its own spans first, then any nested `list`\n * block(s) — the shape that carries multi-level lists. A spans-only item (no\n * nested list) is the common, flat case and stays valid unchanged.\n */\nexport interface PortableTextListItemBlock {\n type: \"list-item\";\n children: (PortableTextSpan | PortableTextListBlock)[];\n}\n\nexport interface PortableTextListBlock {\n type: \"list\";\n style?: PortableTextListStyle;\n children: PortableTextListItemBlock[];\n}\n\n/** Screenshots render framed (border, no shadow); illustrations render flat. */\nexport type PortableTextMediaImageVariant = \"screenshot\" | \"illustration\";\n\n/**\n * Video variants name the hosting service; `src` is the canonical video URL.\n * Their rendering carries service semantics (URL parsing, embed derivation),\n * so it belongs to the application catalog — injected as a `media` block\n * override — never to the default set. The default renderer degrades them.\n */\nexport type PortableTextMediaVideoVariant = \"vimeo\" | \"youtube\";\n\nexport type PortableTextMediaVariant =\n | PortableTextMediaImageVariant\n | PortableTextMediaVideoVariant;\n\n// A Record so the compiler checks the list against the union in both\n// directions: a missing and a stray key each fail to build.\nconst MEDIA_IMAGE_VARIANTS: Record<PortableTextMediaImageVariant, true> = {\n screenshot: true,\n illustration: true,\n};\n\nexport const isPortableTextMediaImageVariant = (\n value: unknown\n): value is PortableTextMediaImageVariant =>\n typeof value === \"string\" && value in MEDIA_IMAGE_VARIANTS;\n\nexport interface PortableTextMediaBlock {\n type: \"media\";\n src: string;\n alt?: string;\n variant?: PortableTextMediaVariant;\n caption?: string;\n}\n\nexport interface PortableTextTitledTextBlock {\n type: \"titled-text\";\n /**\n * Same semantic scale as `heading` — 1, 2 or 3 (the default) — so the wire\n * format never encodes a typography name. How a level looks is the\n * renderer's business.\n */\n level?: PortableTextHeadingLevel;\n title: string;\n content?: PortableTextNode[];\n}\n\nexport interface PortableTextCodeBlock {\n type: \"code-block\";\n /**\n * A language hint (e.g. \"php\", \"json\"). The default renderer does no\n * highlighting, so any value — known, unknown or absent — renders as plain\n * preformatted text; it travels as data for surfaces that highlight.\n */\n language?: string;\n code: string;\n}\n\n/** A table cell is a span array, so inline marks work inside cells. */\nexport type PortableTextTableCell = PortableTextSpan[];\nexport type PortableTextTableRow = PortableTextTableCell[];\n\nexport interface PortableTextTableBlock {\n type: \"table\";\n header: PortableTextTableRow;\n rows: PortableTextTableRow[];\n}\n\n/** A themed horizontal rule between sections. Carries no data. */\nexport interface PortableTextDividerBlock {\n type: \"divider\";\n}\n\nexport type PortableTextBlock =\n | PortableTextParagraphBlock\n | PortableTextHeadingBlock\n | PortableTextListBlock\n | PortableTextMediaBlock\n | PortableTextTitledTextBlock\n | PortableTextCodeBlock\n | PortableTextTableBlock\n | PortableTextDividerBlock;\n\n/**\n * Derived from the union's discriminators, so adding a block to the union\n * without a renderer entry is a compile error, never silent drift.\n */\nexport type PortableTextDefaultBlockType = (\n | PortableTextBlock\n | PortableTextListItemBlock\n)[\"type\"];\n\n// A Record so the compiler checks the list against the union in both\n// directions: a missing and a stray key each fail to build.\nconst DEFAULT_BLOCK_TYPES: Record<PortableTextDefaultBlockType, true> = {\n paragraph: true,\n heading: true,\n list: true,\n \"list-item\": true,\n media: true,\n \"titled-text\": true,\n \"code-block\": true,\n table: true,\n divider: true,\n};\n\n/** Blocks every client understands without injection. */\nexport const PORTABLE_TEXT_DEFAULT_BLOCKS = Object.keys(\n DEFAULT_BLOCK_TYPES\n) as readonly PortableTextDefaultBlockType[];\n\n/* ---- Objects ----------------------------------------------------------- */\n\n/**\n * An embedded component the envelope does not interpret: `_type` names an\n * application-catalog element, everything else is that element's data. An\n * object whose `_type` has no injected renderer renders nothing and is logged.\n */\nexport interface PortableTextObjectNode {\n type: \"object\";\n _type: string;\n [data: string]: unknown;\n}\n\nexport type PortableTextNode = PortableTextBlock | PortableTextObjectNode;\n\n/** The root of a message body: what an API returns under `content`. */\nexport type PortableTextContent = PortableTextNode[];\n\n/* ---- Injection contract ------------------------------------------------ */\n\nexport interface PortableTextMarkRendererProps<\n TMark extends PortableTextMarkObject = PortableTextMarkObject\n> {\n /** Present for object marks; absent when the mark is a plain string. */\n mark?: TMark;\n children: ReactNode;\n}\n\nexport type PortableTextMarkRenderer<\n TMark extends PortableTextMarkObject = PortableTextMarkObject\n> = ComponentType<PortableTextMarkRendererProps<TMark>>;\n\nexport interface PortableTextObjectRendererProps<\n TNode extends PortableTextObjectNode = PortableTextObjectNode\n> {\n node: TNode;\n /** The object's nested `content`, already rendered by the engine. */\n children?: ReactNode;\n}\n\nexport type PortableTextObjectRenderer<\n TNode extends PortableTextObjectNode = PortableTextObjectNode\n> = ComponentType<PortableTextObjectRendererProps<TNode>>;\n\nexport interface PortableTextBlockRendererProps<\n TBlock extends PortableTextBlock = PortableTextBlock\n> {\n block: TBlock;\n /** The block's rendered children/content, when it has any. */\n children?: ReactNode;\n /**\n * Engine-bound span renderer for blocks that carry spans outside `children`\n * (table cells). Resolves marks with the same precedence — injected first,\n * then defaults — as flowing text. Absent when a renderer is used without\n * the engine.\n */\n renderSpans?: (spans: PortableTextSpan[]) => ReactNode;\n}\n\nexport type PortableTextBlockRenderer<\n TBlock extends PortableTextBlock = PortableTextBlock\n> = ComponentType<PortableTextBlockRendererProps<TBlock>>;\n\nexport type PortableTextUnknownKind = \"block\" | \"mark\" | \"object\";\n\n/**\n * Called once per unknown type instead of rendering it, so content written\n * for newer clients degrades silently on older ones.\n */\nexport type PortableTextUnknownTypeHandler = (\n kind: PortableTextUnknownKind,\n type: string\n) => void;\n\n/**\n * What an application injects into the Portable Text engine: renderers for\n * its catalog marks and objects, optional overrides for the default blocks,\n * and the unknown-type hook.\n */\nexport interface PortableTextComponents {\n marks?: Record<string, PortableTextMarkRenderer>;\n objects?: Record<string, PortableTextObjectRenderer>;\n blocks?: Partial<\n Record<PortableTextDefaultBlockType, PortableTextBlockRenderer>\n >;\n onUnknownType?: PortableTextUnknownTypeHandler;\n}\n\n/* ---- Runtime guards ----------------------------------------------------- */\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null;\n\nexport const isPortableTextSpan = (value: unknown): value is PortableTextSpan =>\n isRecord(value) && typeof value.text === \"string\";\n\nexport const isPortableTextTableRow = (\n value: unknown\n): value is PortableTextTableRow =>\n Array.isArray(value) &&\n value.every((cell) => Array.isArray(cell) && cell.every(isPortableTextSpan));\n\nexport const isPortableTextObjectNode = (\n value: unknown\n): value is PortableTextObjectNode =>\n isRecord(value) && value.type === \"object\" && typeof value._type === \"string\";\n\n/**\n * A block is any non-object node with a string `type`. Unknown block types\n * stay valid on purpose — they render nothing on clients that predate them.\n * Known types are held to their shape, so a serializer bug (a paragraph\n * without `children`, a list of non-nodes) fails here instead of at render.\n */\nexport const isPortableTextBlock = (\n value: unknown\n): value is PortableTextBlock => {\n if (\n !isRecord(value) ||\n typeof value.type !== \"string\" ||\n value.type === \"object\"\n ) {\n return false;\n }\n\n switch (value.type) {\n case \"paragraph\":\n case \"heading\":\n return (\n Array.isArray(value.children) &&\n value.children.every(isPortableTextSpan)\n );\n case \"list-item\":\n // The item's spans, plus optional nested `list` block(s). Widened only\n // for nested lists: any other block child (a stray paragraph, an object)\n // still fails, so a serializer bug is caught here, not at render.\n return (\n Array.isArray(value.children) &&\n value.children.every(\n (child) =>\n isPortableTextSpan(child) ||\n (isPortableTextBlock(child) && child.type === \"list\")\n )\n );\n case \"list\":\n // A list holds `list-item`s only. A sublist emitted as a sibling of the\n // items (the classic half-implemented-nesting bug) renders invalid HTML\n // — <ul> with a direct <ul> child — so it fails here, not at render.\n // `list-item` is validated but sits outside the PortableTextBlock union,\n // so the discriminator is checked before isPortableTextBlock narrows it.\n return (\n Array.isArray(value.children) &&\n value.children.every(\n (child) =>\n isRecord(child) &&\n child.type === \"list-item\" &&\n isPortableTextBlock(child)\n )\n );\n case \"media\":\n return typeof value.src === \"string\";\n case \"titled-text\":\n return (\n typeof value.title === \"string\" &&\n (value.content === undefined || isPortableTextContent(value.content))\n );\n case \"code-block\":\n return (\n typeof value.code === \"string\" &&\n (value.language === undefined || typeof value.language === \"string\")\n );\n case \"table\":\n return (\n isPortableTextTableRow(value.header) &&\n Array.isArray(value.rows) &&\n value.rows.every(isPortableTextTableRow)\n );\n case \"divider\":\n return true;\n default:\n return true;\n }\n};\n\nexport const isPortableTextContent = (\n value: unknown\n): value is PortableTextContent =>\n Array.isArray(value) &&\n value.every(\n (node) => isPortableTextBlock(node) || isPortableTextObjectNode(node)\n );\n"],"mappings":"AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAMA;;AAQA;;AAMA;AACA,OAAO,MAAMA,2BAA2B,GAAG,CACzC,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,MAAM,CACE;;AAKV;;AAOA;;AAWA;AACA;AACA;AACA;AACA;;AAYA;;AAGA;AACA;AACA;AACA;AACA;AACA;;AAOA;AACA;AACA,MAAMC,oBAAiE,GAAG;EACxEC,UAAU,EAAE,IAAI;EAChBC,YAAY,EAAE;AAChB,CAAC;AAED,OAAO,MAAMC,+BAA+B,GAC1CC,KAAc,IAEd,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,IAAIJ,oBAAoB;;AAiC5D;;AAUA;;AAeA;AACA;AACA;AACA;;AAMA;AACA;AACA,MAAMK,mBAA+D,GAAG;EACtEC,SAAS,EAAE,IAAI;EACfC,OAAO,EAAE,IAAI;EACbC,IAAI,EAAE,IAAI;EACV,WAAW,EAAE,IAAI;EACjBC,KAAK,EAAE,IAAI;EACX,aAAa,EAAE,IAAI;EACnB,YAAY,EAAE,IAAI;EAClBC,KAAK,EAAE,IAAI;EACXC,OAAO,EAAE;AACX,CAAC;;AAED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AEde,KAAK,CAACC,OAAO,CAAChB,KAAK,CAAC,IACpBA,KAAK,CAACiB,KAAK,CACRiB,IAAI,IAAKZ,mBAAmB,CAACY,IAAI,CAAC,IAAIf,wBAAwB,CAACe,IAAI,CACtE,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":["PORTABLE_TEXT_DEFAULT_MARKS","MEDIA_IMAGE_VARIANTS","screenshot","illustration","isPortableTextMediaImageVariant","value","DEFAULT_BLOCK_TYPES","paragraph","heading","list","media","table","divider","PORTABLE_TEXT_DEFAULT_BLOCKS","Object","keys","isRecord","isPortableTextSpan","text","isPortableTextTableRow","Array","isArray","every","cell","isPortableTextObjectNode","type","_type","isPortableTextBlock","children","id","undefined","child","src","title","content","isPortableTextContent","code","language","header","rows","node"],"sources":["../../../../src/components/PortableText/types.ts"],"sourcesContent":["import { ComponentType, ReactNode } from \"react\";\n\n/**\n * Portable Text envelope — the general content contract for structured,\n * renderer-independent content (in-app messages, help, changelogs).\n *\n * The design system owns this envelope and the universal default set below.\n * It never hardcodes a product element: concrete elements (callout,\n * button-reference, doc-link, …) are defined in the application catalog and\n * injected into the Portable Text engine through {@link PortableTextComponents}.\n * See README.md next to this file for the full contract.\n */\n\n/* ---- Spans and marks ------------------------------------------------- */\n\n/**\n * A mark with data. Parameterless marks travel as plain strings (\"strong\");\n * marks that need data travel as objects discriminated by `type`.\n */\nexport interface PortableTextMarkObject {\n type: string;\n [data: string]: unknown;\n}\n\n/** The one default mark that carries data. */\nexport interface PortableTextLinkMark extends PortableTextMarkObject {\n type: \"link\";\n href: string;\n}\n\nexport type PortableTextMark = string | PortableTextMarkObject;\n\n/** The leaf of every text run: a piece of text plus the marks wrapping it. */\nexport interface PortableTextSpan {\n text: string;\n marks?: PortableTextMark[];\n}\n\n/** Marks every client understands without injection. */\nexport const PORTABLE_TEXT_DEFAULT_MARKS = [\n \"strong\",\n \"em\",\n \"code\",\n \"link\",\n] as const;\n\nexport type PortableTextDefaultMark =\n (typeof PORTABLE_TEXT_DEFAULT_MARKS)[number];\n\n/* ---- Blocks ----------------------------------------------------------- */\n\nexport interface PortableTextParagraphBlock {\n type: \"paragraph\";\n children: PortableTextSpan[];\n}\n\n/** 1 maps to Title1, 2 to Title2, 3 to Header2 typography. */\nexport type PortableTextHeadingLevel = 1 | 2 | 3;\n\nexport interface PortableTextHeadingBlock {\n type: \"heading\";\n level: PortableTextHeadingLevel;\n /**\n * Optional anchor id, rendered verbatim as the heading element's `id` so the\n * heading is a scroll target (e.g. subarticle deep-links). Opaque to the\n * renderer — any slug convention lives with whoever produced the block.\n */\n id?: string;\n children: PortableTextSpan[];\n}\n\nexport type PortableTextListStyle = \"bullet\" | \"number\";\n\n/**\n * A list item's children are its own spans first, then any nested `list`\n * block(s) — the shape that carries multi-level lists. A spans-only item (no\n * nested list) is the common, flat case and stays valid unchanged.\n */\nexport interface PortableTextListItemBlock {\n type: \"list-item\";\n children: (PortableTextSpan | PortableTextListBlock)[];\n}\n\nexport interface PortableTextListBlock {\n type: \"list\";\n style?: PortableTextListStyle;\n children: PortableTextListItemBlock[];\n}\n\n/** Screenshots render framed (border, no shadow); illustrations render flat. */\nexport type PortableTextMediaImageVariant = \"screenshot\" | \"illustration\";\n\n/**\n * Video variants name the hosting service; `src` is the canonical video URL.\n * Their rendering carries service semantics (URL parsing, embed derivation),\n * so it belongs to the application catalog — injected as a `media` block\n * override — never to the default set. The default renderer degrades them.\n */\nexport type PortableTextMediaVideoVariant = \"vimeo\" | \"youtube\";\n\nexport type PortableTextMediaVariant =\n | PortableTextMediaImageVariant\n | PortableTextMediaVideoVariant;\n\n// A Record so the compiler checks the list against the union in both\n// directions: a missing and a stray key each fail to build.\nconst MEDIA_IMAGE_VARIANTS: Record<PortableTextMediaImageVariant, true> = {\n screenshot: true,\n illustration: true,\n};\n\nexport const isPortableTextMediaImageVariant = (\n value: unknown\n): value is PortableTextMediaImageVariant =>\n typeof value === \"string\" && value in MEDIA_IMAGE_VARIANTS;\n\nexport interface PortableTextMediaBlock {\n type: \"media\";\n src: string;\n alt?: string;\n variant?: PortableTextMediaVariant;\n caption?: string;\n}\n\nexport interface PortableTextTitledTextBlock {\n type: \"titled-text\";\n /**\n * Same semantic scale as `heading` — 1, 2 or 3 (the default) — so the wire\n * format never encodes a typography name. How a level looks is the\n * renderer's business.\n */\n level?: PortableTextHeadingLevel;\n title: string;\n content?: PortableTextNode[];\n}\n\nexport interface PortableTextCodeBlock {\n type: \"code-block\";\n /**\n * A language hint (e.g. \"php\", \"json\"). The default renderer does no\n * highlighting, so any value — known, unknown or absent — renders as plain\n * preformatted text; it travels as data for surfaces that highlight.\n */\n language?: string;\n code: string;\n}\n\n/** A table cell is a span array, so inline marks work inside cells. */\nexport type PortableTextTableCell = PortableTextSpan[];\nexport type PortableTextTableRow = PortableTextTableCell[];\n\nexport interface PortableTextTableBlock {\n type: \"table\";\n header: PortableTextTableRow;\n rows: PortableTextTableRow[];\n}\n\n/** A themed horizontal rule between sections. Carries no data. */\nexport interface PortableTextDividerBlock {\n type: \"divider\";\n}\n\nexport type PortableTextBlock =\n | PortableTextParagraphBlock\n | PortableTextHeadingBlock\n | PortableTextListBlock\n | PortableTextMediaBlock\n | PortableTextTitledTextBlock\n | PortableTextCodeBlock\n | PortableTextTableBlock\n | PortableTextDividerBlock;\n\n/**\n * Derived from the union's discriminators, so adding a block to the union\n * without a renderer entry is a compile error, never silent drift.\n */\nexport type PortableTextDefaultBlockType = (\n | PortableTextBlock\n | PortableTextListItemBlock\n)[\"type\"];\n\n// A Record so the compiler checks the list against the union in both\n// directions: a missing and a stray key each fail to build.\nconst DEFAULT_BLOCK_TYPES: Record<PortableTextDefaultBlockType, true> = {\n paragraph: true,\n heading: true,\n list: true,\n \"list-item\": true,\n media: true,\n \"titled-text\": true,\n \"code-block\": true,\n table: true,\n divider: true,\n};\n\n/** Blocks every client understands without injection. */\nexport const PORTABLE_TEXT_DEFAULT_BLOCKS = Object.keys(\n DEFAULT_BLOCK_TYPES\n) as readonly PortableTextDefaultBlockType[];\n\n/* ---- Objects ----------------------------------------------------------- */\n\n/**\n * An embedded component the envelope does not interpret: `_type` names an\n * application-catalog element, everything else is that element's data. An\n * object whose `_type` has no injected renderer renders nothing and is logged.\n */\nexport interface PortableTextObjectNode {\n type: \"object\";\n _type: string;\n [data: string]: unknown;\n}\n\nexport type PortableTextNode = PortableTextBlock | PortableTextObjectNode;\n\n/** The root of a message body: what an API returns under `content`. */\nexport type PortableTextContent = PortableTextNode[];\n\n/* ---- Injection contract ------------------------------------------------ */\n\nexport interface PortableTextMarkRendererProps<\n TMark extends PortableTextMarkObject = PortableTextMarkObject\n> {\n /** Present for object marks; absent when the mark is a plain string. */\n mark?: TMark;\n children: ReactNode;\n}\n\nexport type PortableTextMarkRenderer<\n TMark extends PortableTextMarkObject = PortableTextMarkObject\n> = ComponentType<PortableTextMarkRendererProps<TMark>>;\n\nexport interface PortableTextObjectRendererProps<\n TNode extends PortableTextObjectNode = PortableTextObjectNode\n> {\n node: TNode;\n /** The object's nested `content`, already rendered by the engine. */\n children?: ReactNode;\n}\n\nexport type PortableTextObjectRenderer<\n TNode extends PortableTextObjectNode = PortableTextObjectNode\n> = ComponentType<PortableTextObjectRendererProps<TNode>>;\n\nexport interface PortableTextBlockRendererProps<\n TBlock extends PortableTextBlock = PortableTextBlock\n> {\n block: TBlock;\n /** The block's rendered children/content, when it has any. */\n children?: ReactNode;\n /**\n * Engine-bound span renderer for blocks that carry spans outside `children`\n * (table cells). Resolves marks with the same precedence — injected first,\n * then defaults — as flowing text. Absent when a renderer is used without\n * the engine.\n */\n renderSpans?: (spans: PortableTextSpan[]) => ReactNode;\n}\n\nexport type PortableTextBlockRenderer<\n TBlock extends PortableTextBlock = PortableTextBlock\n> = ComponentType<PortableTextBlockRendererProps<TBlock>>;\n\nexport type PortableTextUnknownKind = \"block\" | \"mark\" | \"object\";\n\n/**\n * Called once per unknown type instead of rendering it, so content written\n * for newer clients degrades silently on older ones.\n */\nexport type PortableTextUnknownTypeHandler = (\n kind: PortableTextUnknownKind,\n type: string\n) => void;\n\n/**\n * What an application injects into the Portable Text engine: renderers for\n * its catalog marks and objects, optional overrides for the default blocks,\n * and the unknown-type hook.\n */\nexport interface PortableTextComponents {\n marks?: Record<string, PortableTextMarkRenderer>;\n objects?: Record<string, PortableTextObjectRenderer>;\n blocks?: Partial<\n Record<PortableTextDefaultBlockType, PortableTextBlockRenderer>\n >;\n onUnknownType?: PortableTextUnknownTypeHandler;\n}\n\n/* ---- Runtime guards ----------------------------------------------------- */\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null;\n\nexport const isPortableTextSpan = (value: unknown): value is PortableTextSpan =>\n isRecord(value) && typeof value.text === \"string\";\n\nexport const isPortableTextTableRow = (\n value: unknown\n): value is PortableTextTableRow =>\n Array.isArray(value) &&\n value.every((cell) => Array.isArray(cell) && cell.every(isPortableTextSpan));\n\nexport const isPortableTextObjectNode = (\n value: unknown\n): value is PortableTextObjectNode =>\n isRecord(value) && value.type === \"object\" && typeof value._type === \"string\";\n\n/**\n * A block is any non-object node with a string `type`. Unknown block types\n * stay valid on purpose — they render nothing on clients that predate them.\n * Known types are held to their shape, so a serializer bug (a paragraph\n * without `children`, a list of non-nodes) fails here instead of at render.\n */\nexport const isPortableTextBlock = (\n value: unknown\n): value is PortableTextBlock => {\n if (\n !isRecord(value) ||\n typeof value.type !== \"string\" ||\n value.type === \"object\"\n ) {\n return false;\n }\n\n switch (value.type) {\n case \"paragraph\":\n return (\n Array.isArray(value.children) &&\n value.children.every(isPortableTextSpan)\n );\n case \"heading\":\n return (\n (value.id === undefined || typeof value.id === \"string\") &&\n Array.isArray(value.children) &&\n value.children.every(isPortableTextSpan)\n );\n case \"list-item\":\n // The item's spans, plus optional nested `list` block(s). Widened only\n // for nested lists: any other block child (a stray paragraph, an object)\n // still fails, so a serializer bug is caught here, not at render.\n return (\n Array.isArray(value.children) &&\n value.children.every(\n (child) =>\n isPortableTextSpan(child) ||\n (isPortableTextBlock(child) && child.type === \"list\")\n )\n );\n case \"list\":\n // A list holds `list-item`s only. A sublist emitted as a sibling of the\n // items (the classic half-implemented-nesting bug) renders invalid HTML\n // — <ul> with a direct <ul> child — so it fails here, not at render.\n // `list-item` is validated but sits outside the PortableTextBlock union,\n // so the discriminator is checked before isPortableTextBlock narrows it.\n return (\n Array.isArray(value.children) &&\n value.children.every(\n (child) =>\n isRecord(child) &&\n child.type === \"list-item\" &&\n isPortableTextBlock(child)\n )\n );\n case \"media\":\n return typeof value.src === \"string\";\n case \"titled-text\":\n return (\n typeof value.title === \"string\" &&\n (value.content === undefined || isPortableTextContent(value.content))\n );\n case \"code-block\":\n return (\n typeof value.code === \"string\" &&\n (value.language === undefined || typeof value.language === \"string\")\n );\n case \"table\":\n return (\n isPortableTextTableRow(value.header) &&\n Array.isArray(value.rows) &&\n value.rows.every(isPortableTextTableRow)\n );\n case \"divider\":\n return true;\n default:\n return true;\n }\n};\n\nexport const isPortableTextContent = (\n value: unknown\n): value is PortableTextContent =>\n Array.isArray(value) &&\n value.every(\n (node) => isPortableTextBlock(node) || isPortableTextObjectNode(node)\n );\n"],"mappings":"AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAMA;;AAQA;;AAMA;AACA,OAAO,MAAMA,2BAA2B,GAAG,CACzC,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,MAAM,CACE;;AAKV;;AAOA;;AAiBA;AACA;AACA;AACA;AACA;;AAYA;;AAGA;AACA;AACA;AACA;AACA;AACA;;AAOA;AACA;AACA,MAAMC,oBAAiE,GAAG;EACxEC,UAAU,EAAE,IAAI;EAChBC,YAAY,EAAE;AAChB,CAAC;AAED,OAAO,MAAMC,+BAA+B,GAC1CC,KAAc,IAEd,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,IAAIJ,oBAAoB;;AAiC5D;;AAUA;;AAeA;AACA;AACA;AACA;;AAMA;AACA;AACA,MAAM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AAY;MACf,OACE,OAAO7B,KAAK,CAAC+B,IAAI,KAAK,QAAQ,KAC7B/B,KAAK,CAACgC,QAAQ,KAAKP,SAAS,IAAI,OAAOzB,KAAK,CAACgC,QAAQ,KAAK,QAAQ,CAAC;IAExE,KAAK,OAAO;MACV,OACElB,sBAAsB,CAACd,KAAK,CAACiC,MAAM,CAAC,IACpClB,KAAK,CAACC,OAAO,CAAChB,KAAK,CAACkC,IAAI,CAAC,IACzBlC,KAAK,CAACkC,IAAI,CAACjB,KAAK,CAACH,sBAAsB,CAAC;IAE5C,KAAK,SAAS;MACZ,OAAO,IAAI;IACb;MACE,OAAO,IAAI;EACf;AACF,CAAC;AAED,OAAO,MAAMgB,qBAAqB,GAChC9B,KAAc,IAEde,KAAK,CAACC,OAAO,CAAChB,KAAK,CAAC,IACpBA,KAAK,CAACiB,KAAK,CACRkB,IAAI,IAAKb,mBAAmB,CAACa,IAAI,CAAC,IAAIhB,wBAAwB,CAACgB,IAAI,CACtE,CAAC","ignoreList":[]}
@@ -135,6 +135,14 @@ describe("PortableText envelope", () => {
135
135
  level: 2,
136
136
  children: "oops"
137
137
  }])).toBe(false);
138
+ expect(isPortableTextContent([{
139
+ type: "heading",
140
+ level: 2,
141
+ id: 42,
142
+ children: [{
143
+ text: "x"
144
+ }]
145
+ }])).toBe(false);
138
146
  expect(isPortableTextContent([{
139
147
  type: "paragraph",
140
148
  children: [{
@@ -344,6 +352,16 @@ describe("PortableText envelope", () => {
344
352
  content: []
345
353
  }])).toBe(true);
346
354
  });
355
+ it("accepts a heading carrying an optional anchor id", () => {
356
+ expect(isPortableTextContent([{
357
+ type: "heading",
358
+ level: 2,
359
+ id: "sub-create-a-task",
360
+ children: [{
361
+ text: "Anchored"
362
+ }]
363
+ }])).toBe(true);
364
+ });
347
365
  it("tells blocks, objects and spans apart", () => {
348
366
  const heading = sampleMessageContent[0],
349
367
  paragraph = sampleMessageContent[1];
@@ -1 +1 @@
1
- {"version":3,"file":"types.test.js","names":["createElement","Fragment","isPortableTextBlock","isPortableTextContent","isPortableTextMediaImageVariant","isPortableTextObjectNode","isPortableTextSpan","PORTABLE_TEXT_DEFAULT_BLOCKS","PORTABLE_TEXT_DEFAULT_MARKS","describe","sampleMessageContent","type","level","children","text","marks","article","style","src","variant","caption","title","content","_type","tone","label","language","code","header","rows","it","expect","toBe","payload","data","heading","paragraph","callout","toEqual","undefined","_components$marks","seen","components","_ref","objects","_ref2","onUnknownType","kind","push","Object","keys"],"sources":["../../../../src/components/PortableText/types.test.ts"],"sourcesContent":["import { createElement, Fragment } from \"react\";\n\nimport {\n isPortableTextBlock,\n isPortableTextContent,\n isPortableTextMediaImageVariant,\n isPortableTextObjectNode,\n isPortableTextSpan,\n PORTABLE_TEXT_DEFAULT_BLOCKS,\n PORTABLE_TEXT_DEFAULT_MARKS,\n PortableTextComponents,\n PortableTextContent,\n} from \"./types\";\n\ndescribe(\"PortableText envelope\", () => {\n const sampleMessageContent: PortableTextContent = [\n { type: \"heading\", level: 2, children: [{ text: \"IP Firewall\" }] },\n {\n type: \"paragraph\",\n children: [\n { text: \"Open the \" },\n { text: \"Security page\", marks: [\"interface-name\"] },\n { text: \" and press \" },\n { text: \"Enter\", marks: [\"keyboard-key\"] },\n { text: \". Read more in \" },\n {\n text: \"the help article\",\n marks: [{ type: \"doc-link\", article: \"ip-firewall\" }],\n },\n { text: \".\" },\n ],\n },\n {\n type: \"list\",\n style: \"bullet\",\n children: [\n {\n type: \"list-item\",\n children: [{ text: \"Allowlist the IPs you trust\" }],\n },\n {\n type: \"list-item\",\n children: [{ text: \"immediately\", marks: [\"strong\"] }],\n },\n ],\n },\n {\n type: \"media\",\n src: \"/screenshots/firewall.png\",\n variant: \"screenshot\",\n caption: \"The firewall settings\",\n },\n {\n type: \"titled-text\",\n title: \"Allowlist the IPs you trust\",\n level: 3,\n content: [\n { type: \"paragraph\", children: [{ text: \"Add one range per line.\" }] },\n ],\n },\n {\n type: \"object\",\n _type: \"callout\",\n tone: \"note\",\n content: [\n {\n type: \"paragraph\",\n children: [{ text: \"Takes effect immediately.\" }],\n },\n ],\n },\n {\n type: \"object\",\n _type: \"button-reference\",\n label: \"Save Changes\",\n variant: \"primary\",\n },\n { type: \"divider\" },\n {\n type: \"code-block\",\n language: \"json\",\n code: '{ \"allowlist\": [\"203.0.113.0/24\"] }',\n },\n {\n type: \"table\",\n header: [[{ text: \"Range\" }], [{ text: \"Purpose\" }]],\n rows: [\n [\n [{ text: \"203.0.113.0/24\", marks: [\"code\"] }],\n [{ text: \"Office\", marks: [\"strong\"] }],\n ],\n [[{ text: \"198.51.100.0/24\", marks: [\"code\"] }], [{ text: \"VPN\" }]],\n ],\n },\n ];\n\n it(\"validates a sample message that mixes default blocks and catalog objects\", () => {\n expect(isPortableTextContent(sampleMessageContent)).toBe(true);\n });\n\n it(\"keeps unknown block and object types valid so older clients degrade instead of break\", () => {\n expect(\n isPortableTextContent([\n { type: \"some-future-block\", payload: 1 },\n { type: \"object\", _type: \"some-future-element\", data: true },\n ])\n ).toBe(true);\n });\n\n it(\"rejects nodes without a type discriminator and objects without _type\", () => {\n expect(isPortableTextContent([{ children: [] }])).toBe(false);\n expect(isPortableTextContent([{ type: \"object\" }])).toBe(false);\n expect(isPortableTextContent([\"paragraph\"])).toBe(false);\n expect(isPortableTextContent({ content: [] })).toBe(false);\n });\n\n it(\"rejects known blocks whose shape a serializer bug has broken\", () => {\n expect(isPortableTextContent([{ type: \"paragraph\" }])).toBe(false);\n expect(\n isPortableTextContent([{ type: \"heading\", level: 2, children: \"oops\" }])\n ).toBe(false);\n expect(\n isPortableTextContent([\n { type: \"paragraph\", children: [{ marks: [\"strong\"] }] },\n ])\n ).toBe(false);\n expect(isPortableTextContent([{ type: \"list\" }])).toBe(false);\n expect(\n isPortableTextContent([{ type: \"list\", children: [\"not a node\"] }])\n ).toBe(false);\n expect(isPortableTextContent([{ type: \"media\" }])).toBe(false);\n expect(isPortableTextContent([{ type: \"titled-text\", content: [] }])).toBe(\n false\n );\n expect(\n isPortableTextContent([\n { type: \"titled-text\", title: \"Ranges\", content: \"oops\" },\n ])\n ).toBe(false);\n });\n\n it(\"rejects malformed code-block, table and divider-adjacent shapes\", () => {\n expect(isPortableTextContent([{ type: \"code-block\" }])).toBe(false);\n expect(isPortableTextContent([{ type: \"code-block\", code: 42 }])).toBe(\n false\n );\n expect(\n isPortableTextContent([{ type: \"code-block\", code: \"x\", language: 1 }])\n ).toBe(false);\n expect(isPortableTextContent([{ type: \"table\" }])).toBe(false);\n expect(\n isPortableTextContent([{ type: \"table\", header: [], rows: \"oops\" }])\n ).toBe(false);\n expect(\n isPortableTextContent([\n { type: \"table\", header: [[{ text: \"A\" }]], rows: [[\"not a cell\"]] },\n ])\n ).toBe(false);\n expect(\n isPortableTextContent([\n { type: \"table\", header: [{ text: \"not a cell\" }], rows: [] },\n ])\n ).toBe(false);\n });\n\n it(\"accepts a list-item whose children nest a list block after its spans\", () => {\n expect(\n isPortableTextContent([\n {\n type: \"list\",\n style: \"bullet\",\n children: [\n {\n type: \"list-item\",\n children: [\n { text: \"Step 3:\", marks: [\"strong\"] },\n { text: \" Choose one of the following options:\" },\n {\n type: \"list\",\n style: \"bullet\",\n children: [\n {\n type: \"list-item\",\n children: [{ text: \"Sign in via Email\" }],\n },\n {\n type: \"list-item\",\n children: [{ text: \"Sign in via your Google account\" }],\n },\n ],\n },\n ],\n },\n ],\n },\n ])\n ).toBe(true);\n });\n\n it(\"validates a list nested four levels deep with mixed styles per level\", () => {\n expect(\n isPortableTextContent([\n {\n type: \"list\",\n style: \"number\",\n children: [\n {\n type: \"list-item\",\n children: [\n { text: \"Top level, ordered\" },\n {\n type: \"list\",\n style: \"bullet\",\n children: [\n {\n type: \"list-item\",\n children: [\n { text: \"Level 2, bullet\" },\n {\n type: \"list\",\n style: \"number\",\n children: [\n {\n type: \"list-item\",\n children: [\n { text: \"Level 3, ordered\" },\n {\n type: \"list\",\n style: \"bullet\",\n children: [\n {\n type: \"list-item\",\n children: [{ text: \"Level 4, bullet\" }],\n },\n ],\n },\n ],\n },\n ],\n },\n ],\n },\n ],\n },\n ],\n },\n ],\n },\n ])\n ).toBe(true);\n });\n\n it(\"rejects a list whose child is a sublist instead of a list-item\", () => {\n // The classic half-implemented-nesting bug: the sublist is emitted as a\n // sibling of the items rather than inside one. It renders invalid HTML\n // (<ul> with a direct <ul> child), so the guard must reject it.\n expect(\n isPortableTextContent([\n {\n type: \"list\",\n style: \"bullet\",\n children: [\n { type: \"list-item\", children: [{ text: \"Parent\" }] },\n {\n type: \"list\",\n style: \"bullet\",\n children: [\n { type: \"list-item\", children: [{ text: \"Orphan sub\" }] },\n ],\n },\n ],\n },\n ])\n ).toBe(false);\n });\n\n it(\"rejects a list-item child that is neither a span nor a nested list\", () => {\n // A stray paragraph child — the guard is widened for nested lists only.\n expect(\n isPortableTextContent([\n {\n type: \"list\",\n children: [\n {\n type: \"list-item\",\n children: [\n { text: \"An item\" },\n { type: \"paragraph\", children: [{ text: \"not allowed here\" }] },\n ],\n },\n ],\n },\n ])\n ).toBe(false);\n // An embedded object child is rejected too.\n expect(\n isPortableTextContent([\n {\n type: \"list\",\n children: [\n {\n type: \"list-item\",\n children: [{ type: \"object\", _type: \"callout\" }],\n },\n ],\n },\n ])\n ).toBe(false);\n });\n\n it(\"accepts a code-block without a language and a table without rows\", () => {\n expect(\n isPortableTextContent([{ type: \"code-block\", code: \"npm install\" }])\n ).toBe(true);\n expect(\n isPortableTextContent([\n { type: \"table\", header: [[{ text: \"A\" }]], rows: [] },\n ])\n ).toBe(true);\n expect(isPortableTextContent([{ type: \"divider\" }])).toBe(true);\n });\n\n it(\"accepts a titled-text with only a title, with or without content\", () => {\n expect(\n isPortableTextContent([{ type: \"titled-text\", title: \"Ranges\" }])\n ).toBe(true);\n expect(\n isPortableTextContent([\n { type: \"titled-text\", title: \"Ranges\", content: [] },\n ])\n ).toBe(true);\n });\n\n it(\"tells blocks, objects and spans apart\", () => {\n const [heading, paragraph] = sampleMessageContent;\n const callout = sampleMessageContent[5];\n\n expect(isPortableTextBlock(heading)).toBe(true);\n expect(isPortableTextBlock(callout)).toBe(false);\n expect(isPortableTextObjectNode(callout)).toBe(true);\n expect(isPortableTextObjectNode(heading)).toBe(false);\n expect(isPortableTextSpan({ text: \"plain\" })).toBe(true);\n expect(isPortableTextSpan(paragraph)).toBe(false);\n });\n\n it(\"ships a universal default set free of product elements\", () => {\n expect(PORTABLE_TEXT_DEFAULT_BLOCKS).toEqual([\n \"paragraph\",\n \"heading\",\n \"list\",\n \"list-item\",\n \"media\",\n \"titled-text\",\n \"code-block\",\n \"table\",\n \"divider\",\n ]);\n expect(PORTABLE_TEXT_DEFAULT_MARKS).toEqual([\n \"strong\",\n \"em\",\n \"code\",\n \"link\",\n ]);\n });\n\n it(\"keeps video media variants in the envelope but out of the image variant set\", () => {\n expect(\n isPortableTextContent([\n {\n type: \"media\",\n variant: \"vimeo\",\n src: \"https://vimeo.com/1131696931\",\n caption: \"Duplicating a project\",\n },\n {\n type: \"media\",\n variant: \"youtube\",\n src: \"https://www.youtube.com/watch?v=dQw4w9WgXcQ\",\n },\n ])\n ).toBe(true);\n\n expect(isPortableTextMediaImageVariant(\"screenshot\")).toBe(true);\n expect(isPortableTextMediaImageVariant(\"illustration\")).toBe(true);\n expect(isPortableTextMediaImageVariant(\"vimeo\")).toBe(false);\n expect(isPortableTextMediaImageVariant(\"youtube\")).toBe(false);\n expect(isPortableTextMediaImageVariant(undefined)).toBe(false);\n });\n\n it(\"accepts an application components map through the injection contract\", () => {\n const seen: string[] = [];\n const components: PortableTextComponents = {\n marks: {\n \"interface-name\": ({ children }) =>\n createElement(Fragment, null, children),\n },\n objects: {\n callout: ({ children }) => createElement(Fragment, null, children),\n },\n onUnknownType: (kind, type) => {\n seen.push(`${kind}:${type}`);\n },\n };\n\n components.onUnknownType?.(\"object\", \"some-future-element\");\n\n expect(Object.keys(components.marks ?? {})).toEqual([\"interface-name\"]);\n expect(seen).toEqual([\"object:some-future-element\"]);\n });\n});\n"],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I,EAAAV,iBAAA,GAACE,UAAU,CAAC3B,KAAK,YAAAyB,iBAAA,GAAI,CAAC,CAAC,CAAC,CAAC,CAACF,OAAO,CAAC,CAAC,gBAAgB,CAAC,CAAC;IACvEP,MAAM,CAACU,IAAI,CAAC,CAACH,OAAO,CAAC,CAAC,4BAA4B,CAAC,CAAC;EACtD,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"types.test.js","names":["createElement","Fragment","isPortableTextBlock","isPortableTextContent","isPortableTextMediaImageVariant","isPortableTextObjectNode","isPortableTextSpan","PORTABLE_TEXT_DEFAULT_BLOCKS","PORTABLE_TEXT_DEFAULT_MARKS","describe","sampleMessageContent","type","level","children","text","marks","article","style","src","variant","caption","title","content","_type","tone","label","language","code","header","rows","it","expect","toBe","payload","data","id","heading","paragraph","callout","toEqual","undefined","_components$marks","seen","components","_ref","objects","_ref2","onUnknownType","kind","push","Object","keys"],"sources":["../../../../src/components/PortableText/types.test.ts"],"sourcesContent":["import { createElement, Fragment } from \"react\";\n\nimport {\n isPortableTextBlock,\n isPortableTextContent,\n isPortableTextMediaImageVariant,\n isPortableTextObjectNode,\n isPortableTextSpan,\n PORTABLE_TEXT_DEFAULT_BLOCKS,\n PORTABLE_TEXT_DEFAULT_MARKS,\n PortableTextComponents,\n PortableTextContent,\n} from \"./types\";\n\ndescribe(\"PortableText envelope\", () => {\n const sampleMessageContent: PortableTextContent = [\n { type: \"heading\", level: 2, children: [{ text: \"IP Firewall\" }] },\n {\n type: \"paragraph\",\n children: [\n { text: \"Open the \" },\n { text: \"Security page\", marks: [\"interface-name\"] },\n { text: \" and press \" },\n { text: \"Enter\", marks: [\"keyboard-key\"] },\n { text: \". Read more in \" },\n {\n text: \"the help article\",\n marks: [{ type: \"doc-link\", article: \"ip-firewall\" }],\n },\n { text: \".\" },\n ],\n },\n {\n type: \"list\",\n style: \"bullet\",\n children: [\n {\n type: \"list-item\",\n children: [{ text: \"Allowlist the IPs you trust\" }],\n },\n {\n type: \"list-item\",\n children: [{ text: \"immediately\", marks: [\"strong\"] }],\n },\n ],\n },\n {\n type: \"media\",\n src: \"/screenshots/firewall.png\",\n variant: \"screenshot\",\n caption: \"The firewall settings\",\n },\n {\n type: \"titled-text\",\n title: \"Allowlist the IPs you trust\",\n level: 3,\n content: [\n { type: \"paragraph\", children: [{ text: \"Add one range per line.\" }] },\n ],\n },\n {\n type: \"object\",\n _type: \"callout\",\n tone: \"note\",\n content: [\n {\n type: \"paragraph\",\n children: [{ text: \"Takes effect immediately.\" }],\n },\n ],\n },\n {\n type: \"object\",\n _type: \"button-reference\",\n label: \"Save Changes\",\n variant: \"primary\",\n },\n { type: \"divider\" },\n {\n type: \"code-block\",\n language: \"json\",\n code: '{ \"allowlist\": [\"203.0.113.0/24\"] }',\n },\n {\n type: \"table\",\n header: [[{ text: \"Range\" }], [{ text: \"Purpose\" }]],\n rows: [\n [\n [{ text: \"203.0.113.0/24\", marks: [\"code\"] }],\n [{ text: \"Office\", marks: [\"strong\"] }],\n ],\n [[{ text: \"198.51.100.0/24\", marks: [\"code\"] }], [{ text: \"VPN\" }]],\n ],\n },\n ];\n\n it(\"validates a sample message that mixes default blocks and catalog objects\", () => {\n expect(isPortableTextContent(sampleMessageContent)).toBe(true);\n });\n\n it(\"keeps unknown block and object types valid so older clients degrade instead of break\", () => {\n expect(\n isPortableTextContent([\n { type: \"some-future-block\", payload: 1 },\n { type: \"object\", _type: \"some-future-element\", data: true },\n ])\n ).toBe(true);\n });\n\n it(\"rejects nodes without a type discriminator and objects without _type\", () => {\n expect(isPortableTextContent([{ children: [] }])).toBe(false);\n expect(isPortableTextContent([{ type: \"object\" }])).toBe(false);\n expect(isPortableTextContent([\"paragraph\"])).toBe(false);\n expect(isPortableTextContent({ content: [] })).toBe(false);\n });\n\n it(\"rejects known blocks whose shape a serializer bug has broken\", () => {\n expect(isPortableTextContent([{ type: \"paragraph\" }])).toBe(false);\n expect(\n isPortableTextContent([{ type: \"heading\", level: 2, children: \"oops\" }])\n ).toBe(false);\n expect(\n isPortableTextContent([\n { type: \"heading\", level: 2, id: 42, children: [{ text: \"x\" }] },\n ])\n ).toBe(false);\n expect(\n isPortableTextContent([\n { type: \"paragraph\", children: [{ marks: [\"strong\"] }] },\n ])\n ).toBe(false);\n expect(isPortableTextContent([{ type: \"list\" }])).toBe(false);\n expect(\n isPortableTextContent([{ type: \"list\", children: [\"not a node\"] }])\n ).toBe(false);\n expect(isPortableTextContent([{ type: \"media\" }])).toBe(false);\n expect(isPortableTextContent([{ type: \"titled-text\", content: [] }])).toBe(\n false\n );\n expect(\n isPortableTextContent([\n { type: \"titled-text\", title: \"Ranges\", content: \"oops\" },\n ])\n ).toBe(false);\n });\n\n it(\"rejects malformed code-block, table and divider-adjacent shapes\", () => {\n expect(isPortableTextContent([{ type: \"code-block\" }])).toBe(false);\n expect(isPortableTextContent([{ type: \"code-block\", code: 42 }])).toBe(\n false\n );\n expect(\n isPortableTextContent([{ type: \"code-block\", code: \"x\", language: 1 }])\n ).toBe(false);\n expect(isPortableTextContent([{ type: \"table\" }])).toBe(false);\n expect(\n isPortableTextContent([{ type: \"table\", header: [], rows: \"oops\" }])\n ).toBe(false);\n expect(\n isPortableTextContent([\n { type: \"table\", header: [[{ text: \"A\" }]], rows: [[\"not a cell\"]] },\n ])\n ).toBe(false);\n expect(\n isPortableTextContent([\n { type: \"table\", header: [{ text: \"not a cell\" }], rows: [] },\n ])\n ).toBe(false);\n });\n\n it(\"accepts a list-item whose children nest a list block after its spans\", () => {\n expect(\n isPortableTextContent([\n {\n type: \"list\",\n style: \"bullet\",\n children: [\n {\n type: \"list-item\",\n children: [\n { text: \"Step 3:\", marks: [\"strong\"] },\n { text: \" Choose one of the following options:\" },\n {\n type: \"list\",\n style: \"bullet\",\n children: [\n {\n type: \"list-item\",\n children: [{ text: \"Sign in via Email\" }],\n },\n {\n type: \"list-item\",\n children: [{ text: \"Sign in via your Google account\" }],\n },\n ],\n },\n ],\n },\n ],\n },\n ])\n ).toBe(true);\n });\n\n it(\"validates a list nested four levels deep with mixed styles per level\", () => {\n expect(\n isPortableTextContent([\n {\n type: \"list\",\n style: \"number\",\n children: [\n {\n type: \"list-item\",\n children: [\n { text: \"Top level, ordered\" },\n {\n type: \"list\",\n style: \"bullet\",\n children: [\n {\n type: \"list-item\",\n children: [\n { text: \"Level 2, bullet\" },\n {\n type: \"list\",\n style: \"number\",\n children: [\n {\n type: \"list-item\",\n children: [\n { text: \"Level 3, ordered\" },\n {\n type: \"list\",\n style: \"bullet\",\n children: [\n {\n type: \"list-item\",\n children: [{ text: \"Level 4, bullet\" }],\n },\n ],\n },\n ],\n },\n ],\n },\n ],\n },\n ],\n },\n ],\n },\n ],\n },\n ])\n ).toBe(true);\n });\n\n it(\"rejects a list whose child is a sublist instead of a list-item\", () => {\n // The classic half-implemented-nesting bug: the sublist is emitted as a\n // sibling of the items rather than inside one. It renders invalid HTML\n // (<ul> with a direct <ul> child), so the guard must reject it.\n expect(\n isPortableTextContent([\n {\n type: \"list\",\n style: \"bullet\",\n children: [\n { type: \"list-item\", children: [{ text: \"Parent\" }] },\n {\n type: \"list\",\n style: \"bullet\",\n children: [\n { type: \"list-item\", children: [{ text: \"Orphan sub\" }] },\n ],\n },\n ],\n },\n ])\n ).toBe(false);\n });\n\n it(\"rejects a list-item child that is neither a span nor a nested list\", () => {\n // A stray paragraph child — the guard is widened for nested lists only.\n expect(\n isPortableTextContent([\n {\n type: \"list\",\n children: [\n {\n type: \"list-item\",\n children: [\n { text: \"An item\" },\n { type: \"paragraph\", children: [{ text: \"not allowed here\" }] },\n ],\n },\n ],\n },\n ])\n ).toBe(false);\n // An embedded object child is rejected too.\n expect(\n isPortableTextContent([\n {\n type: \"list\",\n children: [\n {\n type: \"list-item\",\n children: [{ type: \"object\", _type: \"callout\" }],\n },\n ],\n },\n ])\n ).toBe(false);\n });\n\n it(\"accepts a code-block without a language and a table without rows\", () => {\n expect(\n isPortableTextContent([{ type: \"code-block\", code: \"npm install\" }])\n ).toBe(true);\n expect(\n isPortableTextContent([\n { type: \"table\", header: [[{ text: \"A\" }]], rows: [] },\n ])\n ).toBe(true);\n expect(isPortableTextContent([{ type: \"divider\" }])).toBe(true);\n });\n\n it(\"accepts a titled-text with only a title, with or without content\", () => {\n expect(\n isPortableTextContent([{ type: \"titled-text\", title: \"Ranges\" }])\n ).toBe(true);\n expect(\n isPortableTextContent([\n { type: \"titled-text\", title: \"Ranges\", content: [] },\n ])\n ).toBe(true);\n });\n\n it(\"accepts a heading carrying an optional anchor id\", () => {\n expect(\n isPortableTextContent([\n {\n type: \"heading\",\n level: 2,\n id: \"sub-create-a-task\",\n children: [{ text: \"Anchored\" }],\n },\n ])\n ).toBe(true);\n });\n\n it(\"tells blocks, objects and spans apart\", () => {\n const [heading, paragraph] = sampleMessageContent;\n const callout = sampleMessageContent[5];\n\n expect(isPortableTextBlock(heading)).toBe(true);\n expect(isPortableTextBlock(callout)).toBe(false);\n expect(isPortableTextObjectNode(callout)).toBe(true);\n expect(isPortableTextObjectNode(heading)).toBe(false);\n expect(isPortableTextSpan({ text: \"plain\" })).toBe(true);\n expect(isPortableTextSpan(paragraph)).toBe(false);\n });\n\n it(\"ships a universal default set free of product elements\", () => {\n expect(PORTABLE_TEXT_DEFAULT_BLOCKS).toEqual([\n \"paragraph\",\n \"heading\",\n \"list\",\n \"list-item\",\n \"media\",\n \"titled-text\",\n \"code-block\",\n \"table\",\n \"divider\",\n ]);\n expect(PORTABLE_TEXT_DEFAULT_MARKS).toEqual([\n \"strong\",\n \"em\",\n \"code\",\n \"link\",\n ]);\n });\n\n it(\"keeps video media variants in the envelope but out of the image variant set\", () => {\n expect(\n isPortableTextContent([\n {\n type: \"media\",\n variant: \"vimeo\",\n src: \"https://vimeo.com/1131696931\",\n caption: \"Duplicating a project\",\n },\n {\n type: \"media\",\n variant: \"youtube\",\n src: \"https://www.youtube.com/watch?v=dQw4w9WgXcQ\",\n },\n ])\n ).toBe(true);\n\n expect(isPortableTextMediaImageVariant(\"screenshot\")).toBe(true);\n expect(isPortableTextMediaImageVariant(\"illustration\")).toBe(true);\n expect(isPortableTextMediaImageVariant(\"vimeo\")).toBe(false);\n expect(isPortableTextMediaImageVariant(\"youtube\")).toBe(false);\n expect(isPortableTextMediaImageVariant(undefined)).toBe(false);\n });\n\n it(\"accepts an application components map through the injection contract\", () => {\n const seen: string[] = [];\n const components: PortableTextComponents = {\n marks: {\n \"interface-name\": ({ children }) =>\n createElement(Fragment, null, children),\n },\n objects: {\n callout: ({ children }) => createElement(Fragment, null, children),\n },\n onUnknownType: (kind, type) => {\n seen.push(`${kind}:${type}`);\n },\n };\n\n components.onUnknownType?.(\"object\", \"some-future-element\");\n\n expect(Object.keys(components.marks ?? {})).toEqual([\"interface-name\"]);\n expect(seen).toEqual([\"object:some-future-element\"]);\n });\n});\n"],"mappings":"AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,OAAO;AAE/C,SACEC,mBAAmB,EACnBC,qBAAqB,EACrBC,+BAA+B,EAC/BC,wBAAwB,EACxBC,kBAAkB,EAClBC,4BAA4B,EAC5BC,2BAA2B,QAGtB,SAAS;AAEhBC,QAAQ,CAAC,uBAAuB,EAAE,MAAM;EACtC,MAAMC,oBAAyC,GAAG,CAChD;IAAEC,IAAI,EAAE,SAAS;IAAEC,KAAK,EAAE,CAAC;IAAEC,QAAQ,EAAE,CAAC;MAAEC,IAAI,EAAE;IAAc,CAAC;EAAE,CAAC,EAClE;IACEH,IAAI,EAAE,WAAW;IACjBE,QAAQ,EAAE,CACR;MAAEC,IAAI,EAAE;IAAY,CAAC,EACrB;MAAEA,IAAI,EAAE,eAAe;MAAEC,KAAK,EAAE,CAAC,gBAAgB;IAAE,CAAC,EACpD;MAAED,IAAI,EAAE;IAAc,CAAC,EACvB;MAAEA,IAAI,EAAE,OAAO;MAAEC,KAAK,EAAE,CAAC,cAAc;IAAE,CAAC,EAC1C;MAAED,IAAI,EAAE;IAAkB,CAAC,EAC3B;MACEA,IAAI,EAA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,CAAC,4BAA4B,CAAC,CAAC;EACtD,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -1,18 +1,22 @@
1
1
  import React, { ComponentType, ReactNode } from "react";
2
2
  /** Heading typography of a TitledText — a component prop, not wire data. */
3
3
  export type TitledTextVariant = "title1" | "title2" | "header2";
4
+ /** Props every heading in the trio accepts: content plus an optional anchor id. */
5
+ interface TitledTextHeadingProps {
6
+ id?: string;
7
+ children?: ReactNode;
8
+ }
4
9
  /**
5
10
  * The one heading trio the envelope renders — TitledText variants and the
6
11
  * Portable Text `heading` / `titled-text` levels all resolve through this
7
12
  * map, so the typography can never drift between them.
8
13
  */
9
- export declare const titledTextHeadings: Record<TitledTextVariant, ComponentType<{
10
- children?: ReactNode;
11
- }>>;
14
+ export declare const titledTextHeadings: Record<TitledTextVariant, ComponentType<TitledTextHeadingProps>>;
12
15
  export interface ITitledTextProps extends Omit<React.ComponentPropsWithoutRef<"div">, "title"> {
13
16
  title: string;
14
17
  variant?: TitledTextVariant;
15
18
  }
16
19
  /** A heading plus body, with typography control on the heading. */
17
20
  export declare const TitledText: React.ForwardRefExoticComponent<ITitledTextProps & React.RefAttributes<HTMLDivElement>>;
21
+ export {};
18
22
  //# sourceMappingURL=TitledText.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TitledText.d.ts","sourceRoot":"","sources":["../../../../src/components/TitledText/TitledText.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,SAAS,EAAc,MAAM,OAAO,CAAC;AAMpE,4EAA4E;AAC5E,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AAMhE;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CACrC,iBAAiB,EACjB,aAAa,CAAC;IAAE,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,CAAC,CAKxC,CAAC;AAEF,MAAM,WAAW,gBACf,SAAQ,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IAC5D,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,iBAAiB,CAAC;CAC7B;AAED,mEAAmE;AACnE,eAAO,MAAM,UAAU,yFAWtB,CAAC"}
1
+ {"version":3,"file":"TitledText.d.ts","sourceRoot":"","sources":["../../../../src/components/TitledText/TitledText.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,SAAS,EAAc,MAAM,OAAO,CAAC;AAMpE,4EAA4E;AAC5E,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEhE,mFAAmF;AACnF,UAAU,sBAAsB;IAC9B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAQD;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CACrC,iBAAiB,EACjB,aAAa,CAAC,sBAAsB,CAAC,CAKtC,CAAC;AAEF,MAAM,WAAW,gBACf,SAAQ,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IAC5D,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,iBAAiB,CAAC;CAC7B;AAED,mEAAmE;AACnE,eAAO,MAAM,UAAU,yFAWtB,CAAC"}
@@ -8,9 +8,13 @@ import { Header2, Title2 } from "../Typography";
8
8
 
9
9
  /** Heading typography of a TitledText — a component prop, not wire data. */
10
10
 
11
+ /** Props every heading in the trio accepts: content plus an optional anchor id. */
12
+
11
13
  const BoldTitle2 = _ref => {
12
- let children = _ref.children;
14
+ let id = _ref.id,
15
+ children = _ref.children;
13
16
  return /*#__PURE__*/React.createElement(Title2, {
17
+ id: id,
14
18
  weight: "bold"
15
19
  }, children);
16
20
  };
@@ -1 +1 @@
1
- {"version":3,"file":"TitledText.js","names":["React","forwardRef","StyledTitle1","Stack","Header2","Title2","BoldTitle2","_ref","children","createElement","weight","titledTextHeadings","title1","title2","header2","TitledText","_ref2","ref","_titledTextHeadings$v","title","_ref2$variant","variant","rest","_objectWithoutPropertiesLoose","_excluded","Heading","_extends","space","displayName"],"sources":["../../../../src/components/TitledText/TitledText.tsx"],"sourcesContent":["import React, { ComponentType, ReactNode, forwardRef } from \"react\";\n\nimport { StyledTitle1 } from \"./Styles\";\nimport { Stack } from \"../Stack\";\nimport { Header2, Title2 } from \"../Typography\";\n\n/** Heading typography of a TitledText — a component prop, not wire data. */\nexport type TitledTextVariant = \"title1\" | \"title2\" | \"header2\";\n\nconst BoldTitle2 = ({ children }: { children?: ReactNode }) => (\n <Title2 weight=\"bold\">{children}</Title2>\n);\n\n/**\n * The one heading trio the envelope renders — TitledText variants and the\n * Portable Text `heading` / `titled-text` levels all resolve through this\n * map, so the typography can never drift between them.\n */\nexport const titledTextHeadings: Record<\n TitledTextVariant,\n ComponentType<{ children?: ReactNode }>\n> = {\n title1: StyledTitle1,\n title2: BoldTitle2,\n header2: Header2,\n};\n\nexport interface ITitledTextProps\n extends Omit<React.ComponentPropsWithoutRef<\"div\">, \"title\"> {\n title: string;\n variant?: TitledTextVariant;\n}\n\n/** A heading plus body, with typography control on the heading. */\nexport const TitledText = forwardRef<HTMLDivElement, ITitledTextProps>(\n ({ title, variant = \"header2\", children, ...rest }, ref) => {\n const Heading = titledTextHeadings[variant] ?? titledTextHeadings.header2;\n\n return (\n <Stack ref={ref} space={children ? \"xs\" : \"none\"} {...rest}>\n <Heading>{title}</Heading>\n {children}\n </Stack>\n );\n }\n);\n\nTitledText.displayName = \"TitledText\";\n"],"mappings":";;;AAAA,OAAOA,KAAK,IAA8BC,UAAU,QAAQ,OAAO;AAEnE,SAASC,YAAY,QAAQ,UAAU;AACvC,SAASC,KAAK,QAAQ,UAAU;AAChC,SAASC,OAAO,EAAEC,MAAM,QAAQ,eAAe;;AAE/C;;AAGA,MAAMC,UAAU,GAAGC,IAAA;EAAA,IAAGC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;EAAA,oBAC5BR,KAAA,CAAAS,aAAA,CAACJ,MAAM;IAACK,MAAM,EAAC;EAAM,GAAEF,QAAiB,CAAC;AAAA,CAC1C;;AAED;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMG,kBAGZ,GAAG;EACFC,MAAM,EAAEV,YAAY;EACpBW,MAAM,EAAEP,UAAU;EAClBQ,OAAO,EAAEV;AACX,CAAC;AAQD;AACA,OAAO,MAAMW,UAAU,gBAAGd,UAAU,CAClC,CAAAe,KAAA,EAAoDC,GAAG,KAAK;EAAA,IAAAC,qBAAA;EAAA,IAAzDC,KAAK,GAAAH,KAAA,CAALG,KAAK;IAAAC,aAAA,GAAAJ,KAAA,CAAEK,OAAO;IAAPA,OAAO,GAAAD,aAAA,cAAG,SAAS,GAAAA,aAAA;IAAEZ,QAAQ,GAAAQ,KAAA,CAARR,QAAQ;IAAKc,IAAI,GAAAC,6BAAA,CAAAP,KAAA,EAAAQ,SAAA;EAC9C,MAAMC,OAAO,IAAAP,qBAAA,GAAGP,kBAAkB,CAACU,OAAO,CAAC,YAAAH,qBAAA,GAAIP,kBAAkB,CAACG,OAAO;EAEzE,oBACEd,KAAA,CAAAS,aAAA,CAACN,KAAK,EAAAuB,QAAA;IAACT,GAAG,EAAEA,GAAI;IAACU,KAAK,EAAEnB,QAAQ,GAAG,IAAI,GAAG;EAAO,GAAKc,IAAI,gBACxDtB,KAAA,CAAAS,aAAA,CAACgB,OAAO,QAAEN,KAAe,CAAC,EACzBX,QACI,CAAC;AAEZ,CACF,CAAC;AAEDO,UAAU,CAACa,WAAW,GAAG,YAAY","ignoreList":[]}
1
+ {"version":3,"file":"TitledText.js","names":["React","forwardRef","StyledTitle1","Stack","Header2","Title2","BoldTitle2","_ref","id","children","createElement","weight","titledTextHeadings","title1","title2","header2","TitledText","_ref2","ref","_titledTextHeadings$v","title","_ref2$variant","variant","rest","_objectWithoutPropertiesLoose","_excluded","Heading","_extends","space","displayName"],"sources":["../../../../src/components/TitledText/TitledText.tsx"],"sourcesContent":["import React, { ComponentType, ReactNode, forwardRef } from \"react\";\n\nimport { StyledTitle1 } from \"./Styles\";\nimport { Stack } from \"../Stack\";\nimport { Header2, Title2 } from \"../Typography\";\n\n/** Heading typography of a TitledText — a component prop, not wire data. */\nexport type TitledTextVariant = \"title1\" | \"title2\" | \"header2\";\n\n/** Props every heading in the trio accepts: content plus an optional anchor id. */\ninterface TitledTextHeadingProps {\n id?: string;\n children?: ReactNode;\n}\n\nconst BoldTitle2 = ({ id, children }: TitledTextHeadingProps) => (\n <Title2 id={id} weight=\"bold\">\n {children}\n </Title2>\n);\n\n/**\n * The one heading trio the envelope renders — TitledText variants and the\n * Portable Text `heading` / `titled-text` levels all resolve through this\n * map, so the typography can never drift between them.\n */\nexport const titledTextHeadings: Record<\n TitledTextVariant,\n ComponentType<TitledTextHeadingProps>\n> = {\n title1: StyledTitle1,\n title2: BoldTitle2,\n header2: Header2,\n};\n\nexport interface ITitledTextProps\n extends Omit<React.ComponentPropsWithoutRef<\"div\">, \"title\"> {\n title: string;\n variant?: TitledTextVariant;\n}\n\n/** A heading plus body, with typography control on the heading. */\nexport const TitledText = forwardRef<HTMLDivElement, ITitledTextProps>(\n ({ title, variant = \"header2\", children, ...rest }, ref) => {\n const Heading = titledTextHeadings[variant] ?? titledTextHeadings.header2;\n\n return (\n <Stack ref={ref} space={children ? \"xs\" : \"none\"} {...rest}>\n <Heading>{title}</Heading>\n {children}\n </Stack>\n );\n }\n);\n\nTitledText.displayName = \"TitledText\";\n"],"mappings":";;;AAAA,OAAOA,KAAK,IAA8BC,UAAU,QAAQ,OAAO;AAEnE,SAASC,YAAY,QAAQ,UAAU;AACvC,SAASC,KAAK,QAAQ,UAAU;AAChC,SAASC,OAAO,EAAEC,MAAM,QAAQ,eAAe;;AAE/C;;AAGA;;AAMA,MAAMC,UAAU,GAAGC,IAAA;EAAA,IAAGC,EAAE,GAAAD,IAAA,CAAFC,EAAE;IAAEC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;EAAA,oBAChCT,KAAA,CAAAU,aAAA,CAACL,MAAM;IAACG,EAAE,EAAEA,EAAG;IAACG,MAAM,EAAC;EAAM,GAC1BF,QACK,CAAC;AAAA,CACV;;AAED;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMG,kBAGZ,GAAG;EACFC,MAAM,EAAEX,YAAY;EACpBY,MAAM,EAAER,UAAU;EAClBS,OAAO,EAAEX;AACX,CAAC;AAQD;AACA,OAAO,MAAMY,UAAU,gBAAGf,UAAU,CAClC,CAAAgB,KAAA,EAAoDC,GAAG,KAAK;EAAA,IAAAC,qBAAA;EAAA,IAAzDC,KAAK,GAAAH,KAAA,CAALG,KAAK;IAAAC,aAAA,GAAAJ,KAAA,CAAEK,OAAO;IAAPA,OAAO,GAAAD,aAAA,cAAG,SAAS,GAAAA,aAAA;IAAEZ,QAAQ,GAAAQ,KAAA,CAARR,QAAQ;IAAKc,IAAI,GAAAC,6BAAA,CAAAP,KAAA,EAAAQ,SAAA;EAC9C,MAAMC,OAAO,IAAAP,qBAAA,GAAGP,kBAAkB,CAACU,OAAO,CAAC,YAAAH,qBAAA,GAAIP,kBAAkB,CAACG,OAAO;EAEzE,oBACEf,KAAA,CAAAU,aAAA,CAACP,KAAK,EAAAwB,QAAA;IAACT,GAAG,EAAEA,GAAI;IAACU,KAAK,EAAEnB,QAAQ,GAAG,IAAI,GAAG;EAAO,GAAKc,IAAI,gBACxDvB,KAAA,CAAAU,aAAA,CAACgB,OAAO,QAAEN,KAAe,CAAC,EACzBX,QACI,CAAC;AAEZ,CACF,CAAC;AAEDO,UAAU,CAACa,WAAW,GAAG,YAAY","ignoreList":[]}
package/dist/index.js CHANGED
@@ -25481,8 +25481,9 @@
25481
25481
  }
25482
25482
  switch (value.type) {
25483
25483
  case "paragraph":
25484
- case "heading":
25485
25484
  return Array.isArray(value.children) && value.children.every(isPortableTextSpan);
25485
+ case "heading":
25486
+ return (value.id === undefined || typeof value.id === "string") && Array.isArray(value.children) && value.children.every(isPortableTextSpan);
25486
25487
  case "list-item":
25487
25488
  // The item's spans, plus optional nested `list` block(s). Widened only
25488
25489
  // for nested lists: any other block child (a stray paragraph, an object)
@@ -25591,9 +25592,13 @@
25591
25592
 
25592
25593
  /** Heading typography of a TitledText — a component prop, not wire data. */
25593
25594
 
25595
+ /** Props every heading in the trio accepts: content plus an optional anchor id. */
25596
+
25594
25597
  var BoldTitle2 = function BoldTitle2(_ref) {
25595
- var children = _ref.children;
25598
+ var id = _ref.id,
25599
+ children = _ref.children;
25596
25600
  return /*#__PURE__*/React__default["default"].createElement(Title2, {
25601
+ id: id,
25597
25602
  weight: "bold"
25598
25603
  }, children);
25599
25604
  };
@@ -25694,9 +25699,12 @@
25694
25699
  var block = _ref5.block,
25695
25700
  children = _ref5.children;
25696
25701
  var _ref6 = block,
25697
- level = _ref6.level;
25702
+ level = _ref6.level,
25703
+ id = _ref6.id;
25698
25704
  var Heading = titledTextHeadings[headingVariantForLevel(level)];
25699
- return /*#__PURE__*/React__default["default"].createElement(Heading, null, children);
25705
+ return /*#__PURE__*/React__default["default"].createElement(Heading, {
25706
+ id: id
25707
+ }, children);
25700
25708
  };
25701
25709
  var portableTextDefaultBlockRenderers = {
25702
25710
  paragraph: function paragraph(_ref7) {