@assistant-ui/react-generative-ui 0.0.12 → 0.0.14

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.
Files changed (48) hide show
  1. package/dist/JSONGenerativeUI.client.d.ts +5 -0
  2. package/dist/JSONGenerativeUI.client.d.ts.map +1 -1
  3. package/dist/JSONGenerativeUI.client.js +12 -3
  4. package/dist/JSONGenerativeUI.client.js.map +1 -1
  5. package/dist/renderGenerativeUI.js +2 -1
  6. package/dist/renderGenerativeUI.js.map +1 -1
  7. package/dist/slack/constants.d.ts +11 -4
  8. package/dist/slack/constants.d.ts.map +1 -1
  9. package/dist/slack/constants.js +11 -4
  10. package/dist/slack/constants.js.map +1 -1
  11. package/dist/slack/fromSlackBlocks.js +2 -2
  12. package/dist/slack/toSlackBlocks.d.ts.map +1 -1
  13. package/dist/slack/toSlackBlocks.js +114 -19
  14. package/dist/slack/toSlackBlocks.js.map +1 -1
  15. package/dist/slack/types.d.ts +7 -1
  16. package/dist/slack/types.d.ts.map +1 -1
  17. package/dist/teams/constants.d.ts +9 -2
  18. package/dist/teams/constants.d.ts.map +1 -1
  19. package/dist/teams/constants.js +10 -3
  20. package/dist/teams/constants.js.map +1 -1
  21. package/dist/teams/toAdaptiveCard.d.ts +10 -2
  22. package/dist/teams/toAdaptiveCard.d.ts.map +1 -1
  23. package/dist/teams/toAdaptiveCard.js +54 -15
  24. package/dist/teams/toAdaptiveCard.js.map +1 -1
  25. package/dist/teams/toTeamsAttachments.d.ts.map +1 -1
  26. package/dist/teams/toTeamsAttachments.js +21 -13
  27. package/dist/teams/toTeamsAttachments.js.map +1 -1
  28. package/dist/teams/types.d.ts +11 -2
  29. package/dist/teams/types.d.ts.map +1 -1
  30. package/dist/vocabulary/data.js +3 -2
  31. package/dist/vocabulary/data.js.map +1 -1
  32. package/dist/vocabulary/layout.js +2 -1
  33. package/dist/vocabulary/layout.js.map +1 -1
  34. package/package.json +5 -5
  35. package/src/JSONGenerativeUI.client.tsx +13 -5
  36. package/src/JSONGenerativeUI.test.tsx +21 -2
  37. package/src/slack/constants.ts +11 -3
  38. package/src/slack/toSlackBlocks.test.ts +374 -8
  39. package/src/slack/toSlackBlocks.ts +181 -24
  40. package/src/slack/types.ts +7 -1
  41. package/src/teams/constants.ts +10 -2
  42. package/src/teams/toAdaptiveCard.test.ts +204 -10
  43. package/src/teams/toAdaptiveCard.ts +79 -15
  44. package/src/teams/toTeamsAttachments.test.ts +47 -2
  45. package/src/teams/toTeamsAttachments.ts +17 -11
  46. package/src/teams/types.ts +11 -2
  47. package/src/vocabulary/layout.test.tsx +16 -1
  48. package/src/vocabulary/layout.tsx +4 -1
@@ -1 +1 @@
1
- {"version":3,"file":"toAdaptiveCard.js","names":[],"sources":["../../src/teams/toAdaptiveCard.ts"],"sourcesContent":["import {\n normalizeSpec,\n type NormalizedUIElement,\n type NormalizedUINode,\n} from \"../ir\";\nimport { boundSpec } from \"./boundSpec\";\nimport {\n CHOICE_OPTION_CAP,\n MAX_TRAVERSAL_DEPTH,\n PAYLOAD_SOFT_CAP,\n PRIMARY_ACTION_CAP,\n TABLE_COLUMN_CAP,\n TABLE_ROW_CAP,\n buildCard,\n buildSubmitAction,\n clampReasonDetail,\n utf8ByteLength,\n} from \"./constants\";\nimport type {\n AdaptiveCardResult,\n TeamsActionSet,\n TeamsAdaptiveCard,\n TeamsCardElement,\n TeamsColumn,\n TeamsContainer,\n TeamsContainerStyle,\n TeamsConversionWarning,\n TeamsFact,\n TeamsInputChoice,\n TeamsTable,\n TeamsTableColumnDefinition,\n TeamsTableRow,\n TeamsTextBlock,\n TeamsTextSize,\n ToAdaptiveCardOptions,\n} from \"./types\";\n\n/** Shared mutable conversion state threaded through one top-level conversion. */\nexport interface ConversionContext {\n readonly warnings: TeamsConversionWarning[];\n usedInputIds: Set<string>;\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst isElement = (node: NormalizedUINode): node is NormalizedUIElement =>\n isRecord(node);\n\nconst asString = (value: unknown): string =>\n typeof value === \"string\" ? value : \"\";\n\nconst DATE_PATTERN = /^\\d{4}-\\d{2}-\\d{2}$/;\n\nconst SUBTLE_COLORS = new Set([\n \"secondary\",\n \"alpha-70\",\n \"white\",\n \"white-70\",\n \"white-50\",\n]);\nconst isSubtleColor = (color: unknown): boolean =>\n typeof color === \"string\" && SUBTLE_COLORS.has(color);\n\nconst BOLDER_WEIGHTS = new Set([\"medium\", \"semibold\", \"bold\"]);\nconst isBolderWeight = (weight: unknown): boolean =>\n typeof weight === \"string\" && BOLDER_WEIGHTS.has(weight);\n\nconst TEXT_SIZE_MAP: Record<string, TeamsTextSize> = {\n sm: \"small\",\n lg: \"medium\",\n xl: \"large\",\n \"2xl\": \"extraLarge\",\n \"3xl\": \"extraLarge\",\n};\n\nconst warn = (\n context: ConversionContext,\n code: TeamsConversionWarning[\"code\"],\n component: string,\n detail: string,\n) => {\n context.warnings.push({ code, component, detail });\n};\n\n/**\n * The `aui` key is reserved for the submit envelope (see\n * {@link buildSubmitData} and `decodeSubmitData`): Adaptive Cards merge\n * every input's current value into the same submit object keyed by its\n * `id`, so an input id of `aui` would clobber the envelope. Renamed to an\n * unused id derived from `aui_` instead of being emitted as-is.\n */\nconst RESERVED_INPUT_ID = \"aui\";\n\nfunction reservedSafeId(\n id: string,\n component: string,\n context: ConversionContext,\n): string {\n const reserved = id === RESERVED_INPUT_ID;\n const base = reserved ? `${RESERVED_INPUT_ID}_` : id;\n let candidate = base;\n let n = 2;\n while (context.usedInputIds.has(candidate)) {\n candidate = `${base}_${n}`;\n n += 1;\n }\n if (reserved) {\n warn(\n context,\n \"clamped\",\n component,\n `the input id \"${RESERVED_INPUT_ID}\" collides with the submit envelope's reserved key and was renamed to \"${candidate}\".`,\n );\n } else if (candidate !== base) {\n warn(\n context,\n \"clamped\",\n component,\n `the input id \"${base}\" was already used on this card and was renamed to \"${candidate}\".`,\n );\n }\n context.usedInputIds.add(candidate);\n return candidate;\n}\n\n/**\n * The shared bounded-iteration primitive: slices `value` to `cap` entries\n * without ever reading past that many indices, so a hostile array (sparse or\n * proxied with a fabricated `length`) cannot stall the event loop.\n */\nconst clampArray = (\n value: unknown,\n cap: number,\n): { readonly items: unknown[]; readonly truncated: boolean } => {\n if (!Array.isArray(value)) return { items: [], truncated: false };\n return { items: value.slice(0, cap), truncated: value.length > cap };\n};\n\nconst normalizedList = (\n node: NormalizedUINode | undefined,\n): NormalizedUINode[] => {\n if (node === undefined || node === null) return [];\n if (!Array.isArray(node)) return [node];\n return node.flatMap((child) => normalizedList(child));\n};\n\nfunction textBlock(\n text: string,\n extra?: Partial<Omit<TeamsTextBlock, \"type\" | \"text\" | \"wrap\">>,\n): TeamsTextBlock {\n return { type: \"TextBlock\", text, wrap: true, ...extra };\n}\n\nfunction applyPending(\n element: TeamsCardElement,\n separator: boolean,\n spacing: boolean,\n): TeamsCardElement {\n if (!separator && !spacing) return element;\n return {\n ...element,\n ...(separator ? { separator: true as const } : {}),\n ...(spacing ? { spacing: \"large\" as const } : {}),\n };\n}\n\nconst toChoice = (option: unknown): TeamsInputChoice | undefined => {\n if (!isRecord(option) || typeof option[\"value\"] !== \"string\") {\n return undefined;\n }\n return { title: asString(option[\"label\"]), value: option[\"value\"] };\n};\n\nconst choicesFrom = (\n optionsProp: unknown,\n component: string,\n context: ConversionContext,\n): TeamsInputChoice[] => {\n const { items, truncated } = clampArray(optionsProp, CHOICE_OPTION_CAP);\n if (truncated) {\n warn(\n context,\n \"clamped\",\n component,\n `options were clamped to ${CHOICE_OPTION_CAP} entries.`,\n );\n }\n const choices: TeamsInputChoice[] = [];\n for (const item of items) {\n const choice = toChoice(item);\n if (choice !== undefined) choices.push(choice);\n }\n return choices;\n};\n\nfunction convertFacts(facts: readonly NormalizedUIElement[]): TeamsCardElement {\n const set: TeamsFact[] = facts.map((fact) => ({\n title: asString(fact.props[\"label\"]),\n value: asString(fact.props[\"value\"]),\n }));\n return { type: \"FactSet\", facts: set };\n}\n\n// Action.Submit has no visual style concept, so a Button's `buttonStyle`\n// (positive/destructive or otherwise) has nothing to map onto and is dropped.\nfunction convertButtons(\n buttons: readonly NormalizedUIElement[],\n context: ConversionContext,\n): TeamsActionSet {\n if (buttons.length > PRIMARY_ACTION_CAP) {\n warn(\n context,\n \"clamped\",\n \"Button\",\n `actions beyond ${PRIMARY_ACTION_CAP} were set to secondary mode.`,\n );\n }\n const actions = buttons.map((button, index) =>\n buildSubmitAction(\n asString(button.props[\"label\"]),\n button.action,\n index >= PRIMARY_ACTION_CAP ? \"secondary\" : undefined,\n ),\n );\n return { type: \"ActionSet\", actions };\n}\n\nfunction withCompanionSubmit(\n element: NormalizedUIElement,\n input: TeamsCardElement,\n context: ConversionContext,\n): TeamsCardElement[] {\n if (element.action === undefined) return [input];\n warn(\n context,\n \"fallback\",\n element.type,\n \"Teams inputs cannot dispatch on change; a companion submit action was appended.\",\n );\n return [\n input,\n {\n type: \"ActionSet\",\n actions: [buildSubmitAction(\"Submit\", element.action)],\n },\n ];\n}\n\nfunction cardFooterActionSet(\n props: Readonly<Record<string, unknown>>,\n): TeamsActionSet | undefined {\n const actions = ([\"confirm\", \"cancel\"] as const)\n .map((key) => props[key])\n .filter(isRecord)\n .map((footer) =>\n buildSubmitAction(asString(footer[\"label\"]), footer[\"$action\"]),\n );\n return actions.length > 0 ? { type: \"ActionSet\", actions } : undefined;\n}\n\nconst ALERT_STYLE_MAP: Record<string, TeamsContainerStyle> = {\n info: \"accent\",\n success: \"good\",\n warning: \"warning\",\n danger: \"attention\",\n};\n\nconst stringifyCell = (value: unknown): string => {\n if (typeof value === \"string\") return value;\n if (typeof value === \"number\" || typeof value === \"boolean\")\n return String(value);\n return \"\";\n};\n\nfunction convertTable(\n props: Readonly<Record<string, unknown>>,\n context: ConversionContext,\n): TeamsTable {\n const { items: rawColumns, truncated: columnsTruncated } = clampArray(\n props[\"columns\"],\n TABLE_COLUMN_CAP,\n );\n const { items: rawRows, truncated: rowsTruncated } = clampArray(\n props[\"rows\"],\n TABLE_ROW_CAP,\n );\n if (columnsTruncated) {\n warn(\n context,\n \"clamped\",\n \"Table\",\n `columns were clamped to ${TABLE_COLUMN_CAP} entries.`,\n );\n }\n if (rowsTruncated) {\n warn(\n context,\n \"clamped\",\n \"Table\",\n `rows were clamped to ${TABLE_ROW_CAP} entries.`,\n );\n }\n\n const hasColumns = rawColumns.length > 0;\n const columns: TeamsTableColumnDefinition[] = rawColumns.map(() => ({\n width: 1 as const,\n }));\n const headerRow: TeamsTableRow | undefined = hasColumns\n ? {\n type: \"TableRow\",\n cells: rawColumns.map((column) => ({\n type: \"TableCell\" as const,\n items: [textBlock(isRecord(column) ? asString(column[\"label\"]) : \"\")],\n })),\n }\n : undefined;\n const dataRows: TeamsTableRow[] = rawRows.map((row) => ({\n type: \"TableRow\",\n cells: (Array.isArray(row) ? row.slice(0, TABLE_COLUMN_CAP) : []).map(\n (cell) => ({\n type: \"TableCell\" as const,\n items: [textBlock(stringifyCell(cell))],\n }),\n ),\n }));\n\n return {\n type: \"Table\",\n firstRowAsHeaders: hasColumns,\n columns,\n rows: headerRow !== undefined ? [headerRow, ...dataRows] : dataRows,\n };\n}\n\nfunction convertListViewItem(\n element: NormalizedUIElement,\n context: ConversionContext,\n depth: number,\n): TeamsContainer {\n const items = convertSequence(element.children, context, depth + 1);\n const selectAction = isRecord(element.action)\n ? buildSubmitAction(\"Open\", element.action)\n : undefined;\n return {\n type: \"Container\",\n items,\n ...(selectAction !== undefined ? { selectAction } : {}),\n };\n}\n\nexport function convertElement(\n element: NormalizedUIElement,\n context: ConversionContext,\n depth: number,\n): TeamsCardElement[] {\n const { props } = element;\n switch (element.type) {\n case \"Header\":\n return [\n textBlock(asString(props[\"text\"]), {\n size: \"large\",\n weight: \"bolder\",\n style: \"heading\",\n }),\n ];\n case \"Text\": {\n const mappedSize =\n typeof props[\"size\"] === \"string\"\n ? TEXT_SIZE_MAP[props[\"size\"]]\n : undefined;\n return [\n textBlock(asString(props[\"value\"]), {\n ...(mappedSize !== undefined ? { size: mappedSize } : {}),\n ...(isBolderWeight(props[\"weight\"]) ? { weight: \"bolder\" } : {}),\n ...(isSubtleColor(props[\"color\"]) ? { isSubtle: true } : {}),\n }),\n ];\n }\n case \"Caption\":\n return [\n textBlock(asString(props[\"value\"]), { size: \"small\", isSubtle: true }),\n ];\n case \"Badge\":\n return [\n textBlock(asString(props[\"value\"]), { size: \"small\", isSubtle: true }),\n ];\n case \"Markdown\":\n // Teams renders a strict subset of markdown (no headings, tables, images,\n // preformatted blocks, or blockquotes); unsupported syntax renders literally.\n return [textBlock(asString(props[\"value\"]))];\n case \"Fact\":\n return [convertFacts([element])];\n case \"Image\": {\n const size = props[\"size\"];\n let mappedSize: \"small\" | \"medium\" | \"large\" | undefined;\n if (size === \"sm\") mappedSize = \"small\";\n else if (size === \"md\") mappedSize = \"medium\";\n else if (size === \"lg\") mappedSize = \"large\";\n else if (typeof size === \"number\") {\n warn(context, \"dropped\", \"Image\", \"A numeric size was dropped.\");\n }\n return [\n {\n type: \"Image\",\n url: asString(props[\"src\"]),\n altText: asString(props[\"alt\"]),\n ...(mappedSize !== undefined ? { size: mappedSize } : {}),\n },\n ];\n }\n case \"Divider\":\n case \"Spacer\":\n case \"Icon\":\n return [];\n case \"Button\":\n return [convertButtons([element], context)];\n case \"Select\": {\n const name = asString(props[\"name\"]);\n const placeholder = asString(props[\"placeholder\"]);\n const label = asString(props[\"label\"]);\n const input: TeamsCardElement = {\n type: \"Input.ChoiceSet\",\n id: reservedSafeId(name || \"select\", \"Select\", context),\n style: \"compact\",\n choices: choicesFrom(props[\"options\"], \"Select\", context),\n ...(placeholder ? { placeholder } : {}),\n ...(label ? { label } : {}),\n };\n return withCompanionSubmit(element, input, context);\n }\n case \"RadioGroup\": {\n const name = asString(props[\"name\"]);\n const label = asString(props[\"label\"]);\n const defaultValue = props[\"defaultValue\"];\n const input: TeamsCardElement = {\n type: \"Input.ChoiceSet\",\n id: reservedSafeId(name || \"radiogroup\", \"RadioGroup\", context),\n style: \"expanded\",\n choices: choicesFrom(props[\"options\"], \"RadioGroup\", context),\n ...(typeof defaultValue === \"string\" && defaultValue\n ? { value: defaultValue }\n : {}),\n ...(label ? { label } : {}),\n };\n return withCompanionSubmit(element, input, context);\n }\n case \"Checkbox\": {\n const name = asString(props[\"name\"]);\n const label = asString(props[\"label\"]);\n const input: TeamsCardElement = {\n type: \"Input.Toggle\",\n id: reservedSafeId(name || label || \"checkbox\", \"Checkbox\", context),\n title: label,\n value: props[\"defaultChecked\"] === true ? \"true\" : \"false\",\n valueOn: \"true\",\n valueOff: \"false\",\n };\n return withCompanionSubmit(element, input, context);\n }\n case \"Input\": {\n const name = asString(props[\"name\"]);\n const label = asString(props[\"label\"]);\n const placeholder = asString(props[\"placeholder\"]);\n const input: TeamsCardElement = {\n type: \"Input.Text\",\n id: reservedSafeId(name || \"input\", \"Input\", context),\n ...(label ? { label } : {}),\n ...(placeholder ? { placeholder } : {}),\n ...(props[\"multiline\"] === true ? { isMultiline: true } : {}),\n };\n return withCompanionSubmit(element, input, context);\n }\n case \"DatePicker\": {\n const name = asString(props[\"name\"]);\n const label = asString(props[\"label\"]);\n const rawValue = props[\"value\"];\n const value =\n typeof rawValue === \"string\" && DATE_PATTERN.test(rawValue)\n ? rawValue\n : undefined;\n const rawMin = props[\"min\"];\n const min =\n typeof rawMin === \"string\" && DATE_PATTERN.test(rawMin)\n ? rawMin\n : undefined;\n const rawMax = props[\"max\"];\n const max =\n typeof rawMax === \"string\" && DATE_PATTERN.test(rawMax)\n ? rawMax\n : undefined;\n const input: TeamsCardElement = {\n type: \"Input.Date\",\n id: reservedSafeId(name || \"datepicker\", \"DatePicker\", context),\n ...(label ? { label } : {}),\n ...(value !== undefined ? { value } : {}),\n ...(min !== undefined ? { min } : {}),\n ...(max !== undefined ? { max } : {}),\n };\n return withCompanionSubmit(element, input, context);\n }\n case \"Form\":\n return [\n ...convertSequence(element.children, context, depth + 1),\n {\n type: \"ActionSet\",\n actions: [buildSubmitAction(\"Submit\", element.action)],\n },\n ];\n case \"Card\": {\n const titleText = asString(props[\"title\"]);\n const items: TeamsCardElement[] = [];\n if (titleText) {\n items.push(\n textBlock(titleText, {\n size: \"large\",\n weight: \"bolder\",\n style: \"heading\",\n }),\n );\n }\n items.push(...convertSequence(element.children, context, depth + 1));\n const container: TeamsContainer = {\n type: \"Container\",\n style: \"default\",\n items,\n };\n const actionSet = cardFooterActionSet(props);\n return actionSet !== undefined ? [container, actionSet] : [container];\n }\n case \"Col\":\n case \"Box\":\n return [\n {\n type: \"Container\",\n items: convertSequence(element.children, context, depth + 1),\n },\n ];\n case \"Row\": {\n const children = normalizedList(element.children);\n if (children.length > 3) {\n warn(context, \"clamped\", \"Row\", \"Teams recommends at most 3 columns.\");\n }\n const columns: TeamsColumn[] = children.map((child) => ({\n type: \"Column\",\n width: \"auto\",\n items: convertSequence(child, context, depth + 1),\n }));\n return [{ type: \"ColumnSet\", columns }];\n }\n case \"ListView\": {\n const containers: TeamsContainer[] = [];\n for (const child of normalizedList(element.children)) {\n if (!isElement(child)) continue;\n if (child.type === \"ListViewItem\") {\n containers.push(convertListViewItem(child, context, depth + 1));\n } else {\n convertElement(child, context, depth + 1);\n }\n }\n return containers.map((container, index) =>\n index > 0 ? { ...container, separator: true } : container,\n );\n }\n case \"ListViewItem\":\n return [convertListViewItem(element, context, depth)];\n case \"Table\":\n return [convertTable(props, context)];\n case \"Alert\": {\n const tone = props[\"tone\"];\n const style =\n typeof tone === \"string\"\n ? (ALERT_STYLE_MAP[tone] ?? \"default\")\n : \"default\";\n const titleText = asString(props[\"title\"]);\n const description = asString(props[\"description\"]);\n const items: TeamsCardElement[] = [];\n if (titleText) items.push(textBlock(titleText, { weight: \"bolder\" }));\n if (description) items.push(textBlock(description));\n return [{ type: \"Container\", style, items }];\n }\n case \"Carousel\": {\n warn(\n context,\n \"fallback\",\n \"Carousel\",\n \"A carousel was rendered as sequential cards because it is not at the root.\",\n );\n const cards = normalizedList(element.children).filter(\n (child): child is NormalizedUIElement =>\n isElement(child) && child.type === \"Card\",\n );\n return cards.flatMap((card) => convertElement(card, context, depth + 1));\n }\n case \"Chart\":\n warn(\n context,\n \"dropped\",\n \"Chart\",\n \"Chart was replaced by a Teams omission note.\",\n );\n return [\n textBlock(\"Chart omitted on Teams.\", { isSubtle: true, size: \"small\" }),\n ];\n default:\n warn(\n context,\n \"dropped\",\n element.type,\n \"Unknown component type was dropped.\",\n );\n return [];\n }\n}\n\n/**\n * Walks a normalized sequence into card body elements. Nested arrays are\n * flattened into one flat sibling sequence first (via {@link normalizedList}),\n * so a `Divider`/`Fact`/`Button` run merges correctly even when the model\n * wrapped some of its siblings in their own array. Consecutive `Fact`\n * siblings merge into one FactSet and consecutive `Button` siblings merge\n * into one ActionSet; a `Divider`/`Spacer` emits nothing itself but sets\n * `separator`/`spacing` on the next emitted sibling (a trailing or orphan\n * one is dropped silently, since there is no sibling left to carry it).\n * `depth` advances by exactly one per element-nesting level: this call does\n * not itself add a level, since flattening a sibling array or converting a\n * sibling element is not a descent; only a container's own recursive\n * `convertSequence(children, depth + 1)` call is.\n */\nexport function convertSequence(\n node: NormalizedUINode | undefined,\n context: ConversionContext,\n depth: number,\n): TeamsCardElement[] {\n if (node === undefined || node === null || depth > MAX_TRAVERSAL_DEPTH) {\n return [];\n }\n const nodes = normalizedList(node);\n const items: TeamsCardElement[] = [];\n let pendingSeparator = false;\n let pendingSpacing = false;\n\n const emit = (converted: TeamsCardElement[]) => {\n const [first, ...rest] = converted;\n if (first === undefined) return;\n items.push(applyPending(first, pendingSeparator, pendingSpacing), ...rest);\n pendingSeparator = false;\n pendingSpacing = false;\n };\n\n for (let index = 0; index < nodes.length;) {\n const current = nodes[index];\n if (current === undefined || current === null) {\n index += 1;\n continue;\n }\n if (isElement(current) && current.type === \"Divider\") {\n pendingSeparator = true;\n index += 1;\n continue;\n }\n if (isElement(current) && current.type === \"Spacer\") {\n pendingSpacing = true;\n index += 1;\n continue;\n }\n if (isElement(current) && current.type === \"Fact\") {\n const facts: NormalizedUIElement[] = [];\n while (index < nodes.length) {\n const candidate = nodes[index];\n if (!candidate || !isElement(candidate) || candidate.type !== \"Fact\") {\n break;\n }\n facts.push(candidate);\n index += 1;\n }\n emit([convertFacts(facts)]);\n continue;\n }\n if (isElement(current) && current.type === \"Button\") {\n const buttons: NormalizedUIElement[] = [];\n while (index < nodes.length) {\n const candidate = nodes[index];\n if (\n !candidate ||\n !isElement(candidate) ||\n candidate.type !== \"Button\"\n ) {\n break;\n }\n buttons.push(candidate);\n index += 1;\n }\n emit([convertButtons(buttons, context)]);\n continue;\n }\n if (typeof current === \"string\" || typeof current === \"number\") {\n emit([textBlock(String(current))]);\n } else {\n emit(convertElement(current as NormalizedUIElement, context, depth));\n }\n index += 1;\n }\n return items;\n}\n\n/** Builds a full card (schema envelope plus body) from an already-normalized root, checking the soft payload budget. */\nexport function convertRootToCard(\n root: NormalizedUINode | readonly NormalizedUINode[],\n context: ConversionContext,\n): TeamsAdaptiveCard {\n context.usedInputIds = new Set();\n const body = convertSequence(root, context, 0);\n const card = buildCard(body);\n const size = utf8ByteLength(JSON.stringify(card));\n if (size > PAYLOAD_SOFT_CAP) {\n warn(\n context,\n \"clamped\",\n \"Root\",\n `the card is ${size} bytes, exceeding Teams' 100 KB bot message limit.`,\n );\n }\n return card;\n}\n\n/**\n * Converts a generative-ui tree into a Microsoft Teams Adaptive Card and\n * non-fatal downgrade warnings. Sizes, weights, and colors map to Adaptive\n * Card's semantic enums rather than raw values. An Input/Select/RadioGroup/\n * Checkbox/DatePicker whose id would be the reserved {@link RESERVED_INPUT_ID}\n * is renamed with a warning (see `decodeSubmitData`). Never throws: an\n * unknown `$type` is skipped with a \"dropped\" warning, and a malformed input\n * resolves to an empty card plus a \"dropped\" warning instead of throwing.\n */\nexport function toAdaptiveCard(\n node: unknown,\n _options?: ToAdaptiveCardOptions,\n): AdaptiveCardResult {\n const context: ConversionContext = { warnings: [], usedInputIds: new Set() };\n try {\n const bounded = boundSpec(node, (reason) =>\n warn(context, \"clamped\", \"Root\", clampReasonDetail(reason)),\n );\n const { root } = normalizeSpec(bounded as never);\n return {\n card: convertRootToCard(root, context),\n warnings: context.warnings,\n };\n } catch {\n return {\n card: buildCard([]),\n warnings: [\n {\n code: \"dropped\",\n component: \"Root\",\n detail: \"Input could not be converted.\",\n },\n ],\n };\n }\n}\n"],"mappings":";;;;AA2CA,MAAM,YAAY,UAChB,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAErE,MAAM,aAAa,SACjB,SAAS,IAAI;AAEf,MAAM,YAAY,UAChB,OAAO,UAAU,WAAW,QAAQ;AAEtC,MAAM,eAAe;AAErB,MAAM,gCAAgB,IAAI,IAAI;CAC5B;CACA;CACA;CACA;CACA;AACF,CAAC;AACD,MAAM,iBAAiB,UACrB,OAAO,UAAU,YAAY,cAAc,IAAI,KAAK;AAEtD,MAAM,iCAAiB,IAAI,IAAI;CAAC;CAAU;CAAY;AAAM,CAAC;AAC7D,MAAM,kBAAkB,WACtB,OAAO,WAAW,YAAY,eAAe,IAAI,MAAM;AAEzD,MAAM,gBAA+C;CACnD,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,OAAO;CACP,OAAO;AACT;AAEA,MAAM,QACJ,SACA,MACA,WACA,WACG;CACH,QAAQ,SAAS,KAAK;EAAE;EAAM;EAAW;CAAO,CAAC;AACnD;;;;;;;;AASA,MAAM,oBAAoB;AAE1B,SAAS,eACP,IACA,WACA,SACQ;CACR,MAAM,WAAW,OAAO;CACxB,MAAM,OAAO,WAAW,GAAG,kBAAkB,KAAK;CAClD,IAAI,YAAY;CAChB,IAAI,IAAI;CACR,OAAO,QAAQ,aAAa,IAAI,SAAS,GAAG;EAC1C,YAAY,GAAG,KAAK,GAAG;EACvB,KAAK;CACP;CACA,IAAI,UACF,KACE,SACA,WACA,WACA,iBAAiB,kBAAkB,yEAAyE,UAAU,GACxH;MACK,IAAI,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kB,MAAM,CAAC,CAEvB,CAAU;EAC/C,OAAO;GACL,MAAM,kBAAkB,MAAM,OAAO;GACrC,UAAU,QAAQ;EACpB;CACF,QAAQ;EACN,OAAO;GACL,MAAM,UAAU,CAAC,CAAC;GAClB,UAAU,CACR;IACE,MAAM;IACN,WAAW;IACX,QAAQ;GACV,CACF;EACF;CACF;AACF"}
1
+ {"version":3,"file":"toAdaptiveCard.js","names":[],"sources":["../../src/teams/toAdaptiveCard.ts"],"sourcesContent":["import {\n normalizeSpec,\n type NormalizedUIElement,\n type NormalizedUINode,\n} from \"../ir\";\nimport { boundSpec } from \"./boundSpec\";\nimport {\n CHOICE_OPTION_CAP,\n MAX_TRAVERSAL_DEPTH,\n PAYLOAD_SOFT_CAP,\n PRIMARY_ACTION_CAP,\n TABLE_COLUMN_CAP,\n TABLE_ROW_CAP,\n buildCard,\n buildSubmitAction,\n clampReasonDetail,\n utf8ByteLength,\n} from \"./constants\";\nimport type {\n AdaptiveCardResult,\n TeamsActionSet,\n TeamsAdaptiveCard,\n TeamsCardElement,\n TeamsColumn,\n TeamsContainer,\n TeamsContainerStyle,\n TeamsConversionWarning,\n TeamsFact,\n TeamsInputChoice,\n TeamsTable,\n TeamsTableColumnDefinition,\n TeamsTableRow,\n TeamsTextBlock,\n TeamsTextSize,\n ToAdaptiveCardOptions,\n} from \"./types\";\n\n/** Shared mutable conversion state threaded through one top-level conversion. */\nexport interface ConversionContext {\n readonly warnings: TeamsConversionWarning[];\n usedInputIds: Set<string>;\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst isElement = (node: NormalizedUINode): node is NormalizedUIElement =>\n isRecord(node);\n\nconst asString = (value: unknown): string =>\n typeof value === \"string\" ? value : \"\";\n\nconst DATE_PATTERN = /^\\d{4}-\\d{2}-\\d{2}$/;\n\nconst SUBTLE_COLORS = new Set([\n \"secondary\",\n \"alpha-70\",\n \"white\",\n \"white-70\",\n \"white-50\",\n]);\nconst isSubtleColor = (color: unknown): boolean =>\n typeof color === \"string\" && SUBTLE_COLORS.has(color);\n\nconst BOLDER_WEIGHTS = new Set([\"medium\", \"semibold\", \"bold\"]);\nconst isBolderWeight = (weight: unknown): boolean =>\n typeof weight === \"string\" && BOLDER_WEIGHTS.has(weight);\n\nconst TEXT_SIZE_MAP: Record<string, TeamsTextSize> = {\n sm: \"small\",\n lg: \"medium\",\n xl: \"large\",\n \"2xl\": \"extraLarge\",\n \"3xl\": \"extraLarge\",\n};\n\nconst warn = (\n context: ConversionContext,\n code: TeamsConversionWarning[\"code\"],\n component: string,\n detail: string,\n) => {\n context.warnings.push({ code, component, detail });\n};\n\n/**\n * The `aui` key is reserved for the submit envelope (see\n * {@link buildSubmitData} and `decodeSubmitData`): Adaptive Cards merge\n * every input's current value into the same submit object keyed by its\n * `id`, so an input id of `aui` would clobber the envelope. Renamed to an\n * unused id derived from `aui_` instead of being emitted as-is.\n */\nconst RESERVED_INPUT_ID = \"aui\";\n\nfunction reservedSafeId(\n id: string,\n component: string,\n context: ConversionContext,\n): string {\n const reserved = id === RESERVED_INPUT_ID;\n const base = reserved ? `${RESERVED_INPUT_ID}_` : id;\n let candidate = base;\n let n = 2;\n while (context.usedInputIds.has(candidate)) {\n candidate = `${base}_${n}`;\n n += 1;\n }\n if (reserved) {\n warn(\n context,\n \"fallback\",\n component,\n `the input id \"${RESERVED_INPUT_ID}\" collides with the submit envelope's reserved key and was renamed to \"${candidate}\".`,\n );\n } else if (candidate !== base) {\n warn(\n context,\n \"fallback\",\n component,\n `the input id \"${base}\" was already used on this card and was renamed to \"${candidate}\".`,\n );\n }\n context.usedInputIds.add(candidate);\n return candidate;\n}\n\n/**\n * The shared bounded-iteration primitive: slices `value` to `cap` entries\n * without ever reading past that many indices, so a hostile array (sparse or\n * proxied with a fabricated `length`) cannot stall the event loop.\n */\nconst clampArray = (\n value: unknown,\n cap: number,\n): { readonly items: unknown[]; readonly truncated: boolean } => {\n if (!Array.isArray(value)) return { items: [], truncated: false };\n return { items: value.slice(0, cap), truncated: value.length > cap };\n};\n\nconst normalizedList = (\n node: NormalizedUINode | undefined,\n): NormalizedUINode[] => {\n if (node === undefined || node === null) return [];\n if (!Array.isArray(node)) return [node];\n return node.flatMap((child) => normalizedList(child));\n};\n\nfunction textBlock(\n text: string,\n extra?: Partial<Omit<TeamsTextBlock, \"type\" | \"text\" | \"wrap\">>,\n): TeamsTextBlock {\n return { type: \"TextBlock\", text, wrap: true, ...extra };\n}\n\nfunction applyPending(\n element: TeamsCardElement,\n separator: boolean,\n spacing: boolean,\n): TeamsCardElement {\n if (!separator && !spacing) return element;\n return {\n ...element,\n ...(separator ? { separator: true as const } : {}),\n ...(spacing ? { spacing: \"large\" as const } : {}),\n };\n}\n\nconst toChoice = (option: unknown): TeamsInputChoice | undefined => {\n if (!isRecord(option) || typeof option[\"value\"] !== \"string\") {\n return undefined;\n }\n return { title: asString(option[\"label\"]), value: option[\"value\"] };\n};\n\nconst choicesFrom = (\n optionsProp: unknown,\n component: string,\n context: ConversionContext,\n): TeamsInputChoice[] => {\n const { items, truncated } = clampArray(optionsProp, CHOICE_OPTION_CAP);\n if (truncated) {\n warn(\n context,\n \"clamped\",\n component,\n `options were clamped to ${CHOICE_OPTION_CAP} entries.`,\n );\n }\n const choices: TeamsInputChoice[] = [];\n for (const item of items) {\n const choice = toChoice(item);\n if (choice !== undefined) choices.push(choice);\n }\n const dropped = items.length - choices.length;\n if (dropped > 0) {\n warn(\n context,\n \"dropped\",\n component,\n `${dropped} ${dropped === 1 ? \"option was\" : \"options were\"} dropped for want of a string value.`,\n );\n }\n return choices;\n};\n\nfunction convertFacts(facts: readonly NormalizedUIElement[]): TeamsCardElement {\n const set: TeamsFact[] = facts.map((fact) => ({\n title: asString(fact.props[\"label\"]),\n value: asString(fact.props[\"value\"]),\n }));\n return { type: \"FactSet\", facts: set };\n}\n\n// Action.Submit has no visual style concept, so a Button's `buttonStyle`\n// (positive/destructive or otherwise) has nothing to map onto and is dropped.\nfunction convertButtons(\n buttons: readonly NormalizedUIElement[],\n context: ConversionContext,\n): TeamsActionSet {\n if (buttons.length > PRIMARY_ACTION_CAP) {\n warn(\n context,\n \"fallback\",\n \"Button\",\n `actions beyond ${PRIMARY_ACTION_CAP} were set to secondary mode.`,\n );\n }\n const actions = buttons.map((button, index) =>\n buildSubmitAction(\n asString(button.props[\"label\"]),\n button.action,\n index >= PRIMARY_ACTION_CAP ? \"secondary\" : undefined,\n ),\n );\n return { type: \"ActionSet\", actions };\n}\n\nfunction withCompanionSubmit(\n element: NormalizedUIElement,\n input: TeamsCardElement,\n context: ConversionContext,\n): TeamsCardElement[] {\n if (element.action === undefined) return [input];\n warn(\n context,\n \"fallback\",\n element.type,\n \"Teams inputs cannot dispatch on change; a companion submit action was appended.\",\n );\n return [\n input,\n {\n type: \"ActionSet\",\n actions: [buildSubmitAction(\"Submit\", element.action)],\n },\n ];\n}\n\nfunction cardFooterActionSet(\n props: Readonly<Record<string, unknown>>,\n): TeamsActionSet | undefined {\n const actions = ([\"confirm\", \"cancel\"] as const)\n .map((key) => props[key])\n .filter(isRecord)\n .map((footer) =>\n buildSubmitAction(asString(footer[\"label\"]), footer[\"$action\"]),\n );\n return actions.length > 0 ? { type: \"ActionSet\", actions } : undefined;\n}\n\nconst ALERT_STYLE_MAP: Record<string, TeamsContainerStyle> = {\n info: \"accent\",\n success: \"good\",\n warning: \"warning\",\n danger: \"attention\",\n};\n\nconst stringifyCell = (value: unknown): string => {\n if (typeof value === \"string\") return value;\n if (typeof value === \"number\" || typeof value === \"boolean\")\n return String(value);\n return \"\";\n};\n\nfunction convertTable(\n props: Readonly<Record<string, unknown>>,\n context: ConversionContext,\n): TeamsTable {\n const { items: rawColumns, truncated: columnsTruncated } = clampArray(\n props[\"columns\"],\n TABLE_COLUMN_CAP,\n );\n const { items: rawRows, truncated: rowsTruncated } = clampArray(\n props[\"rows\"],\n TABLE_ROW_CAP,\n );\n if (columnsTruncated) {\n warn(\n context,\n \"clamped\",\n \"Table\",\n `columns were clamped to ${TABLE_COLUMN_CAP} entries.`,\n );\n }\n if (rowsTruncated) {\n warn(\n context,\n \"clamped\",\n \"Table\",\n `rows were clamped to ${TABLE_ROW_CAP} entries.`,\n );\n }\n\n const unlabeled = rawColumns.filter(\n (column) => !isRecord(column) || typeof column[\"label\"] !== \"string\",\n ).length;\n if (unlabeled > 0) {\n warn(\n context,\n \"dropped\",\n \"Table\",\n `${unlabeled} column ${unlabeled === 1 ? \"header was\" : \"headers were\"} left blank for want of a string label.`,\n );\n }\n const hasColumns = rawColumns.length > 0;\n const columns: TeamsTableColumnDefinition[] = rawColumns.map(() => ({\n width: 1 as const,\n }));\n const headerRow: TeamsTableRow | undefined = hasColumns\n ? {\n type: \"TableRow\",\n cells: rawColumns.map((column) => ({\n type: \"TableCell\" as const,\n items: [textBlock(isRecord(column) ? asString(column[\"label\"]) : \"\")],\n })),\n }\n : undefined;\n const dataRows: TeamsTableRow[] = rawRows.map((row) => ({\n type: \"TableRow\",\n cells: (Array.isArray(row) ? row.slice(0, TABLE_COLUMN_CAP) : []).map(\n (cell) => ({\n type: \"TableCell\" as const,\n items: [textBlock(stringifyCell(cell))],\n }),\n ),\n }));\n\n return {\n type: \"Table\",\n firstRowAsHeaders: hasColumns,\n columns,\n rows: headerRow !== undefined ? [headerRow, ...dataRows] : dataRows,\n };\n}\n\nfunction convertListViewItem(\n element: NormalizedUIElement,\n context: ConversionContext,\n depth: number,\n): TeamsContainer {\n const items = convertSequence(element.children, context, depth + 1);\n const selectAction = isRecord(element.action)\n ? buildSubmitAction(\"Open\", element.action)\n : undefined;\n return {\n type: \"Container\",\n items,\n ...(selectAction !== undefined ? { selectAction } : {}),\n };\n}\n\n/**\n * Converts a child whose output is thrown away, and reports whether anything\n * was lost with it. A scratch context keeps the ids it claims out of the card,\n * where they would rename a control that survives; only its `dropped` warnings\n * are forwarded, because those describe the tree the caller wrote, while a\n * clamp or a rename would describe content never delivered.\n */\nexport const discardedChild = (\n child: NormalizedUINode,\n context: ConversionContext,\n depth: number,\n): boolean => {\n const scratch: ConversionContext = {\n ...context,\n warnings: [],\n usedInputIds: new Set(context.usedInputIds),\n };\n const produced = convertSequence(child, scratch, depth).length > 0;\n const lost = scratch.warnings.filter((warning) => warning.code === \"dropped\");\n context.warnings.push(...lost);\n return produced || lost.length > 0;\n};\n\nexport function convertElement(\n element: NormalizedUIElement,\n context: ConversionContext,\n depth: number,\n): TeamsCardElement[] {\n const { props } = element;\n switch (element.type) {\n case \"Header\":\n return [\n textBlock(asString(props[\"text\"]), {\n size: \"large\",\n weight: \"bolder\",\n style: \"heading\",\n }),\n ];\n case \"Text\": {\n const mappedSize =\n typeof props[\"size\"] === \"string\"\n ? TEXT_SIZE_MAP[props[\"size\"]]\n : undefined;\n return [\n textBlock(asString(props[\"value\"]), {\n ...(mappedSize !== undefined ? { size: mappedSize } : {}),\n ...(isBolderWeight(props[\"weight\"]) ? { weight: \"bolder\" } : {}),\n ...(isSubtleColor(props[\"color\"]) ? { isSubtle: true } : {}),\n }),\n ];\n }\n case \"Caption\":\n return [\n textBlock(asString(props[\"value\"]), { size: \"small\", isSubtle: true }),\n ];\n case \"Badge\":\n return [\n textBlock(asString(props[\"value\"]), { size: \"small\", isSubtle: true }),\n ];\n case \"Markdown\":\n // Teams renders a strict subset of markdown (no headings, tables, images,\n // preformatted blocks, or blockquotes); unsupported syntax renders literally.\n return [textBlock(asString(props[\"value\"]))];\n case \"Fact\":\n return [convertFacts([element])];\n case \"Image\": {\n const size = props[\"size\"];\n let mappedSize: \"small\" | \"medium\" | \"large\" | undefined;\n if (size === \"sm\") mappedSize = \"small\";\n else if (size === \"md\") mappedSize = \"medium\";\n else if (size === \"lg\") mappedSize = \"large\";\n else if (typeof size === \"number\") {\n warn(context, \"dropped\", \"Image\", \"A numeric size was dropped.\");\n }\n return [\n {\n type: \"Image\",\n url: asString(props[\"src\"]),\n altText: asString(props[\"alt\"]),\n ...(mappedSize !== undefined ? { size: mappedSize } : {}),\n },\n ];\n }\n case \"Divider\":\n case \"Spacer\":\n case \"Icon\":\n return [];\n case \"Button\":\n return [convertButtons([element], context)];\n case \"Select\": {\n const name = asString(props[\"name\"]);\n const placeholder = asString(props[\"placeholder\"]);\n const label = asString(props[\"label\"]);\n const input: TeamsCardElement = {\n type: \"Input.ChoiceSet\",\n id: reservedSafeId(name || \"select\", \"Select\", context),\n style: \"compact\",\n choices: choicesFrom(props[\"options\"], \"Select\", context),\n ...(placeholder ? { placeholder } : {}),\n ...(label ? { label } : {}),\n };\n return withCompanionSubmit(element, input, context);\n }\n case \"RadioGroup\": {\n const name = asString(props[\"name\"]);\n const label = asString(props[\"label\"]);\n const defaultValue = props[\"defaultValue\"];\n const input: TeamsCardElement = {\n type: \"Input.ChoiceSet\",\n id: reservedSafeId(name || \"radiogroup\", \"RadioGroup\", context),\n style: \"expanded\",\n choices: choicesFrom(props[\"options\"], \"RadioGroup\", context),\n ...(typeof defaultValue === \"string\" && defaultValue\n ? { value: defaultValue }\n : {}),\n ...(label ? { label } : {}),\n };\n return withCompanionSubmit(element, input, context);\n }\n case \"Checkbox\": {\n const name = asString(props[\"name\"]);\n const label = asString(props[\"label\"]);\n const input: TeamsCardElement = {\n type: \"Input.Toggle\",\n id: reservedSafeId(name || label || \"checkbox\", \"Checkbox\", context),\n title: label,\n value: props[\"defaultChecked\"] === true ? \"true\" : \"false\",\n valueOn: \"true\",\n valueOff: \"false\",\n };\n return withCompanionSubmit(element, input, context);\n }\n case \"Input\": {\n const name = asString(props[\"name\"]);\n const label = asString(props[\"label\"]);\n const placeholder = asString(props[\"placeholder\"]);\n const input: TeamsCardElement = {\n type: \"Input.Text\",\n id: reservedSafeId(name || \"input\", \"Input\", context),\n ...(label ? { label } : {}),\n ...(placeholder ? { placeholder } : {}),\n ...(props[\"multiline\"] === true ? { isMultiline: true } : {}),\n };\n return withCompanionSubmit(element, input, context);\n }\n case \"DatePicker\": {\n const name = asString(props[\"name\"]);\n const label = asString(props[\"label\"]);\n const rawValue = props[\"value\"];\n const value =\n typeof rawValue === \"string\" && DATE_PATTERN.test(rawValue)\n ? rawValue\n : undefined;\n const rawMin = props[\"min\"];\n const min =\n typeof rawMin === \"string\" && DATE_PATTERN.test(rawMin)\n ? rawMin\n : undefined;\n const rawMax = props[\"max\"];\n const max =\n typeof rawMax === \"string\" && DATE_PATTERN.test(rawMax)\n ? rawMax\n : undefined;\n const input: TeamsCardElement = {\n type: \"Input.Date\",\n id: reservedSafeId(name || \"datepicker\", \"DatePicker\", context),\n ...(label ? { label } : {}),\n ...(value !== undefined ? { value } : {}),\n ...(min !== undefined ? { min } : {}),\n ...(max !== undefined ? { max } : {}),\n };\n return withCompanionSubmit(element, input, context);\n }\n case \"Form\":\n return [\n ...convertSequence(element.children, context, depth + 1),\n {\n type: \"ActionSet\",\n actions: [buildSubmitAction(\"Submit\", element.action)],\n },\n ];\n case \"Card\": {\n const titleText = asString(props[\"title\"]);\n const items: TeamsCardElement[] = [];\n if (titleText) {\n items.push(\n textBlock(titleText, {\n size: \"large\",\n weight: \"bolder\",\n style: \"heading\",\n }),\n );\n }\n items.push(...convertSequence(element.children, context, depth + 1));\n const container: TeamsContainer = {\n type: \"Container\",\n style: \"default\",\n items,\n };\n const actionSet = cardFooterActionSet(props);\n return actionSet !== undefined ? [container, actionSet] : [container];\n }\n case \"Col\":\n case \"Box\":\n return [\n {\n type: \"Container\",\n items: convertSequence(element.children, context, depth + 1),\n },\n ];\n case \"Row\": {\n const children = normalizedList(element.children);\n if (children.length > 3) {\n warn(context, \"advisory\", \"Row\", \"Teams recommends at most 3 columns.\");\n }\n const columns: TeamsColumn[] = children.map((child) => ({\n type: \"Column\",\n width: \"auto\",\n items: convertSequence(child, context, depth + 1),\n }));\n return [{ type: \"ColumnSet\", columns }];\n }\n case \"ListView\": {\n const containers: TeamsContainer[] = [];\n let discarded = 0;\n for (const child of normalizedList(element.children)) {\n if (isElement(child) && child.type === \"ListViewItem\") {\n containers.push(convertListViewItem(child, context, depth + 1));\n continue;\n }\n if (discardedChild(child, context, depth + 1)) discarded += 1;\n }\n if (discarded > 0) {\n warn(\n context,\n \"dropped\",\n \"ListView\",\n `${discarded} non-item ${discarded === 1 ? \"child was\" : \"children were\"} dropped.`,\n );\n }\n return containers.map((container, index) =>\n index > 0 ? { ...container, separator: true } : container,\n );\n }\n case \"ListViewItem\":\n return [convertListViewItem(element, context, depth)];\n case \"Table\":\n return [convertTable(props, context)];\n case \"Alert\": {\n const tone = props[\"tone\"];\n const style =\n typeof tone === \"string\"\n ? (ALERT_STYLE_MAP[tone] ?? \"default\")\n : \"default\";\n const titleText = asString(props[\"title\"]);\n const description = asString(props[\"description\"]);\n const items: TeamsCardElement[] = [];\n if (titleText) items.push(textBlock(titleText, { weight: \"bolder\" }));\n if (description) items.push(textBlock(description));\n return [{ type: \"Container\", style, items }];\n }\n case \"Carousel\": {\n warn(\n context,\n \"fallback\",\n \"Carousel\",\n \"A carousel was rendered as sequential cards because it is not at the root.\",\n );\n const cards: NormalizedUIElement[] = [];\n let droppedCards = 0;\n for (const child of normalizedList(element.children)) {\n if (isElement(child) && child.type === \"Card\") {\n cards.push(child);\n continue;\n }\n if (discardedChild(child, context, depth + 1)) droppedCards += 1;\n }\n if (droppedCards > 0) {\n warn(\n context,\n \"dropped\",\n \"Carousel\",\n `${droppedCards} non-card ${droppedCards === 1 ? \"child was\" : \"children were\"} dropped.`,\n );\n }\n return cards.flatMap((card) => convertElement(card, context, depth + 1));\n }\n case \"Chart\":\n warn(\n context,\n \"dropped\",\n \"Chart\",\n \"Chart was replaced by a Teams omission note.\",\n );\n return [\n textBlock(\"Chart omitted on Teams.\", { isSubtle: true, size: \"small\" }),\n ];\n default:\n warn(\n context,\n \"dropped\",\n element.type,\n \"Unknown component type was dropped.\",\n );\n return [];\n }\n}\n\n/**\n * Walks a normalized sequence into card body elements. Nested arrays are\n * flattened into one flat sibling sequence first (via {@link normalizedList}),\n * so a `Divider`/`Fact`/`Button` run merges correctly even when the model\n * wrapped some of its siblings in their own array. Consecutive `Fact`\n * siblings merge into one FactSet and consecutive `Button` siblings merge\n * into one ActionSet; a `Divider`/`Spacer` emits nothing itself but sets\n * `separator`/`spacing` on the next emitted sibling (a trailing or orphan\n * one is dropped silently, since there is no sibling left to carry it).\n * `depth` advances by exactly one per element-nesting level: this call does\n * not itself add a level, since flattening a sibling array or converting a\n * sibling element is not a descent; only a container's own recursive\n * `convertSequence(children, depth + 1)` call is.\n */\nexport function convertSequence(\n node: NormalizedUINode | undefined,\n context: ConversionContext,\n depth: number,\n): TeamsCardElement[] {\n if (node === undefined || node === null || depth > MAX_TRAVERSAL_DEPTH) {\n return [];\n }\n const nodes = normalizedList(node);\n const items: TeamsCardElement[] = [];\n let pendingSeparator = false;\n let pendingSpacing = false;\n\n const emit = (converted: TeamsCardElement[]) => {\n const [first, ...rest] = converted;\n if (first === undefined) return;\n items.push(applyPending(first, pendingSeparator, pendingSpacing), ...rest);\n pendingSeparator = false;\n pendingSpacing = false;\n };\n\n for (let index = 0; index < nodes.length;) {\n const current = nodes[index];\n if (current === undefined || current === null) {\n index += 1;\n continue;\n }\n if (isElement(current) && current.type === \"Divider\") {\n pendingSeparator = true;\n index += 1;\n continue;\n }\n if (isElement(current) && current.type === \"Spacer\") {\n pendingSpacing = true;\n index += 1;\n continue;\n }\n if (isElement(current) && current.type === \"Fact\") {\n const facts: NormalizedUIElement[] = [];\n while (index < nodes.length) {\n const candidate = nodes[index];\n if (!candidate || !isElement(candidate) || candidate.type !== \"Fact\") {\n break;\n }\n facts.push(candidate);\n index += 1;\n }\n emit([convertFacts(facts)]);\n continue;\n }\n if (isElement(current) && current.type === \"Button\") {\n const buttons: NormalizedUIElement[] = [];\n while (index < nodes.length) {\n const candidate = nodes[index];\n if (\n !candidate ||\n !isElement(candidate) ||\n candidate.type !== \"Button\"\n ) {\n break;\n }\n buttons.push(candidate);\n index += 1;\n }\n emit([convertButtons(buttons, context)]);\n continue;\n }\n if (typeof current === \"string\" || typeof current === \"number\") {\n emit([textBlock(String(current))]);\n } else {\n emit(convertElement(current as NormalizedUIElement, context, depth));\n }\n index += 1;\n }\n return items;\n}\n\n/** Builds a full card (schema envelope plus body) from an already-normalized root, checking the soft payload budget. */\nexport function convertRootToCard(\n root: NormalizedUINode | readonly NormalizedUINode[],\n context: ConversionContext,\n): TeamsAdaptiveCard {\n context.usedInputIds = new Set();\n const body = convertSequence(root, context, 0);\n const card = buildCard(body);\n const size = utf8ByteLength(JSON.stringify(card));\n if (size > PAYLOAD_SOFT_CAP) {\n warn(\n context,\n \"advisory\",\n \"Root\",\n `the card is ${size} bytes, over the ${PAYLOAD_SOFT_CAP}-byte soft budget kept below Teams' 100 KB bot message limit.`,\n );\n }\n return card;\n}\n\n/**\n * Converts a generative-ui tree into a Microsoft Teams Adaptive Card and\n * non-fatal conversion warnings. Sizes, weights, and colors map to Adaptive\n * Card's semantic enums rather than raw values. An Input/Select/RadioGroup/\n * Checkbox/DatePicker whose id would be the reserved {@link RESERVED_INPUT_ID}\n * is renamed with a warning (see `decodeSubmitData`). Never throws: an\n * unknown `$type` is skipped with a \"dropped\" warning, and a malformed input\n * resolves to an empty card plus a \"dropped\" warning instead of throwing.\n */\nexport function toAdaptiveCard(\n node: unknown,\n _options?: ToAdaptiveCardOptions,\n): AdaptiveCardResult {\n const context: ConversionContext = { warnings: [], usedInputIds: new Set() };\n try {\n const bounded = boundSpec(node, (reason) =>\n warn(context, \"clamped\", \"Root\", clampReasonDetail(reason)),\n );\n const { root } = normalizeSpec(bounded as never);\n return {\n card: convertRootToCard(root, context),\n warnings: context.warnings,\n };\n } catch {\n return {\n card: buildCard([]),\n warnings: [\n {\n code: \"dropped\",\n component: \"Root\",\n detail: \"Input could not be converted.\",\n },\n ],\n };\n }\n}\n"],"mappings":";;;;AA2CA,MAAM,YAAY,UAChB,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAErE,MAAM,aAAa,SACjB,SAAS,IAAI;AAEf,MAAM,YAA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C,CAAC;GACvC;EACF;EACA,IAAI,OAAO,YAAY,YAAY,OAAO,YAAY,UACpD,KAAK,CAAC,UAAU,OAAO,OAAO,CAAC,CAAC,CAAC;OAEjC,KAAK,eAAe,SAAgC,SAAS,KAAK,CAAC;EAErE,SAAS;CACX;CACA,OAAO;AACT;;AAGA,SAAgB,kBACd,MACA,SACmB;CACnB,QAAQ,+BAAe,IAAI,IAAI;CAC/B,MAAM,OAAO,gBAAgB,MAAM,SAAS,CAAC;CAC7C,MAAM,OAAO,UAAU,IAAI;CAC3B,MAAM,OAAO,eAAe,KAAK,UAAU,IAAI,CAAC;CAChD,IAAI,OAAA,KACF,KACE,SACA,YACA,QACA,eAAe,KAAK,mBAAmB,iBAAiB,8DAC1D;CAEF,OAAO;AACT;;;;;;;;;;AAWA,SAAgB,eACd,MACA,UACoB;CACpB,MAAM,UAA6B;EAAE,UAAU,CAAC;EAAG,8BAAc,IAAI,IAAI;CAAE;CAC3E,IAAI;EACF,MAAM,UAAU,UAAU,OAAO,WAC/B,KAAK,SAAS,WAAW,QAAQ,kBAAkB,MAAM,CAAC,CAC5D;EACA,MAAM,EAAE,SAAS,cAAc,OAAgB;EAC/C,OAAO;GACL,MAAM,kBAAkB,MAAM,OAAO;GACrC,UAAU,QAAQ;EACpB;CACF,QAAQ;EACN,OAAO;GACL,MAAM,UAAU,CAAC,CAAC;GAClB,UAAU,CACR;IACE,MAAM;IACN,WAAW;IACX,QAAQ;GACV,CACF;EACF;CACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"toTeamsAttachments.d.ts","names":[],"sources":["../../src/teams/toTeamsAttachments.ts"],"mappings":";;;;;;;;;iBAiFgB,mBACd,eACA,WAAW,wBACV"}
1
+ {"version":3,"file":"toTeamsAttachments.d.ts","names":[],"sources":["../../src/teams/toTeamsAttachments.ts"],"mappings":";;;;;;;;;iBAuFgB,mBACd,eACA,WAAW,wBACV"}
@@ -1,7 +1,7 @@
1
1
  import { normalizeSpec } from "../ir.js";
2
- import { buildAttachment, clampReasonDetail, utf8ByteLength } from "./constants.js";
2
+ import { PAYLOAD_SOFT_CAP, buildAttachment, clampReasonDetail, utf8ByteLength } from "./constants.js";
3
3
  import { boundSpec } from "./boundSpec.js";
4
- import { convertElement, convertRootToCard } from "./toAdaptiveCard.js";
4
+ import { convertRootToCard, discardedChild } from "./toAdaptiveCard.js";
5
5
  //#region src/teams/toTeamsAttachments.ts
6
6
  const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
7
7
  const isElement = (node) => isRecord(node);
@@ -16,10 +16,9 @@ const clampArray = (value, cap) => ({
16
16
  });
17
17
  /**
18
18
  * Recognizes a root that is a single `Carousel` element, returning its `Card`
19
- * children. Every child is routed through {@link convertElement} first (its
20
- * result is discarded) so an unknown or unsupported child still produces its
21
- * usual "dropped" warning instead of being filtered out silently; non-card
22
- * children are then dropped. `undefined` means the root is not exclusively a
19
+ * children. A non-card child is routed through {@link discardedChild}, which
20
+ * reports it and forwards whatever it lost, rather than being filtered out
21
+ * silently. `undefined` means the root is not exclusively a
23
22
  * root-level carousel, so the caller falls back to converting the whole tree
24
23
  * as one card.
25
24
  */
@@ -27,11 +26,19 @@ function rootCarouselCards(root, context) {
27
26
  const element = Array.isArray(root) && root.length === 1 ? root[0] : root;
28
27
  if (!isElement(element) || element.type !== "Carousel") return void 0;
29
28
  const cards = [];
29
+ let discarded = 0;
30
30
  for (const child of normalizedList(element.children)) {
31
- if (!isElement(child)) continue;
32
- if (child.type === "Card") cards.push(child);
33
- else convertElement(child, context, 1);
31
+ if (isElement(child) && child.type === "Card") {
32
+ cards.push(child);
33
+ continue;
34
+ }
35
+ if (discardedChild(child, context, 1)) discarded += 1;
34
36
  }
37
+ if (discarded > 0) context.warnings.push({
38
+ code: "dropped",
39
+ component: "Carousel",
40
+ detail: `${discarded} non-card ${discarded === 1 ? "child was" : "children were"} dropped.`
41
+ });
35
42
  return cards;
36
43
  }
37
44
  /**
@@ -48,11 +55,12 @@ function toTeamsAttachments(node, _options) {
48
55
  usedInputIds: /* @__PURE__ */ new Set()
49
56
  };
50
57
  try {
51
- const { root } = normalizeSpec(boundSpec(node, (reason) => warnings.push({
58
+ const bounded = boundSpec(node, (reason) => warnings.push({
52
59
  code: "clamped",
53
60
  component: "Root",
54
61
  detail: clampReasonDetail(reason)
55
- })));
62
+ }));
63
+ const { root } = normalizeSpec(bounded);
56
64
  const carouselCards = rootCarouselCards(root, context);
57
65
  if (carouselCards !== void 0) {
58
66
  const { items, truncated } = clampArray(carouselCards, 10);
@@ -64,9 +72,9 @@ function toTeamsAttachments(node, _options) {
64
72
  const attachments = items.map((child) => buildAttachment(convertRootToCard(child, context)));
65
73
  const size = utf8ByteLength(JSON.stringify(attachments));
66
74
  if (size > 8e4) warnings.push({
67
- code: "clamped",
75
+ code: "advisory",
68
76
  component: "Carousel",
69
- detail: `the carousel attachments total ${size} bytes, exceeding Teams' 100 KB bot message limit.`
77
+ detail: `the carousel attachments total ${size} bytes, over the ${PAYLOAD_SOFT_CAP}-byte soft budget kept below Teams' 100 KB bot message limit.`
70
78
  });
71
79
  return {
72
80
  attachments,
@@ -1 +1 @@
1
- {"version":3,"file":"toTeamsAttachments.js","names":[],"sources":["../../src/teams/toTeamsAttachments.ts"],"sourcesContent":["import {\n normalizeSpec,\n type NormalizedUIElement,\n type NormalizedUINode,\n} from \"../ir\";\nimport { boundSpec } from \"./boundSpec\";\nimport {\n CAROUSEL_ATTACHMENT_CAP,\n PAYLOAD_SOFT_CAP,\n buildAttachment,\n clampReasonDetail,\n utf8ByteLength,\n} from \"./constants\";\nimport {\n convertElement,\n convertRootToCard,\n type ConversionContext,\n} from \"./toAdaptiveCard\";\nimport type {\n TeamsAttachmentsResult,\n TeamsCardAttachment,\n TeamsConversionWarning,\n ToAdaptiveCardOptions,\n} from \"./types\";\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst isElement = (node: NormalizedUINode): node is NormalizedUIElement =>\n isRecord(node);\n\nconst normalizedList = (\n node: NormalizedUINode | undefined,\n): NormalizedUINode[] => {\n if (node === undefined || node === null) return [];\n if (!Array.isArray(node)) return [node];\n return node.flatMap((child) => normalizedList(child));\n};\n\nconst clampArray = <T>(\n value: readonly T[],\n cap: number,\n): { readonly items: T[]; readonly truncated: boolean } => ({\n items: value.slice(0, cap),\n truncated: value.length > cap,\n});\n\n/**\n * Recognizes a root that is a single `Carousel` element, returning its `Card`\n * children. Every child is routed through {@link convertElement} first (its\n * result is discarded) so an unknown or unsupported child still produces its\n * usual \"dropped\" warning instead of being filtered out silently; non-card\n * children are then dropped. `undefined` means the root is not exclusively a\n * root-level carousel, so the caller falls back to converting the whole tree\n * as one card.\n */\nfunction rootCarouselCards(\n root: NormalizedUINode | readonly NormalizedUINode[],\n context: ConversionContext,\n): NormalizedUIElement[] | undefined {\n const element = Array.isArray(root) && root.length === 1 ? root[0] : root;\n if (!isElement(element) || element.type !== \"Carousel\") return undefined;\n const cards: NormalizedUIElement[] = [];\n for (const child of normalizedList(element.children)) {\n if (!isElement(child)) continue;\n if (child.type === \"Card\") {\n cards.push(child);\n } else {\n convertElement(child, context, 1);\n }\n }\n return cards;\n}\n\n/**\n * Converts a generative-ui tree into Teams bot-framework message attachments.\n * A root-level `Carousel` becomes one attachment per `Card` child (clamped to\n * {@link CAROUSEL_ATTACHMENT_CAP}) with `attachmentLayout: \"carousel\"`;\n * anything else converts through {@link toAdaptiveCard}'s engine into a\n * single attachment. Never throws.\n */\nexport function toTeamsAttachments(\n node: unknown,\n _options?: ToAdaptiveCardOptions,\n): TeamsAttachmentsResult {\n const warnings: TeamsConversionWarning[] = [];\n const context: ConversionContext = { warnings, usedInputIds: new Set() };\n try {\n const bounded = boundSpec(node, (reason) =>\n warnings.push({\n code: \"clamped\",\n component: \"Root\",\n detail: clampReasonDetail(reason),\n }),\n );\n const { root } = normalizeSpec(bounded as never);\n const carouselCards = rootCarouselCards(root, context);\n if (carouselCards !== undefined) {\n const { items, truncated } = clampArray(\n carouselCards,\n CAROUSEL_ATTACHMENT_CAP,\n );\n if (truncated) {\n warnings.push({\n code: \"clamped\",\n component: \"Carousel\",\n detail: `cards were clamped to ${CAROUSEL_ATTACHMENT_CAP} entries.`,\n });\n }\n const attachments: TeamsCardAttachment[] = items.map((child) =>\n buildAttachment(convertRootToCard(child, context)),\n );\n const size = utf8ByteLength(JSON.stringify(attachments));\n if (size > PAYLOAD_SOFT_CAP) {\n warnings.push({\n code: \"clamped\",\n component: \"Carousel\",\n detail: `the carousel attachments total ${size} bytes, exceeding Teams' 100 KB bot message limit.`,\n });\n }\n return { attachments, attachmentLayout: \"carousel\", warnings };\n }\n const attachment = buildAttachment(convertRootToCard(root, context));\n return { attachments: [attachment], warnings };\n } catch {\n return {\n attachments: [],\n warnings: [\n {\n code: \"dropped\",\n component: \"Root\",\n detail: \"Input could not be converted.\",\n },\n ],\n };\n }\n}\n"],"mappings":";;;;;AAyBA,MAAM,YAAY,UAChB,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAErE,MAAM,aAAa,SACjB,SAAS,IAAI;AAEf,MAAM,kBACJ,SACuB;CACvB,IAAI,SAAS,KAAA,KAAa,SAAS,MAAM,OAAO,CAAC;CACjD,IAAI,CAAC,MAAM,QAAQ,IAAI,GAAG,OAAO,CAAC,IAAI;CACtC,OAAO,KAAK,SAAS,UAAU,eAAe,KAAK,CAAC;AACtD;AAEA,MAAM,cACJ,OACA,SAC0D;CAC1D,OAAO,MAAM,MAAM,GAAG,GAAG;CACzB,WAAW,MAAM,SAAS;AAC5B;;;;;;;;;;AAWA,SAAS,kBACP,MACA,SACmC;CACnC,MAAM,UAAU,MAAM,QAAQ,IAAI,KAAK,KAAK,WAAW,IAAI,KAAK,KAAK;CACrE,IAAI,CAAC,UAAU,OAAO,KAAK,QAAQ,SAAS,YAAY,OAAO,KAAA;CAC/D,MAAM,QAA+B,CAAC;CACtC,KAAK,MAAM,SAAS,eAAe,QAAQ,QAAQ,GAAG;EACpD,IAAI,CAAC,UAAU,KAAK,GAAG;EACvB,IAAI,MAAM,SAAS,QACjB,MAAM,KAAK,KAAK;OAEhB,eAAe,OAAO,SAAS,CAAC;CAEpC;CACA,OAAO;AACT;;;;;;;;AASA,SAAgB,mBACd,MACA,UACwB;CACxB,MAAM,WAAqC,CAAC;CAC5C,MAAM,UAA6B;EAAE;EAAU,8BAAc,IAAI,IAAI;CAAE;CACvE,IAAI;EAQF,MAAM,EAAE,SAAS,cAPD,UAAU,OAAO,WAC/B,SAAS,KAAK;GACZ,MAAM;GACN,WAAW;GACX,QAAQ,kBAAkB,MAAM;EAClC,CAAC,CAEkC,CAAU;EAC/C,MAAM,gBAAgB,kBAAkB,MAAM,OAAO;EACrD,IAAI,kBAAkB,KAAA,GAAW;GAC/B,MAAM,EAAE,OAAO,cAAc,WAC3B,eAAA,EAEF;GACA,IAAI,WACF,SAAS,KAAK;IACZ,MAAM;IACN,WAAW;IACX,QAAQ;GACV,CAAC;GAEH,MAAM,cAAqC,MAAM,KAAK,UACpD,gBAAgB,kBAAkB,OAAO,OAAO,CAAC,CACnD;GACA,MAAM,OAAO,eAAe,KAAK,UAAU,WAAW,CAAC;GACvD,IAAI,OAAA,KACF,SAAS,KAAK;IACZ,MAAM;IACN,WAAW;IACX,QAAQ,kCAAkC,KAAK;GACjD,CAAC;GAEH,OAAO;IAAE;IAAa,kBAAkB;IAAY;GAAS;EAC/D;EAEA,OAAO;GAAE,aAAa,CADH,gBAAgB,kBAAkB,MAAM,OAAO,CAClC,CAAC;GAAG;EAAS;CAC/C,QAAQ;EACN,OAAO;GACL,aAAa,CAAC;GACd,UAAU,CACR;IACE,MAAM;IACN,WAAW;IACX,QAAQ;GACV,CACF;EACF;CACF;AACF"}
1
+ {"version":3,"file":"toTeamsAttachments.js","names":[],"sources":["../../src/teams/toTeamsAttachments.ts"],"sourcesContent":["import {\n normalizeSpec,\n type NormalizedUIElement,\n type NormalizedUINode,\n} from \"../ir\";\nimport { boundSpec } from \"./boundSpec\";\nimport {\n CAROUSEL_ATTACHMENT_CAP,\n PAYLOAD_SOFT_CAP,\n buildAttachment,\n clampReasonDetail,\n utf8ByteLength,\n} from \"./constants\";\nimport {\n convertRootToCard,\n discardedChild,\n type ConversionContext,\n} from \"./toAdaptiveCard\";\nimport type {\n TeamsAttachmentsResult,\n TeamsCardAttachment,\n TeamsConversionWarning,\n ToAdaptiveCardOptions,\n} from \"./types\";\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst isElement = (node: NormalizedUINode): node is NormalizedUIElement =>\n isRecord(node);\n\nconst normalizedList = (\n node: NormalizedUINode | undefined,\n): NormalizedUINode[] => {\n if (node === undefined || node === null) return [];\n if (!Array.isArray(node)) return [node];\n return node.flatMap((child) => normalizedList(child));\n};\n\nconst clampArray = <T>(\n value: readonly T[],\n cap: number,\n): { readonly items: T[]; readonly truncated: boolean } => ({\n items: value.slice(0, cap),\n truncated: value.length > cap,\n});\n\n/**\n * Recognizes a root that is a single `Carousel` element, returning its `Card`\n * children. A non-card child is routed through {@link discardedChild}, which\n * reports it and forwards whatever it lost, rather than being filtered out\n * silently. `undefined` means the root is not exclusively a\n * root-level carousel, so the caller falls back to converting the whole tree\n * as one card.\n */\nfunction rootCarouselCards(\n root: NormalizedUINode | readonly NormalizedUINode[],\n context: ConversionContext,\n): NormalizedUIElement[] | undefined {\n const element = Array.isArray(root) && root.length === 1 ? root[0] : root;\n if (!isElement(element) || element.type !== \"Carousel\") return undefined;\n const cards: NormalizedUIElement[] = [];\n let discarded = 0;\n for (const child of normalizedList(element.children)) {\n if (isElement(child) && child.type === \"Card\") {\n cards.push(child);\n continue;\n }\n if (discardedChild(child, context, 1)) discarded += 1;\n }\n if (discarded > 0) {\n context.warnings.push({\n code: \"dropped\",\n component: \"Carousel\",\n detail: `${discarded} non-card ${discarded === 1 ? \"child was\" : \"children were\"} dropped.`,\n });\n }\n return cards;\n}\n\n/**\n * Converts a generative-ui tree into Teams bot-framework message attachments.\n * A root-level `Carousel` becomes one attachment per `Card` child (clamped to\n * {@link CAROUSEL_ATTACHMENT_CAP}) with `attachmentLayout: \"carousel\"`;\n * anything else converts through {@link toAdaptiveCard}'s engine into a\n * single attachment. Never throws.\n */\nexport function toTeamsAttachments(\n node: unknown,\n _options?: ToAdaptiveCardOptions,\n): TeamsAttachmentsResult {\n const warnings: TeamsConversionWarning[] = [];\n const context: ConversionContext = { warnings, usedInputIds: new Set() };\n try {\n const bounded = boundSpec(node, (reason) =>\n warnings.push({\n code: \"clamped\",\n component: \"Root\",\n detail: clampReasonDetail(reason),\n }),\n );\n const { root } = normalizeSpec(bounded as never);\n const carouselCards = rootCarouselCards(root, context);\n if (carouselCards !== undefined) {\n const { items, truncated } = clampArray(\n carouselCards,\n CAROUSEL_ATTACHMENT_CAP,\n );\n if (truncated) {\n warnings.push({\n code: \"clamped\",\n component: \"Carousel\",\n detail: `cards were clamped to ${CAROUSEL_ATTACHMENT_CAP} entries.`,\n });\n }\n const attachments: TeamsCardAttachment[] = items.map((child) =>\n buildAttachment(convertRootToCard(child, context)),\n );\n const size = utf8ByteLength(JSON.stringify(attachments));\n if (size > PAYLOAD_SOFT_CAP) {\n warnings.push({\n code: \"advisory\",\n component: \"Carousel\",\n detail: `the carousel attachments total ${size} bytes, over the ${PAYLOAD_SOFT_CAP}-byte soft budget kept below Teams' 100 KB bot message limit.`,\n });\n }\n return { attachments, attachmentLayout: \"carousel\", warnings };\n }\n const attachment = buildAttachment(convertRootToCard(root, context));\n return { attachments: [attachment], warnings };\n } catch {\n return {\n attachments: [],\n warnings: [\n {\n code: \"dropped\",\n component: \"Root\",\n detail: \"Input could not be converted.\",\n },\n ],\n };\n }\n}\n"],"mappings":";;;;;AAyBA,MAAM,YAAY,UAChB,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAErE,MAAM,aAAa,SACjB,SAAS,IAAI;AAEf,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cAAc,WAC3B,eAAA,EAEF;GACA,IAAI,WACF,SAAS,KAAK;IACZ,MAAM;IACN,WAAW;IACX,QAAQ;GACV,CAAC;GAEH,MAAM,cAAqC,MAAM,KAAK,UACpD,gBAAgB,kBAAkB,OAAO,OAAO,CAAC,CACnD;GACA,MAAM,OAAO,eAAe,KAAK,UAAU,WAAW,CAAC;GACvD,IAAI,OAAA,KACF,SAAS,KAAK;IACZ,MAAM;IACN,WAAW;IACX,QAAQ,kCAAkC,KAAK,mBAAmB,iBAAiB;GACrF,CAAC;GAEH,OAAO;IAAE;IAAa,kBAAkB;IAAY;GAAS;EAC/D;EAEA,OAAO;GAAE,aAAa,CADH,gBAAgB,kBAAkB,MAAM,OAAO,CAClC,CAAC;GAAG;EAAS;CAC/C,QAAQ;EACN,OAAO;GACL,aAAa,CAAC;GACd,UAAU,CACR;IACE,MAAM;IACN,WAAW;IACX,QAAQ;GACV,CACF;EACF;CACF;AACF"}
@@ -172,9 +172,18 @@ interface TeamsCardAttachment {
172
172
  readonly contentType: "application/vnd.microsoft.card.adaptive";
173
173
  readonly content: TeamsAdaptiveCard;
174
174
  }
175
- /** A non-fatal downgrade reported during Teams conversion. */
175
+ /**
176
+ * A non-fatal note reported during Teams conversion.
177
+ *
178
+ * `clamped` removed content to fit a limit, `dropped` discarded a node or one
179
+ * of its props and may leave a placeholder note behind, and `fallback`
180
+ * emitted the node in a different form than requested. `advisory` changed
181
+ * nothing at all and notes content Teams may still render poorly or refuse,
182
+ * such as a payload over the byte budget or a `Row` past the recommended
183
+ * column count.
184
+ */
176
185
  interface TeamsConversionWarning {
177
- readonly code: "clamped" | "dropped" | "fallback";
186
+ readonly code: "clamped" | "dropped" | "fallback" | "advisory";
178
187
  readonly component: string;
179
188
  readonly detail: string;
180
189
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","names":[],"sources":["../../src/teams/types.ts"],"mappings":";;KACY;;KAGA;;UASK;WACN;WACA;WACA;WACA,OAAO;WACP;WACA;WACA;WACA;WACA;;;UAIM;WACN;WACA;WACA;WACA;WACA;WACA;;;UAIM;WACN;WACA;;;UAIM;WACN;WACA,gBAAgB;WAChB;WACA;;;UAIM;WACN;aACE;aACA,UAAU;;;;;;;;UASN;WACN;WACA;WACA,MAAM;WACN;;;KAIC,kBAAkB;;UAGb;WACN;WACA,kBAAkB;WAClB;WACA;;;UAIM;WACN;WACA,QAAQ;WACR,gBAAgB;WAChB,eAAe;WACf;WACA;;;UAIM;WACN;WACA;WACA,gBAAgB;;;UAIV;WACN;WACA,kBAAkB;WAClB;WACA;;;UAIM;WACN;WACA;;;UAIM;WACN;WACA;WACA;WACA,kBAAkB;WAClB;WACA;WACA;WACA;WACA;;;UAIM;WACN;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;;UAIM;WACN;WACA;WACA;WACA;WACA;WACA;WACA;;;UAIM;WACN;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;;UAIM;WACN;WACA,gBAAgB;;;UAIV;WACN;WACA,gBAAgB;;;UAIV;WACN;;;UAIM;WACN;WACA;WACA,kBAAkB;WAClB,eAAe;WACf;WACA;;;KAIC,mBACR,iBACA,aACA,eACA,iBACA,iBACA,iBACA,sBACA,mBACA,iBACA,iBACA;;UAGa;WACN;WACA;WACA;WACA,eAAe;WACf,kBAAkB;;;UAIZ;WACN;WACA,SAAS;;;UAIH;WACN;WACA;WACA;;;UAIM;;UAGA;WACN,MAAM;WACN,UAAU;;;UAIJ;WACN,aAAa;WACb;WACA,UAAU"}
1
+ {"version":3,"file":"types.d.ts","names":[],"sources":["../../src/teams/types.ts"],"mappings":";;KACY;;KAGA;;UASK;WACN;WACA;WACA;WACA,OAAO;WACP;WACA;WACA;WACA;WACA;;;UAIM;WACN;WACA;WACA;WACA;WACA;WACA;;;UAIM;WACN;WACA;;;UAIM;WACN;WACA,gBAAgB;WAChB;WACA;;;UAIM;WACN;aACE;aACA,UAAU;;;;;;;;UASN;WACN;WACA;WACA,MAAM;WACN;;;KAIC,kBAAkB;;UAGb;WACN;WACA,kBAAkB;WAClB;WACA;;;UAIM;WACN;WACA,QAAQ;WACR,gBAAgB;WAChB,eAAe;WACf;WACA;;;UAIM;WACN;WACA;WACA,gBAAgB;;;UAIV;WACN;WACA,kBAAkB;WAClB;WACA;;;UAIM;WACN;WACA;;;UAIM;WACN;WACA;WACA;WACA,kBAAkB;WAClB;WACA;WACA;WACA;WACA;;;UAIM;WACN;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;;UAIM;WACN;WACA;WACA;WACA;WACA;WACA;WACA;;;UAIM;WACN;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;;UAIM;WACN;WACA,gBAAgB;;;UAIV;WACN;WACA,gBAAgB;;;UAIV;WACN;;;UAIM;WACN;WACA;WACA,kBAAkB;WAClB,eAAe;WACf;WACA;;;KAIC,mBACR,iBACA,aACA,eACA,iBACA,iBACA,iBACA,sBACA,mBACA,iBACA,iBACA;;UAGa;WACN;WACA;WACA;WACA,eAAe;WACf,kBAAkB;;;UAIZ;WACN;WACA,SAAS;;;;;;;;;;;;UAaH;WACN;WACA;WACA;;;UAIM;;UAGA;WACN,MAAM;WACN,UAAU;;;UAIJ;WACN,aAAa;WACb;WACA,UAAU"}
@@ -78,7 +78,7 @@ const TICK_COUNT = 5;
78
78
  /** `TICK_COUNT` evenly spaced ticks from `max` down to `0`, for a top-to-bottom y-axis column. */
79
79
  function tickValues(max) {
80
80
  const ticks = [];
81
- for (let i = 0; i < TICK_COUNT; i++) ticks.push(max * (TICK_COUNT - 1 - i) / (TICK_COUNT - 1));
81
+ for (let i = 0; i < TICK_COUNT; i++) ticks.push(max * (4 - i) / 4);
82
82
  return ticks;
83
83
  }
84
84
  function formatTick(value) {
@@ -97,8 +97,9 @@ function renderSeriesMarks(variant, series, count, scaleMax, stacked) {
97
97
  const marks = s.values.map((value, i) => {
98
98
  const height = scaleMax > 0 ? value / scaleMax * CHART_HEIGHT : 0;
99
99
  const belowHeight = stacked && scaleMax > 0 ? (cumulative[i] ?? 0) / scaleMax * CHART_HEIGHT : 0;
100
+ const x = stacked || seriesCount <= 1 ? i * slot + gap / 2 : i * slot + gap / 2 + seriesIndex * perSeriesWidth;
100
101
  return /* @__PURE__ */ jsx("rect", {
101
- x: stacked || seriesCount <= 1 ? i * slot + gap / 2 : i * slot + gap / 2 + seriesIndex * perSeriesWidth,
102
+ x,
102
103
  y: CHART_HEIGHT - belowHeight - height,
103
104
  width: perSeriesWidth,
104
105
  height,
@@ -1 +1 @@
1
- {"version":3,"file":"data.js","names":[],"sources":["../../src/vocabulary/data.tsx"],"sourcesContent":["import { z } from \"zod\";\nimport type { GenerativeUILibrary } from \"../types\";\n\nconst columnSchema = z.object({\n label: z.string().describe(\"Column header label.\"),\n});\n\nconst cellSchema = z\n .union([z.string(), z.number(), z.boolean()])\n .describe(\"A cell value.\");\n\nconst CHART_HEIGHT = 40;\nconst CHART_WIDTH = 100;\n\nconst clampValue = (value: unknown): number =>\n typeof value === \"number\" && Number.isFinite(value) ? Math.max(0, value) : 0;\n\nconst yFor = (value: number, max: number): number =>\n max > 0 ? CHART_HEIGHT - (value / max) * CHART_HEIGHT : CHART_HEIGHT;\n\nconst pointSchema = z.object({\n label: z.string().optional().describe(\"Point label.\"),\n value: z.number().describe(\"Point value.\"),\n});\n\nconst seriesSchema = z.object({\n label: z.string().optional().describe(\"Series label, shown in the legend.\"),\n data: z.array(pointSchema).describe(\"Data points for this series.\"),\n});\n\ntype ChartPoint = { label?: string; value: number };\ntype ChartSeriesInput = { label?: string; data: ChartPoint[] };\ntype NormalizedChartSeries = {\n label: string | undefined;\n values: number[];\n labels: (string | undefined)[];\n};\n\n/** Pads every series to the longest series' length, treating a shorter series' missing points as `{ value: 0 }` so mismatched series never misalign or throw. */\nfunction normalizeSeries(\n seriesProp: unknown,\n dataProp: unknown,\n): { count: number; series: NormalizedChartSeries[] } {\n const rawSeries: ChartSeriesInput[] =\n Array.isArray(seriesProp) && seriesProp.length > 0\n ? (seriesProp as ChartSeriesInput[])\n : [{ data: Array.isArray(dataProp) ? (dataProp as ChartPoint[]) : [] }];\n\n const count = rawSeries.reduce((max, s) => {\n const len = Array.isArray(s?.data) ? s.data.length : 0;\n return Math.max(max, len);\n }, 0);\n\n const series = rawSeries.map((s) => {\n const points = Array.isArray(s?.data) ? s.data : [];\n const values: number[] = [];\n const labels: (string | undefined)[] = [];\n for (let i = 0; i < count; i++) {\n const point = points[i];\n values.push(clampValue(point?.value));\n labels.push(typeof point?.label === \"string\" ? point.label : undefined);\n }\n return {\n label: typeof s?.label === \"string\" ? s.label : undefined,\n values,\n labels,\n };\n });\n\n return { count, series };\n}\n\nfunction computeMax(\n series: NormalizedChartSeries[],\n count: number,\n stacked: boolean,\n): number {\n if (stacked) {\n let max = 0;\n for (let i = 0; i < count; i++) {\n let sum = 0;\n for (const s of series) sum += s.values[i] ?? 0;\n max = Math.max(max, sum);\n }\n return max;\n }\n let max = 0;\n for (const s of series) for (const v of s.values) max = Math.max(max, v);\n return max;\n}\n\nconst NICE_MULTIPLES = [1, 2, 5];\n\n/** The smallest of `{1, 2, 5} × 10^n` that is `>= max`, so axis ticks land on round numbers. */\nfunction niceMax(max: number): number {\n if (max <= 0) return 0;\n const exponent = Math.floor(Math.log10(max));\n for (const multiple of NICE_MULTIPLES) {\n const candidate = multiple * 10 ** exponent;\n if (candidate >= max) return candidate;\n }\n return 10 ** (exponent + 1);\n}\n\nconst TICK_COUNT = 5;\n\n/** `TICK_COUNT` evenly spaced ticks from `max` down to `0`, for a top-to-bottom y-axis column. */\nfunction tickValues(max: number): number[] {\n const ticks: number[] = [];\n for (let i = 0; i < TICK_COUNT; i++) {\n ticks.push((max * (TICK_COUNT - 1 - i)) / (TICK_COUNT - 1));\n }\n return ticks;\n}\n\nfunction formatTick(value: number): string {\n return (Math.round(value * 100) / 100).toLocaleString(\"en-US\");\n}\n\ntype ChartVariant = \"bar\" | \"line\" | \"sparkline\" | \"area\";\n\nconst SERIES_PALETTE_SIZE = 5;\n\nfunction renderSeriesMarks(\n variant: ChartVariant,\n series: NormalizedChartSeries[],\n count: number,\n scaleMax: number,\n stacked: boolean,\n) {\n if (variant === \"bar\") {\n const slot = count > 0 ? CHART_WIDTH / count : 0;\n const gap = slot * 0.2;\n const groupWidth = slot - gap;\n const seriesCount = series.length;\n const perSeriesWidth =\n stacked || seriesCount <= 1 ? groupWidth : groupWidth / seriesCount;\n const cumulative = new Array(count).fill(0) as number[];\n\n return series.map((s, seriesIndex) => {\n const marks = s.values.map((value, i) => {\n const height = scaleMax > 0 ? (value / scaleMax) * CHART_HEIGHT : 0;\n const belowHeight =\n stacked && scaleMax > 0\n ? ((cumulative[i] ?? 0) / scaleMax) * CHART_HEIGHT\n : 0;\n const x =\n stacked || seriesCount <= 1\n ? i * slot + gap / 2\n : i * slot + gap / 2 + seriesIndex * perSeriesWidth;\n return (\n <rect\n key={i}\n x={x}\n y={CHART_HEIGHT - belowHeight - height}\n width={perSeriesWidth}\n height={height}\n fill=\"currentColor\"\n />\n );\n });\n if (stacked) {\n for (let i = 0; i < count; i++) {\n cumulative[i] = (cumulative[i] ?? 0) + (s.values[i] ?? 0);\n }\n }\n return (\n <g\n key={seriesIndex}\n data-aui=\"chart-series\"\n data-aui-series={seriesIndex % SERIES_PALETTE_SIZE}\n >\n {marks}\n </g>\n );\n });\n }\n\n if (variant === \"area\") {\n const cumulative = new Array(count).fill(0) as number[];\n\n return series.map((s, seriesIndex) => {\n const bottoms = stacked\n ? cumulative.slice()\n : (new Array(count).fill(0) as number[]);\n if (stacked) {\n for (let i = 0; i < count; i++) {\n cumulative[i] = (cumulative[i] ?? 0) + (s.values[i] ?? 0);\n }\n }\n const tops = stacked ? cumulative.slice() : s.values.slice();\n\n if (count === 1) {\n const y = yFor(tops[0] ?? 0, scaleMax);\n return (\n <g\n key={seriesIndex}\n data-aui=\"chart-series\"\n data-aui-series={seriesIndex % SERIES_PALETTE_SIZE}\n >\n <circle cx={CHART_WIDTH / 2} cy={y} r={2} fill=\"currentColor\" />\n </g>\n );\n }\n if (count === 0) {\n return (\n <g\n key={seriesIndex}\n data-aui=\"chart-series\"\n data-aui-series={seriesIndex % SERIES_PALETTE_SIZE}\n />\n );\n }\n\n const topPoints = tops.map(\n (v, i) => `${(i / (count - 1)) * CHART_WIDTH},${yFor(v, scaleMax)}`,\n );\n const bottomPoints = bottoms\n .map(\n (v, i) => `${(i / (count - 1)) * CHART_WIDTH},${yFor(v, scaleMax)}`,\n )\n .reverse();\n\n return (\n <g\n key={seriesIndex}\n data-aui=\"chart-series\"\n data-aui-series={seriesIndex % SERIES_PALETTE_SIZE}\n >\n <polygon\n points={[...topPoints, ...bottomPoints].join(\" \")}\n fill=\"currentColor\"\n fillOpacity=\"0.25\"\n />\n <polyline\n points={topPoints.join(\" \")}\n fill=\"none\"\n stroke=\"currentColor\"\n vectorEffect=\"non-scaling-stroke\"\n />\n </g>\n );\n });\n }\n\n // line / sparkline: each series is always drawn independently. Stacking a line has no single standard meaning, so `stacked` is ignored (the caller never passes it for these variants).\n return series.map((s, seriesIndex) => (\n <g\n key={seriesIndex}\n data-aui=\"chart-series\"\n data-aui-series={seriesIndex % SERIES_PALETTE_SIZE}\n >\n {count === 1 ? (\n <circle\n cx={CHART_WIDTH / 2}\n cy={yFor(s.values[0] ?? 0, scaleMax)}\n r={2}\n fill=\"currentColor\"\n />\n ) : count > 1 ? (\n <polyline\n points={s.values\n .map(\n (v, i) =>\n `${(i / (count - 1)) * CHART_WIDTH},${yFor(v, scaleMax)}`,\n )\n .join(\" \")}\n fill=\"none\"\n stroke=\"currentColor\"\n vectorEffect=\"non-scaling-stroke\"\n />\n ) : null}\n </g>\n ));\n}\n\nexport const dataVocabulary = {\n Table: {\n description:\n \"Tabular data. Provide `columns` and `rows`; each row is an array of cells matching the columns.\",\n properties: z.object({\n columns: z.array(columnSchema).optional().describe(\"Column definitions.\"),\n rows: z.array(z.array(cellSchema)).optional().describe(\"Rows of cells.\"),\n }),\n render: ({ columns, rows, children }) => (\n <table data-aui=\"table\">\n {columns?.length ? (\n <thead>\n <tr>\n {columns.map((c: { label: string }, i: number) => (\n <th key={i} data-aui=\"table-col\">\n {c.label}\n </th>\n ))}\n </tr>\n </thead>\n ) : null}\n {rows?.length ? (\n <tbody>\n {rows.map((row: (string | number | boolean)[], r: number) => (\n <tr key={r}>\n {row.map((cell: string | number | boolean, c: number) => (\n <td key={c}>{String(cell)}</td>\n ))}\n </tr>\n ))}\n </tbody>\n ) : null}\n {children}\n </table>\n ),\n },\n Markdown: {\n description:\n \"A markdown string. Rendered as-is by default; override this component for a full markdown renderer.\",\n properties: z.object({\n value: z.string().describe(\"Markdown source.\"),\n }),\n streamProperties: true,\n render: ({ value, children }) => (\n <div data-aui=\"markdown\">\n {value}\n {children}\n </div>\n ),\n },\n Chart: {\n description:\n \"A chart. `variant` selects bar, line, sparkline, or area rendering. Provide `data` for a single series, or `series` for multiple named series (`series` takes precedence over `data` when both are present). Set `stacked` to accumulate series values instead of overlaying them, and `showAxis`/`showLegend` to add y-axis ticks, x-axis point labels, and a legend.\",\n properties: z.object({\n variant: z\n .enum([\"bar\", \"line\", \"sparkline\", \"area\"])\n .describe(\"Chart variant.\"),\n data: z\n .array(pointSchema)\n .optional()\n .describe(\"Data points for a single series.\"),\n series: z\n .array(seriesSchema)\n .optional()\n .describe(\n \"Multiple named series; takes precedence over `data` when present.\",\n ),\n stacked: z\n .boolean()\n .optional()\n .describe(\n \"Accumulate series values instead of overlaying them (bar and area variants; ignored for line and sparkline).\",\n ),\n showAxis: z\n .boolean()\n .optional()\n .describe(\"Show y-axis ticks and x-axis point labels.\"),\n showLegend: z\n .boolean()\n .optional()\n .describe(\"Show a legend mapping each series to its color.\"),\n color: z\n .string()\n .optional()\n .describe(\n \"Series color (single-series mode only). One of `emphasis`, `secondary`, `alpha-70`, `white`, `white-70`, or `white-50`, matching Text's `color` tokens; other values have no visual effect.\",\n ),\n }),\n render: ({\n variant,\n data,\n series,\n stacked,\n showAxis,\n showLegend,\n color,\n }) => {\n const usesExtendedFeatures =\n variant === \"area\" ||\n !!stacked ||\n !!showAxis ||\n !!showLegend ||\n (Array.isArray(series) && series.length > 0);\n\n if (!usesExtendedFeatures) {\n const points = Array.isArray(data) ? data : [];\n const n = points.length;\n const values = points.map((d) => clampValue(d?.value));\n const max = values.reduce((m, v) => Math.max(m, v), 0);\n const slot = n > 0 ? CHART_WIDTH / n : 0;\n const gap = slot * 0.2;\n const barWidth = slot - gap;\n\n return (\n <svg\n data-aui=\"chart\"\n data-aui-variant={variant}\n data-aui-color={color}\n role=\"img\"\n aria-label={`${variant} chart with ${n} data points`}\n viewBox={`0 0 ${CHART_WIDTH} ${CHART_HEIGHT}`}\n preserveAspectRatio=\"none\"\n >\n {variant === \"bar\" ? (\n values.map((v, i) => {\n const height = max > 0 ? (v / max) * CHART_HEIGHT : 0;\n return (\n <rect\n key={i}\n x={i * slot + gap / 2}\n y={CHART_HEIGHT - height}\n width={barWidth}\n height={height}\n fill=\"currentColor\"\n />\n );\n })\n ) : n === 1 ? (\n <circle\n cx={CHART_WIDTH / 2}\n cy={yFor(values[0] ?? 0, max)}\n r={2}\n fill=\"currentColor\"\n />\n ) : n > 1 ? (\n <polyline\n points={values\n .map(\n (v, i) => `${(i / (n - 1)) * CHART_WIDTH},${yFor(v, max)}`,\n )\n .join(\" \")}\n fill=\"none\"\n stroke=\"currentColor\"\n />\n ) : null}\n </svg>\n );\n }\n\n const { count, series: normalized } = normalizeSeries(series, data);\n const stackedScale =\n !!stacked && (variant === \"bar\" || variant === \"area\");\n const rawMax = computeMax(normalized, count, stackedScale);\n const scaleMax = showAxis ? niceMax(rawMax) : rawMax;\n const marks = renderSeriesMarks(\n variant,\n normalized,\n count,\n scaleMax,\n stackedScale,\n );\n\n const svg = (\n <svg\n data-aui=\"chart\"\n data-aui-variant={variant}\n data-aui-color={color}\n role=\"img\"\n aria-label={`${variant} chart with ${count} data points`}\n viewBox={`0 0 ${CHART_WIDTH} ${CHART_HEIGHT}`}\n preserveAspectRatio=\"none\"\n >\n {marks}\n </svg>\n );\n\n if (!showAxis && !showLegend) return svg;\n\n return (\n <div data-aui=\"chart-frame\">\n {showAxis ? (\n <div data-aui=\"chart-ticks\">\n {tickValues(scaleMax).map((tick, i) => (\n <div key={i}>{formatTick(tick)}</div>\n ))}\n </div>\n ) : null}\n {svg}\n {showAxis ? (\n <div data-aui=\"chart-xlabels\">\n {(normalized[0]?.labels ?? []).map((label, i) => (\n <div key={i}>{label ?? \"\"}</div>\n ))}\n </div>\n ) : null}\n {showLegend ? (\n <div data-aui=\"chart-legend\">\n {normalized.map((s, i) => (\n <span\n key={i}\n data-aui=\"chart-legend-item\"\n data-aui-series={i % SERIES_PALETTE_SIZE}\n >\n <span data-aui=\"chart-legend-swatch\" />\n {s.label ?? `Series ${i + 1}`}\n </span>\n ))}\n </div>\n ) : null}\n </div>\n );\n },\n },\n} satisfies GenerativeUILibrary;\n"],"mappings":";;;AAGA,MAAM,eAAe,EAAE,OAAO,EAC5B,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS,sBAAsB,EACnD,CAAC;AAED,MAAM,aAAa,EAChB,MAAM;CAAC,EAAE,OAAO;CAAG,EAAE,OAAO;CAAG,EAAE,QAAQ;AAAC,CAAC,CAAC,CAC5C,SAAS,eAAe;AAE3B,MAAM,eAAe;AACrB,MAAM,cAAc;AAEpB,MAAM,cAAc,UAClB,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,IAAI,KAAK,IAAI,GAAG,KAAK,IAAI;AAE7E,MAAM,QAAQ,OAAe,QAC3B,MAAM,IAAI,eAAgB,QAAQ,MAAO,eAAe;AAE1D,MAAM,cAAc,EAAE,OAAO;CAC3B,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,cAAc;CACpD,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS,cAAc;AAC3C,CAAC;AAED,MAAM,eAAe,EAAE,OAAO;CAC5B,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,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,MAAM,MACJ,oBAAC,OAAD;IACE,YAAS;IACT,oBAAkB;IAClB,kBAAgB;IAChB,MAAK;IACL,cAAY,GAAG,QAAQ,cAAc,MAAM;IAC3C,SAAS,OAAO,YAAY,GAAG;IAC/B,qBAAoB;IAEnB,UAAA;GACE,CAAA;GAGP,IAAI,CAAC,YAAY,CAAC,YAAY,OAAO;GAErC,OACE,qBAAC,OAAD;IAAK,YAAS;IAAd,UAAA;KACG,WACC,oBAAC,OAAD;MAAK,YAAS;MACX,UAAA,WAAW,QAAQ,CAAC,CAAC,KAAK,MAAM,MAC/B,oBAAC,OAAD,EAAA,UAAc,WAAW,IAAI,EAAO,GAA1B,CAA0B,CACrC;KACE,CAAA,IACH;KACH;KACA,WACC,oBAAC,OAAD;MAAK,YAAS;MACV,WAAA,WAAW,EAAE,EAAE,UAAU,CAAC,EAAA,CAAG,KAAK,OAAO,MACzC,oBAAC,OAAD,EAAA,UAAc,SAAS,GAAQ,GAArB,CAAqB,CAChC;KACE,CAAA,IACH;KACH,aACC,oBAAC,OAAD;MAAK,YAAS;MACX,UAAA,WAAW,KAAK,GAAG,MAClB,qBAAC,QAAD;OAEE,YAAS;OACT,mBAAiB,IAAI;OAHvB,UAAA,CAKE,oBAAC,QAAD,EAAM,YAAS,sBAAuB,CAAA,GACrC,EAAE,SAAS,UAAU,IAAI,GACtB;MANC,GAAA,CAMD,CACP;KACE,CAAA,IACH;IACD;;EAET;CACF;AACF"}
1
+ {"version":3,"file":"data.js","names":[],"sources":["../../src/vocabulary/data.tsx"],"sourcesContent":["import { z } from \"zod\";\nimport type { GenerativeUILibrary } from \"../types\";\n\nconst columnSchema = z.object({\n label: z.string().describe(\"Column header label.\"),\n});\n\nconst cellSchema = z\n .union([z.string(), z.number(), z.boolean()])\n .describe(\"A cell value.\");\n\nconst CHART_HEIGHT = 40;\nconst CHART_WIDTH = 100;\n\nconst clampValue = (value: unknown): number =>\n typeof value === \"number\" && Number.isFinite(value) ? Math.max(0, value) : 0;\n\nconst yFor = (value: number, max: number): number =>\n max > 0 ? CHART_HEIGHT - (value / max) * CHART_HEIGHT : CHART_HEIGHT;\n\nconst pointSchema = z.object({\n label: z.string().optional().describe(\"Point label.\"),\n value: z.number().describe(\"Point value.\"),\n});\n\nconst seriesSchema = z.object({\n label: z.string().optional().describe(\"Series label, shown in the legend.\"),\n data: z.array(pointSchema).describe(\"Data points for this series.\"),\n});\n\ntype ChartPoint = { label?: string; value: number };\ntype ChartSeriesInput = { label?: string; data: ChartPoint[] };\ntype NormalizedChartSeries = {\n label: string | undefined;\n values: number[];\n labels: (string | undefined)[];\n};\n\n/** Pads every series to the longest series' length, treating a shorter series' missing points as `{ value: 0 }` so mismatched series never misalign or throw. */\nfunction normalizeSeries(\n seriesProp: unknown,\n dataProp: unknown,\n): { count: number; series: NormalizedChartSeries[] } {\n const rawSeries: ChartSeriesInput[] =\n Array.isArray(seriesProp) && seriesProp.length > 0\n ? (seriesProp as ChartSeriesInput[])\n : [{ data: Array.isArray(dataProp) ? (dataProp as ChartPoint[]) : [] }];\n\n const count = rawSeries.reduce((max, s) => {\n const len = Array.isArray(s?.data) ? s.data.length : 0;\n return Math.max(max, len);\n }, 0);\n\n const series = rawSeries.map((s) => {\n const points = Array.isArray(s?.data) ? s.data : [];\n const values: number[] = [];\n const labels: (string | undefined)[] = [];\n for (let i = 0; i < count; i++) {\n const point = points[i];\n values.push(clampValue(point?.value));\n labels.push(typeof point?.label === \"string\" ? point.label : undefined);\n }\n return {\n label: typeof s?.label === \"string\" ? s.label : undefined,\n values,\n labels,\n };\n });\n\n return { count, series };\n}\n\nfunction computeMax(\n series: NormalizedChartSeries[],\n count: number,\n stacked: boolean,\n): number {\n if (stacked) {\n let max = 0;\n for (let i = 0; i < count; i++) {\n let sum = 0;\n for (const s of series) sum += s.values[i] ?? 0;\n max = Math.max(max, sum);\n }\n return max;\n }\n let max = 0;\n for (const s of series) for (const v of s.values) max = Math.max(max, v);\n return max;\n}\n\nconst NICE_MULTIPLES = [1, 2, 5];\n\n/** The smallest of `{1, 2, 5} × 10^n` that is `>= max`, so axis ticks land on round numbers. */\nfunction niceMax(max: number): number {\n if (max <= 0) return 0;\n const exponent = Math.floor(Math.log10(max));\n for (const multiple of NICE_MULTIPLES) {\n const candidate = multiple * 10 ** exponent;\n if (candidate >= max) return candidate;\n }\n return 10 ** (exponent + 1);\n}\n\nconst TICK_COUNT = 5;\n\n/** `TICK_COUNT` evenly spaced ticks from `max` down to `0`, for a top-to-bottom y-axis column. */\nfunction tickValues(max: number): number[] {\n const ticks: number[] = [];\n for (let i = 0; i < TICK_COUNT; i++) {\n ticks.push((max * (TICK_COUNT - 1 - i)) / (TICK_COUNT - 1));\n }\n return ticks;\n}\n\nfunction formatTick(value: number): string {\n return (Math.round(value * 100) / 100).toLocaleString(\"en-US\");\n}\n\ntype ChartVariant = \"bar\" | \"line\" | \"sparkline\" | \"area\";\n\nconst SERIES_PALETTE_SIZE = 5;\n\nfunction renderSeriesMarks(\n variant: ChartVariant,\n series: NormalizedChartSeries[],\n count: number,\n scaleMax: number,\n stacked: boolean,\n) {\n if (variant === \"bar\") {\n const slot = count > 0 ? CHART_WIDTH / count : 0;\n const gap = slot * 0.2;\n const groupWidth = slot - gap;\n const seriesCount = series.length;\n const perSeriesWidth =\n stacked || seriesCount <= 1 ? groupWidth : groupWidth / seriesCount;\n const cumulative = new Array(count).fill(0) as number[];\n\n return series.map((s, seriesIndex) => {\n const marks = s.values.map((value, i) => {\n const height = scaleMax > 0 ? (value / scaleMax) * CHART_HEIGHT : 0;\n const belowHeight =\n stacked && scaleMax > 0\n ? ((cumulative[i] ?? 0) / scaleMax) * CHART_HEIGHT\n : 0;\n const x =\n stacked || seriesCount <= 1\n ? i * slot + gap / 2\n : i * slot + gap / 2 + seriesIndex * perSeriesWidth;\n return (\n <rect\n key={i}\n x={x}\n y={CHART_HEIGHT - belowHeight - height}\n width={perSeriesWidth}\n height={height}\n fill=\"currentColor\"\n />\n );\n });\n if (stacked) {\n for (let i = 0; i < count; i++) {\n cumulative[i] = (cumulative[i] ?? 0) + (s.values[i] ?? 0);\n }\n }\n return (\n <g\n key={seriesIndex}\n data-aui=\"chart-series\"\n data-aui-series={seriesIndex % SERIES_PALETTE_SIZE}\n >\n {marks}\n </g>\n );\n });\n }\n\n if (variant === \"area\") {\n const cumulative = new Array(count).fill(0) as number[];\n\n return series.map((s, seriesIndex) => {\n const bottoms = stacked\n ? cumulative.slice()\n : (new Array(count).fill(0) as number[]);\n if (stacked) {\n for (let i = 0; i < count; i++) {\n cumulative[i] = (cumulative[i] ?? 0) + (s.values[i] ?? 0);\n }\n }\n const tops = stacked ? cumulative.slice() : s.values.slice();\n\n if (count === 1) {\n const y = yFor(tops[0] ?? 0, scaleMax);\n return (\n <g\n key={seriesIndex}\n data-aui=\"chart-series\"\n data-aui-series={seriesIndex % SERIES_PALETTE_SIZE}\n >\n <circle cx={CHART_WIDTH / 2} cy={y} r={2} fill=\"currentColor\" />\n </g>\n );\n }\n if (count === 0) {\n return (\n <g\n key={seriesIndex}\n data-aui=\"chart-series\"\n data-aui-series={seriesIndex % SERIES_PALETTE_SIZE}\n />\n );\n }\n\n const topPoints = tops.map(\n (v, i) => `${(i / (count - 1)) * CHART_WIDTH},${yFor(v, scaleMax)}`,\n );\n const bottomPoints = bottoms\n .map(\n (v, i) => `${(i / (count - 1)) * CHART_WIDTH},${yFor(v, scaleMax)}`,\n )\n .reverse();\n\n return (\n <g\n key={seriesIndex}\n data-aui=\"chart-series\"\n data-aui-series={seriesIndex % SERIES_PALETTE_SIZE}\n >\n <polygon\n points={[...topPoints, ...bottomPoints].join(\" \")}\n fill=\"currentColor\"\n fillOpacity=\"0.25\"\n />\n <polyline\n points={topPoints.join(\" \")}\n fill=\"none\"\n stroke=\"currentColor\"\n vectorEffect=\"non-scaling-stroke\"\n />\n </g>\n );\n });\n }\n\n // line / sparkline: each series is always drawn independently. Stacking a line has no single standard meaning, so `stacked` is ignored (the caller never passes it for these variants).\n return series.map((s, seriesIndex) => (\n <g\n key={seriesIndex}\n data-aui=\"chart-series\"\n data-aui-series={seriesIndex % SERIES_PALETTE_SIZE}\n >\n {count === 1 ? (\n <circle\n cx={CHART_WIDTH / 2}\n cy={yFor(s.values[0] ?? 0, scaleMax)}\n r={2}\n fill=\"currentColor\"\n />\n ) : count > 1 ? (\n <polyline\n points={s.values\n .map(\n (v, i) =>\n `${(i / (count - 1)) * CHART_WIDTH},${yFor(v, scaleMax)}`,\n )\n .join(\" \")}\n fill=\"none\"\n stroke=\"currentColor\"\n vectorEffect=\"non-scaling-stroke\"\n />\n ) : null}\n </g>\n ));\n}\n\nexport const dataVocabulary = {\n Table: {\n description:\n \"Tabular data. Provide `columns` and `rows`; each row is an array of cells matching the columns.\",\n properties: z.object({\n columns: z.array(columnSchema).optional().describe(\"Column definitions.\"),\n rows: z.array(z.array(cellSchema)).optional().describe(\"Rows of cells.\"),\n }),\n render: ({ columns, rows, children }) => (\n <table data-aui=\"table\">\n {columns?.length ? (\n <thead>\n <tr>\n {columns.map((c: { label: string }, i: number) => (\n <th key={i} data-aui=\"table-col\">\n {c.label}\n </th>\n ))}\n </tr>\n </thead>\n ) : null}\n {rows?.length ? (\n <tbody>\n {rows.map((row: (string | number | boolean)[], r: number) => (\n <tr key={r}>\n {row.map((cell: string | number | boolean, c: number) => (\n <td key={c}>{String(cell)}</td>\n ))}\n </tr>\n ))}\n </tbody>\n ) : null}\n {children}\n </table>\n ),\n },\n Markdown: {\n description:\n \"A markdown string. Rendered as-is by default; override this component for a full markdown renderer.\",\n properties: z.object({\n value: z.string().describe(\"Markdown source.\"),\n }),\n streamProperties: true,\n render: ({ value, children }) => (\n <div data-aui=\"markdown\">\n {value}\n {children}\n </div>\n ),\n },\n Chart: {\n description:\n \"A chart. `variant` selects bar, line, sparkline, or area rendering. Provide `data` for a single series, or `series` for multiple named series (`series` takes precedence over `data` when both are present). Set `stacked` to accumulate series values instead of overlaying them, and `showAxis`/`showLegend` to add y-axis ticks, x-axis point labels, and a legend.\",\n properties: z.object({\n variant: z\n .enum([\"bar\", \"line\", \"sparkline\", \"area\"])\n .describe(\"Chart variant.\"),\n data: z\n .array(pointSchema)\n .optional()\n .describe(\"Data points for a single series.\"),\n series: z\n .array(seriesSchema)\n .optional()\n .describe(\n \"Multiple named series; takes precedence over `data` when present.\",\n ),\n stacked: z\n .boolean()\n .optional()\n .describe(\n \"Accumulate series values instead of overlaying them (bar and area variants; ignored for line and sparkline).\",\n ),\n showAxis: z\n .boolean()\n .optional()\n .describe(\"Show y-axis ticks and x-axis point labels.\"),\n showLegend: z\n .boolean()\n .optional()\n .describe(\"Show a legend mapping each series to its color.\"),\n color: z\n .string()\n .optional()\n .describe(\n \"Series color (single-series mode only). One of `emphasis`, `secondary`, `alpha-70`, `white`, `white-70`, or `white-50`, matching Text's `color` tokens; other values have no visual effect.\",\n ),\n }),\n render: ({\n variant,\n data,\n series,\n stacked,\n showAxis,\n showLegend,\n color,\n }) => {\n const usesExtendedFeatures =\n variant === \"area\" ||\n !!stacked ||\n !!showAxis ||\n !!showLegend ||\n (Array.isArray(series) && series.length > 0);\n\n if (!usesExtendedFeatures) {\n const points = Array.isArray(data) ? data : [];\n const n = points.length;\n const values = points.map((d) => clampValue(d?.value));\n const max = values.reduce((m, v) => Math.max(m, v), 0);\n const slot = n > 0 ? CHART_WIDTH / n : 0;\n const gap = slot * 0.2;\n const barWidth = slot - gap;\n\n return (\n <svg\n data-aui=\"chart\"\n data-aui-variant={variant}\n data-aui-color={color}\n role=\"img\"\n aria-label={`${variant} chart with ${n} data points`}\n viewBox={`0 0 ${CHART_WIDTH} ${CHART_HEIGHT}`}\n preserveAspectRatio=\"none\"\n >\n {variant === \"bar\" ? (\n values.map((v, i) => {\n const height = max > 0 ? (v / max) * CHART_HEIGHT : 0;\n return (\n <rect\n key={i}\n x={i * slot + gap / 2}\n y={CHART_HEIGHT - height}\n width={barWidth}\n height={height}\n fill=\"currentColor\"\n />\n );\n })\n ) : n === 1 ? (\n <circle\n cx={CHART_WIDTH / 2}\n cy={yFor(values[0] ?? 0, max)}\n r={2}\n fill=\"currentColor\"\n />\n ) : n > 1 ? (\n <polyline\n points={values\n .map(\n (v, i) => `${(i / (n - 1)) * CHART_WIDTH},${yFor(v, max)}`,\n )\n .join(\" \")}\n fill=\"none\"\n stroke=\"currentColor\"\n />\n ) : null}\n </svg>\n );\n }\n\n const { count, series: normalized } = normalizeSeries(series, data);\n const stackedScale =\n !!stacked && (variant === \"bar\" || variant === \"area\");\n const rawMax = computeMax(normalized, count, stackedScale);\n const scaleMax = showAxis ? niceMax(rawMax) : rawMax;\n const marks = renderSeriesMarks(\n variant,\n normalized,\n count,\n scaleMax,\n stackedScale,\n );\n\n const svg = (\n <svg\n data-aui=\"chart\"\n data-aui-variant={variant}\n data-aui-color={color}\n role=\"img\"\n aria-label={`${variant} chart with ${count} data points`}\n viewBox={`0 0 ${CHART_WIDTH} ${CHART_HEIGHT}`}\n preserveAspectRatio=\"none\"\n >\n {marks}\n </svg>\n );\n\n if (!showAxis && !showLegend) return svg;\n\n return (\n <div data-aui=\"chart-frame\">\n {showAxis ? (\n <div data-aui=\"chart-ticks\">\n {tickValues(scaleMax).map((tick, i) => (\n <div key={i}>{formatTick(tick)}</div>\n ))}\n </div>\n ) : null}\n {svg}\n {showAxis ? (\n <div data-aui=\"chart-xlabels\">\n {(normalized[0]?.labels ?? []).map((label, i) => (\n <div key={i}>{label ?? \"\"}</div>\n ))}\n </div>\n ) : null}\n {showLegend ? (\n <div data-aui=\"chart-legend\">\n {normalized.map((s, i) => (\n <span\n key={i}\n data-aui=\"chart-legend-item\"\n data-aui-series={i % SERIES_PALETTE_SIZE}\n >\n <span data-aui=\"chart-legend-swatch\" />\n {s.label ?? `Series ${i + 1}`}\n </span>\n ))}\n </div>\n ) : null}\n </div>\n );\n },\n },\n} satisfies GenerativeUILibrary;\n"],"mappings":";;;AAGA,MAAM,eAAe,EAAE,OAAO,EAC5B,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS,sB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,oBAAC,OAAD;MAAK,YAAS;MACX,UAAA,WAAW,KAAK,GAAG,MAClB,qBAAC,QAAD;OAEE,YAAS;OACT,mBAAiB,IAAI;OAHvB,UAAA,CAKE,oBAAC,QAAD,EAAM,YAAS,sBAAuB,CAAA,GACrC,EAAE,SAAS,UAAU,IAAI,GACtB;MANC,GAAA,CAMD,CACP;KACE,CAAA,IACH;IACD;;EAET;CACF;AACF"}
@@ -12,7 +12,7 @@ const cardFooterButtonSchema = z.object({
12
12
  });
13
13
  const layoutVocabulary = {
14
14
  Card: {
15
- description: "A bordered container grouping related content. Optionally titled. Set `asForm` to collect named child control values on submit, and `confirm`/`cancel` to add a footer with action buttons.",
15
+ description: "A titled section of related content, the default way to break a response into parts. It renders as plain content, so several in a row read as one answer rather than a stack of boxes; it takes on a framed surface only when `background` is set, when `confirm`/`cancel` add a footer, or when it is a slot in a `Carousel`. Set `asForm` to collect named child control values on submit.",
16
16
  properties: z.object({
17
17
  title: z.string().optional().describe("Optional card title."),
18
18
  padding: z.number().min(0).max(8).optional().describe("Padding in 4px units (e.g. 2 = 8px). 0 to 8 is the supported range."),
@@ -41,6 +41,7 @@ const layoutVocabulary = {
41
41
  "data-aui": "card",
42
42
  "data-aui-padding": padding,
43
43
  "data-aui-background": background,
44
+ "data-aui-surface": background !== void 0 || footer !== null ? "" : void 0,
44
45
  style: background !== void 0 ? {
45
46
  background,
46
47
  color: "white"
@@ -1 +1 @@
1
- {"version":3,"file":"layout.js","names":[],"sources":["../../src/vocabulary/layout.tsx"],"sourcesContent":["import type { CSSProperties, FormEvent } from \"react\";\nimport { z } from \"zod\";\nimport type { GenerativeUILibrary } from \"../types\";\nimport { ALIGNS, JUSTIFIES } from \"../ir\";\nimport { fire } from \"./dispatch\";\nimport { collectFormValuesFromEvent } from \"./collectFormValues\";\n\nconst toCssLength = (value: string | number): string =>\n typeof value === \"number\" ? `${value}px` : value;\n\nconst cardActionSchema = z.looseObject({\n type: z\n .string()\n .describe(\"The action type, resolved by the host's action registry.\"),\n});\n\nconst cardFooterButtonSchema = z.object({\n label: z.string().describe(\"Footer button label.\"),\n $action: cardActionSchema\n .optional()\n .describe(\"Action fired when the button is activated.\"),\n});\n\nexport const layoutVocabulary = {\n Card: {\n description:\n \"A bordered container grouping related content. Optionally titled. Set `asForm` to collect named child control values on submit, and `confirm`/`cancel` to add a footer with action buttons.\",\n properties: z.object({\n title: z.string().optional().describe(\"Optional card title.\"),\n padding: z\n .number()\n .min(0)\n .max(8)\n .optional()\n .describe(\n \"Padding in 4px units (e.g. 2 = 8px). 0 to 8 is the supported range.\",\n ),\n background: z\n .string()\n .optional()\n .describe(\n \"Background color or gradient (any CSS background value). Setting this also switches the card's own text to white, since a custom background makes the card a tinted surface; children can still opt into a different color explicitly.\",\n ),\n asForm: z\n .boolean()\n .optional()\n .describe(\n \"Render as a form; submitting it fires `confirm.$action` with every named child control's value, keyed by `name`.\",\n ),\n confirm: cardFooterButtonSchema\n .optional()\n .describe(\"Confirm button shown in the footer.\"),\n cancel: cardFooterButtonSchema\n .optional()\n .describe(\"Cancel button shown in the footer.\"),\n }),\n render: ({\n title,\n padding,\n background,\n asForm,\n confirm,\n cancel,\n $dispatch,\n children,\n }) => {\n const Root = asForm ? \"form\" : \"section\";\n const footer =\n confirm || cancel ? (\n <footer data-aui=\"card-footer\">\n {confirm ? (\n <button\n type={asForm ? \"submit\" : \"button\"}\n data-aui=\"card-confirm\"\n onClick={\n asForm ? undefined : () => fire(confirm.$action, $dispatch)\n }\n >\n {confirm.label}\n </button>\n ) : null}\n {cancel ? (\n <button\n type=\"button\"\n data-aui=\"card-cancel\"\n onClick={() => fire(cancel.$action, $dispatch)}\n >\n {cancel.label}\n </button>\n ) : null}\n </footer>\n ) : null;\n\n return (\n <Root\n data-aui=\"card\"\n data-aui-padding={padding}\n data-aui-background={background}\n style={\n background !== undefined\n ? { background, color: \"white\" }\n : undefined\n }\n data-aui-asform={asForm || undefined}\n onSubmit={\n asForm\n ? (event: FormEvent<HTMLFormElement>) => {\n event.preventDefault();\n fire(\n confirm?.$action,\n $dispatch,\n collectFormValuesFromEvent(event),\n );\n }\n : undefined\n }\n >\n {title ? <header data-aui=\"card-title\">{title}</header> : null}\n {children}\n {footer}\n </Root>\n );\n },\n },\n Col: {\n description: \"A vertical stack; children laid out top to bottom.\",\n properties: z.object({\n gap: z\n .number()\n .min(0)\n .max(8)\n .optional()\n .describe(\n \"Gap between children in 4px units. 0 to 8 is the supported range.\",\n ),\n align: z.enum(ALIGNS).optional().describe(\"Cross-axis alignment.\"),\n }),\n render: ({ gap, align, children }) => (\n <div data-aui=\"col\" data-aui-gap={gap} data-aui-align={align}>\n {children}\n </div>\n ),\n },\n Row: {\n description: \"A horizontal row; children laid out left to right.\",\n properties: z.object({\n gap: z\n .number()\n .min(0)\n .max(8)\n .optional()\n .describe(\n \"Gap between children in 4px units. 0 to 8 is the supported range.\",\n ),\n align: z.enum(ALIGNS).optional().describe(\"Cross-axis alignment.\"),\n justify: z.enum(JUSTIFIES).optional().describe(\"Main-axis distribution.\"),\n }),\n render: ({ gap, align, justify, children }) => (\n <div\n data-aui=\"row\"\n data-aui-gap={gap}\n data-aui-align={align}\n data-aui-justify={justify}\n >\n {children}\n </div>\n ),\n },\n Spacer: {\n description: \"Empty space that pushes neighbors apart.\",\n properties: z.object({}),\n render: () => <div data-aui=\"spacer\" />,\n },\n Badge: {\n description: \"A small labeled tag, e.g. for status or category.\",\n properties: z.object({\n value: z.string().describe(\"Badge text.\"),\n variant: z.string().optional().describe(\"Visual variant token.\"),\n }),\n render: ({ value, variant, children }) => (\n <span data-aui=\"badge\" data-aui-variant={variant}>\n {value}\n {children}\n </span>\n ),\n },\n Box: {\n description:\n \"A generic container for composition, e.g. a progress bar built from an outer track Box containing a partial-width fill Box. Size, radius, and background accept arbitrary values, so they render as inline styles rather than data-attribute hooks.\",\n properties: z.object({\n width: z\n .union([z.string(), z.number()])\n .optional()\n .describe(\"Width; a number is pixels.\"),\n height: z\n .union([z.string(), z.number()])\n .optional()\n .describe(\"Height; a number is pixels.\"),\n radius: z\n .union([z.literal(\"full\"), z.number()])\n .optional()\n .describe(\n 'Corner radius; \"full\" is a pill/circle, a number is pixels.',\n ),\n background: z\n .string()\n .optional()\n .describe(\"Background color or gradient (any CSS background value).\"),\n }),\n render: ({ width, height, radius, background, children }) => {\n const style: CSSProperties = {};\n if (width !== undefined) style.width = toCssLength(width);\n if (height !== undefined) style.height = toCssLength(height);\n if (background !== undefined) style.background = background;\n if (radius === \"full\") style.borderRadius = \"9999px\";\n else if (typeof radius === \"number\") style.borderRadius = `${radius}px`;\n\n return (\n <div\n data-aui=\"box\"\n data-aui-radius={radius === \"full\" ? \"full\" : undefined}\n style={style}\n >\n {children}\n </div>\n );\n },\n },\n} satisfies GenerativeUILibrary;\n"],"mappings":";;;;;;AAOA,MAAM,eAAe,UACnB,OAAO,UAAU,WAAW,GAAG,MAAM,MAAM;AAE7C,MAAM,mBAAmB,EAAE,YAAY,EACrC,MAAM,EACH,OAAO,CAAC,CACR,SAAS,0DAA0D,EACxE,CAAC;AAED,MAAM,yBAAyB,EAAE,OAAO;CACtC,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS,sBAAsB;CACjD,SAAS,iBACN,SAAS,CAAC,CACV,SAAS,4CAA4C;AAC1D,CAAC;AAED,MAAa,mBAAmB;CAC9B,MAAM;EACJ,aACE;EACF,YAAY,EAAE,OAAO;GACnB,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,sBAAsB;GAC5D,SAAS,EACN,OAAO,CAAC,CACR,IAAI,CAAC,CAAC,CACN,IAAI,CAAC,CAAC,CACN,SAAS,CAAC,CACV,SACC,qEACF;GACF,YAAY,EACT,OAAO,CAAC,CACR,SAAS,CAAC,CACV,SACC,wOACF;GACF,QAAQ,EACL,QAAQ,CAAC,CACT,SAAS,CAAC,CACV,SACC,kHACF;GACF,SAAS,uBACN,SAAS,CAAC,CACV,SAAS,qCAAqC;GACjD,QAAQ,uBACL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ACR,SAAS,CAAC,CACV,SAAS,0DAA0D;EACxE,CAAC;EACD,SAAS,EAAE,OAAO,QAAQ,QAAQ,YAAY,eAAe;GAC3D,MAAM,QAAuB,CAAC;GAC9B,IAAI,UAAU,KAAA,GAAW,MAAM,QAAQ,YAAY,KAAK;GACxD,IAAI,WAAW,KAAA,GAAW,MAAM,SAAS,YAAY,MAAM;GAC3D,IAAI,eAAe,KAAA,GAAW,MAAM,aAAa;GACjD,IAAI,WAAW,QAAQ,MAAM,eAAe;QACvC,IAAI,OAAO,WAAW,UAAU,MAAM,eAAe,GAAG,OAAO;GAEpE,OACE,oBAAC,OAAD;IACE,YAAS;IACT,mBAAiB,WAAW,SAAS,SAAS,KAAA;IACvC;IAEN;GACE,CAAA;EAET;CACF;AACF"}
1
+ {"version":3,"file":"layout.js","names":[],"sources":["../../src/vocabulary/layout.tsx"],"sourcesContent":["import type { CSSProperties, FormEvent } from \"react\";\nimport { z } from \"zod\";\nimport type { GenerativeUILibrary } from \"../types\";\nimport { ALIGNS, JUSTIFIES } from \"../ir\";\nimport { fire } from \"./dispatch\";\nimport { collectFormValuesFromEvent } from \"./collectFormValues\";\n\nconst toCssLength = (value: string | number): string =>\n typeof value === \"number\" ? `${value}px` : value;\n\nconst cardActionSchema = z.looseObject({\n type: z\n .string()\n .describe(\"The action type, resolved by the host's action registry.\"),\n});\n\nconst cardFooterButtonSchema = z.object({\n label: z.string().describe(\"Footer button label.\"),\n $action: cardActionSchema\n .optional()\n .describe(\"Action fired when the button is activated.\"),\n});\n\nexport const layoutVocabulary = {\n Card: {\n description:\n \"A titled section of related content, the default way to break a response into parts. It renders as plain content, so several in a row read as one answer rather than a stack of boxes; it takes on a framed surface only when `background` is set, when `confirm`/`cancel` add a footer, or when it is a slot in a `Carousel`. Set `asForm` to collect named child control values on submit.\",\n properties: z.object({\n title: z.string().optional().describe(\"Optional card title.\"),\n padding: z\n .number()\n .min(0)\n .max(8)\n .optional()\n .describe(\n \"Padding in 4px units (e.g. 2 = 8px). 0 to 8 is the supported range.\",\n ),\n background: z\n .string()\n .optional()\n .describe(\n \"Background color or gradient (any CSS background value). Setting this also switches the card's own text to white, since a custom background makes the card a tinted surface; children can still opt into a different color explicitly.\",\n ),\n asForm: z\n .boolean()\n .optional()\n .describe(\n \"Render as a form; submitting it fires `confirm.$action` with every named child control's value, keyed by `name`.\",\n ),\n confirm: cardFooterButtonSchema\n .optional()\n .describe(\"Confirm button shown in the footer.\"),\n cancel: cardFooterButtonSchema\n .optional()\n .describe(\"Cancel button shown in the footer.\"),\n }),\n render: ({\n title,\n padding,\n background,\n asForm,\n confirm,\n cancel,\n $dispatch,\n children,\n }) => {\n const Root = asForm ? \"form\" : \"section\";\n const footer =\n confirm || cancel ? (\n <footer data-aui=\"card-footer\">\n {confirm ? (\n <button\n type={asForm ? \"submit\" : \"button\"}\n data-aui=\"card-confirm\"\n onClick={\n asForm ? undefined : () => fire(confirm.$action, $dispatch)\n }\n >\n {confirm.label}\n </button>\n ) : null}\n {cancel ? (\n <button\n type=\"button\"\n data-aui=\"card-cancel\"\n onClick={() => fire(cancel.$action, $dispatch)}\n >\n {cancel.label}\n </button>\n ) : null}\n </footer>\n ) : null;\n\n return (\n <Root\n data-aui=\"card\"\n data-aui-padding={padding}\n data-aui-background={background}\n data-aui-surface={\n background !== undefined || footer !== null ? \"\" : undefined\n }\n style={\n background !== undefined\n ? { background, color: \"white\" }\n : undefined\n }\n data-aui-asform={asForm || undefined}\n onSubmit={\n asForm\n ? (event: FormEvent<HTMLFormElement>) => {\n event.preventDefault();\n fire(\n confirm?.$action,\n $dispatch,\n collectFormValuesFromEvent(event),\n );\n }\n : undefined\n }\n >\n {title ? <header data-aui=\"card-title\">{title}</header> : null}\n {children}\n {footer}\n </Root>\n );\n },\n },\n Col: {\n description: \"A vertical stack; children laid out top to bottom.\",\n properties: z.object({\n gap: z\n .number()\n .min(0)\n .max(8)\n .optional()\n .describe(\n \"Gap between children in 4px units. 0 to 8 is the supported range.\",\n ),\n align: z.enum(ALIGNS).optional().describe(\"Cross-axis alignment.\"),\n }),\n render: ({ gap, align, children }) => (\n <div data-aui=\"col\" data-aui-gap={gap} data-aui-align={align}>\n {children}\n </div>\n ),\n },\n Row: {\n description: \"A horizontal row; children laid out left to right.\",\n properties: z.object({\n gap: z\n .number()\n .min(0)\n .max(8)\n .optional()\n .describe(\n \"Gap between children in 4px units. 0 to 8 is the supported range.\",\n ),\n align: z.enum(ALIGNS).optional().describe(\"Cross-axis alignment.\"),\n justify: z.enum(JUSTIFIES).optional().describe(\"Main-axis distribution.\"),\n }),\n render: ({ gap, align, justify, children }) => (\n <div\n data-aui=\"row\"\n data-aui-gap={gap}\n data-aui-align={align}\n data-aui-justify={justify}\n >\n {children}\n </div>\n ),\n },\n Spacer: {\n description: \"Empty space that pushes neighbors apart.\",\n properties: z.object({}),\n render: () => <div data-aui=\"spacer\" />,\n },\n Badge: {\n description: \"A small labeled tag, e.g. for status or category.\",\n properties: z.object({\n value: z.string().describe(\"Badge text.\"),\n variant: z.string().optional().describe(\"Visual variant token.\"),\n }),\n render: ({ value, variant, children }) => (\n <span data-aui=\"badge\" data-aui-variant={variant}>\n {value}\n {children}\n </span>\n ),\n },\n Box: {\n description:\n \"A generic container for composition, e.g. a progress bar built from an outer track Box containing a partial-width fill Box. Size, radius, and background accept arbitrary values, so they render as inline styles rather than data-attribute hooks.\",\n properties: z.object({\n width: z\n .union([z.string(), z.number()])\n .optional()\n .describe(\"Width; a number is pixels.\"),\n height: z\n .union([z.string(), z.number()])\n .optional()\n .describe(\"Height; a number is pixels.\"),\n radius: z\n .union([z.literal(\"full\"), z.number()])\n .optional()\n .describe(\n 'Corner radius; \"full\" is a pill/circle, a number is pixels.',\n ),\n background: z\n .string()\n .optional()\n .describe(\"Background color or gradient (any CSS background value).\"),\n }),\n render: ({ width, height, radius, background, children }) => {\n const style: CSSProperties = {};\n if (width !== undefined) style.width = toCssLength(width);\n if (height !== undefined) style.height = toCssLength(height);\n if (background !== undefined) style.background = background;\n if (radius === \"full\") style.borderRadius = \"9999px\";\n else if (typeof radius === \"number\") style.borderRadius = `${radius}px`;\n\n return (\n <div\n data-aui=\"box\"\n data-aui-radius={radius === \"full\" ? \"full\" : undefined}\n style={style}\n >\n {children}\n </div>\n );\n },\n },\n} satisfies GenerativeUILibrary;\n"],"mappings":";;;;;;AAOA,MAAM,eAAe,UACnB,OAAO,UAAU,WAAW,GAAG,MAAM,MAAM;AAE7C,MAAM,mBAAmB,EAAE,YAAY,EACrC,MAAM,EACH,OAAO,CAAC,CACR,SAAS,0DAA0D,EACxE,CAAC;AAED,MAAM,yBAAyB,EAAE,OAAO;CACtC,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS,sBAAsB;CACjD,SAAS,iBACN,SAAS,CAAC,CACV,SAAS,4CAA4C;AAC1D,CAAC;AAED,MAAa,mBAAmB;CAC9B,MAAM;EACJ,aACE;EACF,YAAY,EAAE,OAAO;GACnB,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,sBAAsB;GAC5D,SAAS,EACN,OAAO,CAAC,CACR,IAAI,CAAC,CAAC,CACN,IAAI,CAAC,CAAC,CACN,SAAS,CAAC,CACV,SACC,qEACF;GACF,YAAY,EACT,OAAO,CAAC,CACR,SAAS,CAAC,CACV,SACC,wOACF;GACF,QAAQ,EACL,QAAQ,CAAC,CACT,SAAS,CAAC,CACV,SACC,kHACF;GACF,SAAS,uBACN,SAAS,CAAC,CACV,SAAS,qCAAqC;GACjD,QAAQ,uBACL,SAAS,CAAC,CACV,SAAS,oCAAoC;EAClD,CAAC;EACD,SAAS,EACP,OACA,SACA,YACA,QACA,SACA,QACA,WACA,eACI;GACJ,MAAM,OAAO,SAAS,SAAS;GAC/B,MAAM,SACJ,WAAW,SACT,qBAAC,UAAD;IAAQ,YAAS;IAAjB,UAAA,CACG,UACC,oBAAC,UAAD;KACE,MAAM,SAAS,WAAW;KAC1B,YAAS;KACT,SACE,SAAS,KAAA,UAAkB,KAAK,Q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D,IAAI,eAAe,KAAA,GAAW,MAAM,aAAa;GACjD,IAAI,WAAW,QAAQ,MAAM,eAAe;QACvC,IAAI,OAAO,WAAW,UAAU,MAAM,eAAe,GAAG,OAAO;GAEpE,OACE,oBAAC,OAAD;IACE,YAAS;IACT,mBAAiB,WAAW,SAAS,SAAS,KAAA;IACvC;IAEN;GACE,CAAA;EAET;CACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@assistant-ui/react-generative-ui",
3
- "version": "0.0.12",
3
+ "version": "0.0.14",
4
4
  "description": "Generative UI components for assistant-ui",
5
5
  "keywords": [
6
6
  "generative-ui",
@@ -50,7 +50,7 @@
50
50
  ],
51
51
  "sideEffects": false,
52
52
  "dependencies": {
53
- "assistant-stream": "^0.3.34"
53
+ "assistant-stream": "^0.3.37"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "@assistant-ui/react": "^0.15.0",
@@ -65,13 +65,13 @@
65
65
  },
66
66
  "devDependencies": {
67
67
  "@types/json-schema": "^7.0.15",
68
- "@types/react": "^19.2.17",
68
+ "@types/react": "^19.2.18",
69
69
  "react": "^19.2.8",
70
70
  "react-dom": "^19.2.8",
71
71
  "vitest": "^4.1.10",
72
72
  "zod": "^4.4.3",
73
- "@assistant-ui/react": "0.15.5",
74
- "@assistant-ui/x-buildutils": "0.0.21"
73
+ "@assistant-ui/react": "0.15.14",
74
+ "@assistant-ui/x-buildutils": "0.0.22"
75
75
  },
76
76
  "publishConfig": {
77
77
  "access": "public",