@assistant-ui/react-generative-ui 0.0.21 → 0.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/dist/JSONGenerativeUI.client.d.ts.map +1 -1
- package/dist/JSONGenerativeUI.client.js +30 -13
- package/dist/JSONGenerativeUI.client.js.map +1 -1
- package/dist/RadioGroupScope.d.ts +6 -0
- package/dist/RadioGroupScope.d.ts.map +1 -0
- package/dist/RadioGroupScope.js +25 -0
- package/dist/RadioGroupScope.js.map +1 -0
- package/dist/a2ui/BindingContext.d.ts +11 -0
- package/dist/a2ui/BindingContext.d.ts.map +1 -0
- package/dist/a2ui/BindingContext.js +12 -0
- package/dist/a2ui/BindingContext.js.map +1 -0
- package/dist/a2ui/PresentRenderer.d.ts +11 -0
- package/dist/a2ui/PresentRenderer.d.ts.map +1 -0
- package/dist/a2ui/PresentRenderer.js +39 -0
- package/dist/a2ui/PresentRenderer.js.map +1 -0
- package/dist/a2ui/convert.d.ts +6 -0
- package/dist/a2ui/convert.d.ts.map +1 -1
- package/dist/a2ui/convert.js +363 -85
- package/dist/a2ui/convert.js.map +1 -1
- package/dist/a2ui/dataModel.d.ts +9 -0
- package/dist/a2ui/dataModel.d.ts.map +1 -0
- package/dist/a2ui/dataModel.js +44 -0
- package/dist/a2ui/dataModel.js.map +1 -0
- package/dist/a2ui/reducer.d.ts +5 -0
- package/dist/a2ui/reducer.d.ts.map +1 -1
- package/dist/a2ui/reducer.js +3 -3
- package/dist/a2ui/reducer.js.map +1 -1
- package/dist/a2ui/types.d.ts +8 -2
- package/dist/a2ui/types.d.ts.map +1 -1
- package/dist/a2ui/types.js.map +1 -1
- package/dist/a2ui/valueFunctions.d.ts +16 -0
- package/dist/a2ui/valueFunctions.d.ts.map +1 -0
- package/dist/a2ui/valueFunctions.js +332 -0
- package/dist/a2ui/valueFunctions.js.map +1 -0
- package/dist/actionRegistry.d.ts +1 -1
- package/dist/actionRegistry.js.map +1 -1
- package/dist/answeredValues.d.ts +16 -0
- package/dist/answeredValues.d.ts.map +1 -0
- package/dist/answeredValues.js +37 -0
- package/dist/answeredValues.js.map +1 -0
- package/dist/constants.d.ts +3 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +4 -1
- package/dist/constants.js.map +1 -1
- package/dist/fieldReferences.d.ts +9 -0
- package/dist/fieldReferences.d.ts.map +1 -0
- package/dist/fieldReferences.js +53 -0
- package/dist/fieldReferences.js.map +1 -0
- package/dist/generativeUIToJSX.js +3 -3
- package/dist/generativeUIToJSX.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.server.js +2 -2
- package/dist/index.shared.js +2 -2
- package/dist/ir.d.ts +1 -1
- package/dist/ir.js.map +1 -1
- package/dist/renderGenerativeUI.d.ts.map +1 -1
- package/dist/renderGenerativeUI.js +12 -1
- package/dist/renderGenerativeUI.js.map +1 -1
- package/dist/slack/constants.d.ts +2 -0
- package/dist/slack/constants.d.ts.map +1 -1
- package/dist/slack/constants.js +3 -1
- package/dist/slack/constants.js.map +1 -1
- package/dist/slack/decodeBlockAction.d.ts +3 -1
- package/dist/slack/decodeBlockAction.d.ts.map +1 -1
- package/dist/slack/decodeBlockAction.js +96 -7
- package/dist/slack/decodeBlockAction.js.map +1 -1
- package/dist/slack/fromSlackBlocks.d.ts.map +1 -1
- package/dist/slack/fromSlackBlocks.js +43 -3
- package/dist/slack/fromSlackBlocks.js.map +1 -1
- package/dist/slack/toSlackBlocks.d.ts.map +1 -1
- package/dist/slack/toSlackBlocks.js +244 -20
- package/dist/slack/toSlackBlocks.js.map +1 -1
- package/dist/slack/types.d.ts +24 -1
- package/dist/slack/types.d.ts.map +1 -1
- package/dist/slack.d.ts +1 -1
- package/dist/slack.d.ts.map +1 -1
- package/dist/teams/constants.d.ts +1 -1
- package/dist/teams/constants.d.ts.map +1 -1
- package/dist/teams/constants.js +1 -1
- package/dist/teams/constants.js.map +1 -1
- package/dist/teams/decodeSubmitData.d.ts +4 -0
- package/dist/teams/decodeSubmitData.d.ts.map +1 -1
- package/dist/teams/decodeSubmitData.js +29 -3
- package/dist/teams/decodeSubmitData.js.map +1 -1
- package/dist/teams/temporalId.d.ts +5 -0
- package/dist/teams/temporalId.d.ts.map +1 -0
- package/dist/teams/temporalId.js +28 -0
- package/dist/teams/temporalId.js.map +1 -0
- package/dist/teams/toAdaptiveCard.d.ts +5 -4
- package/dist/teams/toAdaptiveCard.d.ts.map +1 -1
- package/dist/teams/toAdaptiveCard.js +136 -18
- package/dist/teams/toAdaptiveCard.js.map +1 -1
- package/dist/teams/toTeamsAttachments.d.ts.map +1 -1
- package/dist/teams/toTeamsAttachments.js.map +1 -1
- package/dist/teams/types.d.ts +23 -2
- package/dist/teams/types.d.ts.map +1 -1
- package/dist/teams.d.ts +1 -1
- package/dist/teams.d.ts.map +1 -1
- package/dist/temporal.d.ts +33 -0
- package/dist/temporal.d.ts.map +1 -0
- package/dist/temporal.js +152 -0
- package/dist/temporal.js.map +1 -0
- package/dist/vocabulary/alert.d.ts +9 -2
- package/dist/vocabulary/alert.d.ts.map +1 -1
- package/dist/vocabulary/alert.js +116 -19
- package/dist/vocabulary/alert.js.map +1 -1
- package/dist/vocabulary/collectFormValues.d.ts +2 -1
- package/dist/vocabulary/collectFormValues.d.ts.map +1 -1
- package/dist/vocabulary/collectFormValues.js +15 -4
- package/dist/vocabulary/collectFormValues.js.map +1 -1
- package/dist/vocabulary/data.d.ts +22 -5
- package/dist/vocabulary/data.d.ts.map +1 -1
- package/dist/vocabulary/data.js +278 -83
- package/dist/vocabulary/data.js.map +1 -1
- package/dist/vocabulary/dispatch.d.ts +3 -2
- package/dist/vocabulary/dispatch.d.ts.map +1 -1
- package/dist/vocabulary/dispatch.js +33 -4
- package/dist/vocabulary/dispatch.js.map +1 -1
- package/dist/vocabulary/fact.d.ts +8 -1
- package/dist/vocabulary/fact.d.ts.map +1 -1
- package/dist/vocabulary/fact.js +37 -11
- package/dist/vocabulary/fact.js.map +1 -1
- package/dist/vocabulary/form.d.ts.map +1 -1
- package/dist/vocabulary/form.js +3 -3
- package/dist/vocabulary/form.js.map +1 -1
- package/dist/vocabulary/formatValue.d.ts +7 -0
- package/dist/vocabulary/formatValue.d.ts.map +1 -0
- package/dist/vocabulary/formatValue.js +76 -0
- package/dist/vocabulary/formatValue.js.map +1 -0
- package/dist/vocabulary/icon.d.ts +1 -1
- package/dist/vocabulary/interactive.d.ts +143 -8
- package/dist/vocabulary/interactive.d.ts.map +1 -1
- package/dist/vocabulary/interactive.js +458 -107
- package/dist/vocabulary/interactive.js.map +1 -1
- package/dist/vocabulary/layout.d.ts.map +1 -1
- package/dist/vocabulary/layout.js +4 -4
- package/dist/vocabulary/layout.js.map +1 -1
- package/dist/vocabulary/list.js +2 -2
- package/dist/vocabulary/list.js.map +1 -1
- package/dist/vocabulary/text.d.ts +1 -1
- package/package.json +8 -5
- package/src/JSONGenerativeUI.client.tsx +84 -40
- package/src/JSONGenerativeUI.test.tsx +964 -68
- package/src/RadioGroupScope.server.test.tsx +24 -0
- package/src/RadioGroupScope.tsx +34 -0
- package/src/a2ui/BindingContext.ts +26 -0
- package/src/a2ui/PresentRenderer.tsx +83 -0
- package/src/a2ui/convert.test.ts +2054 -229
- package/src/a2ui/convert.ts +665 -134
- package/src/a2ui/dataModel.ts +69 -0
- package/src/a2ui/reducer.test.ts +35 -0
- package/src/a2ui/reducer.ts +5 -4
- package/src/a2ui/types.ts +9 -2
- package/src/a2ui/valueFunctions.test.ts +271 -0
- package/src/a2ui/valueFunctions.ts +523 -0
- package/src/actionRegistry.ts +1 -1
- package/src/answeredValues.test.ts +33 -0
- package/src/answeredValues.tsx +70 -0
- package/src/constants.ts +5 -0
- package/src/fieldReferences.test.ts +66 -0
- package/src/fieldReferences.ts +83 -0
- package/src/generativeUIToJSX.test.ts +18 -0
- package/src/generativeUIToJSX.ts +4 -6
- package/src/index.server.test.ts +106 -0
- package/src/ir.ts +1 -1
- package/src/renderGenerativeUI.test.tsx +14 -5
- package/src/renderGenerativeUI.tsx +30 -1
- package/src/slack/a2uiSlack.test.ts +198 -0
- package/src/slack/constants.ts +3 -0
- package/src/slack/datePicker.test.ts +612 -0
- package/src/slack/decodeBlockAction.test.ts +98 -0
- package/src/slack/decodeBlockAction.ts +182 -16
- package/src/slack/fromSlackBlocks.test.ts +222 -3
- package/src/slack/fromSlackBlocks.ts +82 -2
- package/src/slack/toSlackBlocks.test.ts +682 -3
- package/src/slack/toSlackBlocks.ts +463 -25
- package/src/slack/types.ts +28 -0
- package/src/slack.ts +2 -0
- package/src/teams/constants.ts +1 -1
- package/src/teams/decodeSubmitData.test.ts +249 -0
- package/src/teams/decodeSubmitData.ts +57 -4
- package/src/teams/temporal.test.ts +766 -0
- package/src/teams/temporalId.ts +56 -0
- package/src/teams/toAdaptiveCard.test.ts +219 -0
- package/src/teams/toAdaptiveCard.ts +259 -21
- package/src/teams/toTeamsAttachments.ts +4 -1
- package/src/teams/types.ts +21 -1
- package/src/teams.ts +1 -0
- package/src/temporal.test.ts +319 -0
- package/src/temporal.ts +259 -0
- package/src/vocabulary/alert.test.tsx +288 -7
- package/src/vocabulary/alert.tsx +168 -26
- package/src/vocabulary/collectFormValues.test.ts +225 -1
- package/src/vocabulary/collectFormValues.ts +54 -5
- package/src/vocabulary/data.test.tsx +248 -6
- package/src/vocabulary/data.tsx +398 -100
- package/src/vocabulary/datepicker.dom.test.tsx +1148 -0
- package/src/vocabulary/dispatch.ts +63 -2
- package/src/vocabulary/fact.test.tsx +67 -0
- package/src/vocabulary/fact.tsx +40 -9
- package/src/vocabulary/form.tsx +7 -2
- package/src/vocabulary/formatValue.test.ts +72 -0
- package/src/vocabulary/formatValue.ts +127 -0
- package/src/vocabulary/index.test.ts +2 -0
- package/src/vocabulary/interactive.dispatch.test.tsx +167 -79
- package/src/vocabulary/interactive.dom.test.tsx +1747 -0
- package/src/vocabulary/interactive.test.tsx +60 -4
- package/src/vocabulary/interactive.tsx +910 -155
- package/src/vocabulary/layout.test.tsx +6 -4
- package/src/vocabulary/layout.tsx +13 -2
- package/src/vocabulary/list.tsx +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"temporalId.d.ts","sourceRoot":"","sources":["../../src/teams/temporalId.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAgB;AAElD,eAAO,MAAM,qBAAqB,kBAAkB,CAAC;AAkBrD,eAAO,MAAM,qBAAqB,GAAI,OAAO,kBAAkB,KAAG,MAC0F,CAAC;AAE7J,eAAO,MAAM,qBAAqB,GAChC,IAAI,MAAM,KACT,kBAAkB,GAAG,SA6BvB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { classifyTemporal } from "../temporal.js";
|
|
2
|
+
//#region src/teams/temporalId.ts
|
|
3
|
+
const TEMPORAL_INPUT_PREFIX = "aui:datetime:";
|
|
4
|
+
const encodeFieldId = (value) => Array.from(value, (char) => /^[\uD800-\uDFFF]$/.test(char) ? `%u${char.charCodeAt(0).toString(16).toUpperCase()}` : encodeURIComponent(char)).join("");
|
|
5
|
+
const decodeFieldId = (value) => value.split(/(%uD[89A-F][0-9A-F]{2})/).map((part, index) => index % 2 === 0 ? decodeURIComponent(part) : String.fromCharCode(Number.parseInt(part.slice(2), 16))).join("");
|
|
6
|
+
const encodeTemporalInputId = (field) => `${TEMPORAL_INPUT_PREFIX}${field.role}:${encodeFieldId(field.fieldId)}${field.role === "time" ? `:${encodeURIComponent(field.previousValue ?? "")}` : ""}`;
|
|
7
|
+
const decodeTemporalInputId = (id) => {
|
|
8
|
+
try {
|
|
9
|
+
const parts = id.slice(13).split(":");
|
|
10
|
+
const role = parts[0];
|
|
11
|
+
if (!id.startsWith("aui:datetime:") || role !== "date" && role !== "time" || parts.length !== (role === "date" ? 2 : 3)) return void 0;
|
|
12
|
+
const fieldId = decodeFieldId(parts[1]);
|
|
13
|
+
const previousValue = role === "time" ? decodeURIComponent(parts[2]) : "";
|
|
14
|
+
if (!fieldId || fieldId === "aui" || fieldId.startsWith("aui:datetime:") || previousValue !== "" && classifyTemporal(previousValue).kind !== "instant") return void 0;
|
|
15
|
+
const metadata = {
|
|
16
|
+
fieldId,
|
|
17
|
+
role,
|
|
18
|
+
...previousValue ? { previousValue } : {}
|
|
19
|
+
};
|
|
20
|
+
return encodeTemporalInputId(metadata) === id ? metadata : void 0;
|
|
21
|
+
} catch {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
26
|
+
export { TEMPORAL_INPUT_PREFIX, decodeTemporalInputId, encodeTemporalInputId };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=temporalId.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"temporalId.js","names":[],"sources":["../../src/teams/temporalId.ts"],"sourcesContent":["import { classifyTemporal } from \"../temporal\";\nimport type { TeamsTemporalField } from \"./types\";\n\nexport const TEMPORAL_INPUT_PREFIX = \"aui:datetime:\";\nconst encodeFieldId = (value: string): string =>\n Array.from(value, (char) =>\n /^[\\uD800-\\uDFFF]$/.test(char)\n ? `%u${char.charCodeAt(0).toString(16).toUpperCase()}`\n : encodeURIComponent(char),\n ).join(\"\");\n\nconst decodeFieldId = (value: string): string =>\n value\n .split(/(%uD[89A-F][0-9A-F]{2})/)\n .map((part, index) =>\n index % 2 === 0\n ? decodeURIComponent(part)\n : String.fromCharCode(Number.parseInt(part.slice(2), 16)),\n )\n .join(\"\");\n\nexport const encodeTemporalInputId = (field: TeamsTemporalField): string =>\n `${TEMPORAL_INPUT_PREFIX}${field.role}:${encodeFieldId(field.fieldId)}${field.role === \"time\" ? `:${encodeURIComponent(field.previousValue ?? \"\")}` : \"\"}`;\n\nexport const decodeTemporalInputId = (\n id: string,\n): TeamsTemporalField | undefined => {\n try {\n const parts = id.slice(TEMPORAL_INPUT_PREFIX.length).split(\":\");\n const role = parts[0];\n if (\n !id.startsWith(TEMPORAL_INPUT_PREFIX) ||\n (role !== \"date\" && role !== \"time\") ||\n parts.length !== (role === \"date\" ? 2 : 3)\n )\n return undefined;\n const fieldId = decodeFieldId(parts[1]!);\n const previousValue = role === \"time\" ? decodeURIComponent(parts[2]!) : \"\";\n if (\n !fieldId ||\n fieldId === \"aui\" ||\n fieldId.startsWith(TEMPORAL_INPUT_PREFIX) ||\n (previousValue !== \"\" &&\n classifyTemporal(previousValue).kind !== \"instant\")\n )\n return undefined;\n const metadata: TeamsTemporalField = {\n fieldId,\n role,\n ...(previousValue ? { previousValue } : {}),\n };\n return encodeTemporalInputId(metadata) === id ? metadata : undefined;\n } catch {\n return undefined;\n }\n};\n"],"mappings":";;AAGA,MAAa,wBAAwB;AACrC,MAAM,iBAAiB,UACrB,MAAM,KAAK,QAAQ,SACjB,oBAAoB,KAAK,IAAI,IACzB,KAAK,KAAK,WAAW,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,YAAY,MACjD,mBAAmB,IAAI,CAC7B,CAAC,CAAC,KAAK,EAAE;AAEX,MAAM,iBAAiB,UACrB,MACG,MAAM,yBAAyB,CAAC,CAChC,KAAK,MAAM,UACV,QAAQ,MAAM,IACV,mBAAmB,IAAI,IACvB,OAAO,aAAa,OAAO,SAAS,KAAK,MAAM,CAAC,GAAG,EAAE,CAAC,CAC5D,CAAC,CACA,KAAK,EAAE;AAEZ,MAAa,yBAAyB,UACpC,GAAG,wBAAwB,MAAM,KAAK,GAAG,cAAc,MAAM,OAAO,IAAI,MAAM,SAAS,SAAS,IAAI,mBAAmB,MAAM,iBAAiB,EAAE,MAAM;AAExJ,MAAa,yBACX,OACmC;CACnC,IAAI;EACF,MAAM,QAAQ,GAAG,MAAM,EAA4B,CAAC,CAAC,MAAM,GAAG;EAC9D,MAAM,OAAO,MAAM;EACnB,IACE,CAAC,GAAG,WAAA,eAAgC,KACnC,SAAS,UAAU,SAAS,UAC7B,MAAM,YAAY,SAAS,SAAS,IAAI,IAExC,OAAO,KAAA;EACT,MAAM,UAAU,cAAc,MAAM,EAAG;EACvC,MAAM,gBAAgB,SAAS,SAAS,mBAAmB,MAAM,EAAG,IAAI;EACxE,IACE,CAAC,WACD,YAAY,SACZ,QAAQ,WAAA,eAAgC,KACvC,kBAAkB,MACjB,iBAAiB,aAAa,CAAC,CAAC,SAAS,WAE3C,OAAO,KAAA;EACT,MAAM,WAA+B;GACnC;GACA;GACA,GAAI,gBAAgB,EAAE,cAAc,IAAI,CAAC;EAC3C;EACA,OAAO,sBAAsB,QAAQ,MAAM,KAAK,WAAW,KAAA;CAC7D,QAAQ;EACN;CACF;AACF"}
|
|
@@ -35,10 +35,11 @@ export declare function convertRootToCard(root: NormalizedUINode | readonly Norm
|
|
|
35
35
|
* Converts a generative-ui tree into a Microsoft Teams Adaptive Card and
|
|
36
36
|
* non-fatal conversion warnings. Sizes, weights, and colors map to Adaptive
|
|
37
37
|
* Card's semantic enums rather than raw values. An Input/Select/RadioGroup/
|
|
38
|
-
* Checkbox/DatePicker whose id would be the reserved
|
|
39
|
-
* is renamed with a warning (see `decodeSubmitData`).
|
|
40
|
-
* unknown `$type` is skipped with a "dropped" warning, and a
|
|
41
|
-
* resolves to an empty card plus a "dropped" warning instead
|
|
38
|
+
* CheckboxGroup/Checkbox/Slider/DatePicker whose id would be the reserved
|
|
39
|
+
* {@link RESERVED_INPUT_ID} is renamed with a warning (see `decodeSubmitData`).
|
|
40
|
+
* Never throws: an unknown `$type` is skipped with a "dropped" warning, and a
|
|
41
|
+
* malformed input resolves to an empty card plus a "dropped" warning instead
|
|
42
|
+
* of throwing.
|
|
42
43
|
*/
|
|
43
44
|
export declare function toAdaptiveCard(node: unknown, _options?: ToAdaptiveCardOptions): AdaptiveCardResult;
|
|
44
45
|
//# sourceMappingURL=toAdaptiveCard.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toAdaptiveCard.d.ts","sourceRoot":"","sources":["../../src/teams/toAdaptiveCard.ts"],"names":[],"mappings":"AAQA,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACtB,iBAAc;
|
|
1
|
+
{"version":3,"file":"toAdaptiveCard.d.ts","sourceRoot":"","sources":["../../src/teams/toAdaptiveCard.ts"],"names":[],"mappings":"AAQA,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACtB,iBAAc;AAsBf,OAAO,KAAK,EACV,kBAAkB,EAElB,iBAAiB,EACjB,gBAAgB,EAIhB,sBAAsB,EAQtB,qBAAqB,EACtB,mBAAgB;AAEjB,iFAAiF;AACjF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,QAAQ,EAAE,sBAAsB,EAAE,CAAC;IAC5C,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC3B;AAwWD;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GACzB,OAAO,gBAAgB,EACvB,SAAS,iBAAiB,EAC1B,OAAO,MAAM,KACZ,OAUF,CAAC;AAEF,wBAAgB,cAAc,CAC5B,OAAO,EAAE,mBAAmB,EAC5B,OAAO,EAAE,iBAAiB,EAC1B,KAAK,EAAE,MAAM,GACZ,gBAAgB,EAAE,CAsdpB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,gBAAgB,GAAG,SAAS,EAClC,OAAO,EAAE,iBAAiB,EAC1B,KAAK,EAAE,MAAM,GACZ,gBAAgB,EAAE,CA6DpB;AAED,wHAAwH;AACxH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,gBAAgB,GAAG,SAAS,gBAAgB,EAAE,EACpD,OAAO,EAAE,iBAAiB,GACzB,iBAAiB,CAcnB;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,OAAO,EACb,QAAQ,CAAC,EAAE,qBAAqB,GAC/B,kBAAkB,CA0BpB"}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { normalizeSpec } from "../ir.js";
|
|
2
|
+
import { classifyTemporal, splitTemporalMinutes, temporalOffsetLabel } from "../temporal.js";
|
|
2
3
|
import { copyBounded } from "../convert/copyBounded.js";
|
|
3
4
|
import { boundSpec, clampReasonDetail } from "../convert/boundSpec.js";
|
|
4
5
|
import { isElement } from "../convert/isElement.js";
|
|
5
6
|
import { takeRun } from "../convert/takeRun.js";
|
|
7
|
+
import { factTrend, formatFactDelta, formatValue } from "../vocabulary/formatValue.js";
|
|
8
|
+
import { encodeTemporalInputId } from "./temporalId.js";
|
|
6
9
|
import { PAYLOAD_SOFT_CAP, buildCard, buildSubmitAction, utf8ByteLength } from "./constants.js";
|
|
7
10
|
//#region src/teams/toAdaptiveCard.ts
|
|
8
11
|
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9
12
|
const asString = (value) => typeof value === "string" ? value : "";
|
|
13
|
+
const asFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
10
14
|
const DATE_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
|
|
11
15
|
const SUBTLE_COLORS = /* @__PURE__ */ new Set([
|
|
12
16
|
"secondary",
|
|
@@ -46,7 +50,8 @@ const warn = (context, code, component, detail) => {
|
|
|
46
50
|
const RESERVED_INPUT_ID = "aui";
|
|
47
51
|
function reservedSafeId(id, component, context) {
|
|
48
52
|
const reserved = id === RESERVED_INPUT_ID;
|
|
49
|
-
const
|
|
53
|
+
const temporalReserved = /^_*aui:datetime:/.test(id);
|
|
54
|
+
const base = reserved ? `${RESERVED_INPUT_ID}_` : temporalReserved ? `_${id}` : id;
|
|
50
55
|
let candidate = base;
|
|
51
56
|
let n = 2;
|
|
52
57
|
while (context.usedInputIds.has(candidate)) {
|
|
@@ -54,6 +59,7 @@ function reservedSafeId(id, component, context) {
|
|
|
54
59
|
n += 1;
|
|
55
60
|
}
|
|
56
61
|
if (reserved) warn(context, "fallback", component, `the input id "${RESERVED_INPUT_ID}" collides with the submit envelope's reserved key and was renamed to "${candidate}".`);
|
|
62
|
+
else if (temporalReserved) warn(context, "fallback", component, `the input id "${id}" collides with the reserved datetime namespace and was renamed to "${candidate}".`);
|
|
57
63
|
else if (candidate !== base) warn(context, "fallback", component, `the input id "${base}" was already used on this card and was renamed to "${candidate}".`);
|
|
58
64
|
context.usedInputIds.add(candidate);
|
|
59
65
|
return candidate;
|
|
@@ -93,8 +99,10 @@ function applyPending(element, separator, spacing) {
|
|
|
93
99
|
}
|
|
94
100
|
const toChoice = (option) => {
|
|
95
101
|
if (!isRecord(option) || typeof option["value"] !== "string") return;
|
|
102
|
+
const label = asString(option["label"]);
|
|
103
|
+
const description = asString(option["description"]);
|
|
96
104
|
return {
|
|
97
|
-
title:
|
|
105
|
+
title: description ? [label, description].filter(Boolean).join(": ") : label,
|
|
98
106
|
value: option["value"]
|
|
99
107
|
};
|
|
100
108
|
};
|
|
@@ -113,10 +121,15 @@ const choicesFrom = (optionsProp, component, context) => {
|
|
|
113
121
|
function convertFacts(facts) {
|
|
114
122
|
return {
|
|
115
123
|
type: "FactSet",
|
|
116
|
-
facts: facts.map((fact) =>
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
124
|
+
facts: facts.map((fact) => {
|
|
125
|
+
const value = asString(fact.props["value"]);
|
|
126
|
+
const delta = fact.props["delta"];
|
|
127
|
+
const deltaText = typeof delta === "string" ? formatFactDelta(delta, factTrend(delta, fact.props["trend"])) : void 0;
|
|
128
|
+
return {
|
|
129
|
+
title: asString(fact.props["label"]),
|
|
130
|
+
value: deltaText === void 0 ? value : `${value} (${deltaText})`
|
|
131
|
+
};
|
|
132
|
+
})
|
|
120
133
|
};
|
|
121
134
|
}
|
|
122
135
|
function convertButtons(buttons, context) {
|
|
@@ -147,11 +160,6 @@ const ALERT_STYLE_MAP = {
|
|
|
147
160
|
warning: "warning",
|
|
148
161
|
danger: "attention"
|
|
149
162
|
};
|
|
150
|
-
const stringifyCell = (value) => {
|
|
151
|
-
if (typeof value === "string") return value;
|
|
152
|
-
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
153
|
-
return "";
|
|
154
|
-
};
|
|
155
163
|
function convertTable(props, context) {
|
|
156
164
|
const { items: rawColumns, truncated: columnsTruncated } = clampArray(props["columns"], 20);
|
|
157
165
|
const { items: rawRows, truncated: rowsTruncated } = clampArray(props["rows"], 100);
|
|
@@ -170,9 +178,9 @@ function convertTable(props, context) {
|
|
|
170
178
|
} : void 0;
|
|
171
179
|
const dataRows = rawRows.map((row) => ({
|
|
172
180
|
type: "TableRow",
|
|
173
|
-
cells: (Array.isArray(row) ? copyBounded(row, 20).items : []).map((cell) => ({
|
|
181
|
+
cells: (Array.isArray(row) ? copyBounded(row, 20).items : []).map((cell, index) => ({
|
|
174
182
|
type: "TableCell",
|
|
175
|
-
items: [textBlock(
|
|
183
|
+
items: [textBlock(formatValue(cell, isRecord(rawColumns[index]) ? rawColumns[index]["format"] : void 0))]
|
|
176
184
|
}))
|
|
177
185
|
}));
|
|
178
186
|
return {
|
|
@@ -257,11 +265,13 @@ function convertElement(element, context, depth) {
|
|
|
257
265
|
const name = asString(props["name"]);
|
|
258
266
|
const placeholder = asString(props["placeholder"]);
|
|
259
267
|
const label = asString(props["label"]);
|
|
268
|
+
const defaultValue = props["defaultValue"];
|
|
260
269
|
return withCompanionSubmit(element, {
|
|
261
270
|
type: "Input.ChoiceSet",
|
|
262
271
|
id: reservedSafeId(name || "select", "Select", context),
|
|
263
272
|
style: "compact",
|
|
264
273
|
choices: choicesFrom(props["options"], "Select", context),
|
|
274
|
+
...typeof defaultValue === "string" && defaultValue ? { value: defaultValue } : {},
|
|
265
275
|
...placeholder ? { placeholder } : {},
|
|
266
276
|
...label ? { label } : {}
|
|
267
277
|
}, context);
|
|
@@ -279,6 +289,20 @@ function convertElement(element, context, depth) {
|
|
|
279
289
|
...label ? { label } : {}
|
|
280
290
|
}, context);
|
|
281
291
|
}
|
|
292
|
+
case "CheckboxGroup": {
|
|
293
|
+
const name = asString(props["name"]);
|
|
294
|
+
const label = asString(props["label"]);
|
|
295
|
+
const checked = Array.isArray(props["defaultValue"]) ? props["defaultValue"].filter((value) => typeof value === "string" && value !== "") : [];
|
|
296
|
+
return withCompanionSubmit(element, {
|
|
297
|
+
type: "Input.ChoiceSet",
|
|
298
|
+
id: reservedSafeId(name || "checkboxgroup", "CheckboxGroup", context),
|
|
299
|
+
style: "expanded",
|
|
300
|
+
isMultiSelect: true,
|
|
301
|
+
choices: choicesFrom(props["options"], "CheckboxGroup", context),
|
|
302
|
+
...checked.length > 0 ? { value: checked.join(",") } : {},
|
|
303
|
+
...label ? { label } : {}
|
|
304
|
+
}, context);
|
|
305
|
+
}
|
|
282
306
|
case "Checkbox": {
|
|
283
307
|
const name = asString(props["name"]);
|
|
284
308
|
const label = asString(props["label"]);
|
|
@@ -291,21 +315,114 @@ function convertElement(element, context, depth) {
|
|
|
291
315
|
valueOff: "false"
|
|
292
316
|
}, context);
|
|
293
317
|
}
|
|
318
|
+
case "Slider": {
|
|
319
|
+
const name = asString(props["name"]);
|
|
320
|
+
const label = asString(props["label"]);
|
|
321
|
+
const min = asFiniteNumber(props["min"]);
|
|
322
|
+
const max = asFiniteNumber(props["max"]);
|
|
323
|
+
const defaultValue = asFiniteNumber(props["defaultValue"]);
|
|
324
|
+
return withCompanionSubmit(element, {
|
|
325
|
+
type: "Input.Number",
|
|
326
|
+
id: reservedSafeId(name || "slider", "Slider", context),
|
|
327
|
+
...label ? { label } : {},
|
|
328
|
+
...min !== void 0 ? { min } : {},
|
|
329
|
+
...max !== void 0 ? { max } : {},
|
|
330
|
+
...defaultValue !== void 0 ? { value: defaultValue } : {}
|
|
331
|
+
}, context);
|
|
332
|
+
}
|
|
294
333
|
case "Input": {
|
|
295
334
|
const name = asString(props["name"]);
|
|
296
335
|
const label = asString(props["label"]);
|
|
297
336
|
const placeholder = asString(props["placeholder"]);
|
|
337
|
+
const defaultValue = props["defaultValue"];
|
|
298
338
|
return withCompanionSubmit(element, {
|
|
299
339
|
type: "Input.Text",
|
|
300
340
|
id: reservedSafeId(name || "input", "Input", context),
|
|
341
|
+
...props["inputType"] === "password" ? { style: "password" } : {},
|
|
301
342
|
...label ? { label } : {},
|
|
302
343
|
...placeholder ? { placeholder } : {},
|
|
303
|
-
...
|
|
344
|
+
...typeof defaultValue === "string" && defaultValue ? { value: defaultValue } : {},
|
|
345
|
+
...props["multiline"] === true && (props["inputType"] === void 0 || props["inputType"] === "text") ? { isMultiline: true } : {}
|
|
304
346
|
}, context);
|
|
305
347
|
}
|
|
306
348
|
case "DatePicker": {
|
|
307
349
|
const name = asString(props["name"]);
|
|
308
350
|
const label = asString(props["label"]);
|
|
351
|
+
const mode = props["inputType"];
|
|
352
|
+
if (mode === "time") {
|
|
353
|
+
const id = reservedSafeId(name || "datepicker", "DatePicker", context);
|
|
354
|
+
const rawValue = asString(props["value"]);
|
|
355
|
+
const parts = splitTemporalMinutes(rawValue);
|
|
356
|
+
if (classifyTemporal(rawValue).kind === "time" && parts?.droppedPrecision) warn(context, "dropped", "DatePicker", "Nonzero seconds were dropped from the time value.");
|
|
357
|
+
const value = parts?.time;
|
|
358
|
+
const rawMin = asString(props["min"]);
|
|
359
|
+
const minParts = splitTemporalMinutes(rawMin);
|
|
360
|
+
let min = minParts?.time;
|
|
361
|
+
if (classifyTemporal(rawMin).kind === "time" && minParts?.droppedPrecision) {
|
|
362
|
+
const minuteOfDay = Number(minParts.time.slice(0, 2)) * 60 + Number(minParts.time.slice(3, 5)) + 1;
|
|
363
|
+
if (minuteOfDay === 1440) {
|
|
364
|
+
min = void 0;
|
|
365
|
+
warn(context, "dropped", "DatePicker", "The time minimum rounds past 23:59 and was dropped.");
|
|
366
|
+
} else min = `${String(Math.floor(minuteOfDay / 60)).padStart(2, "0")}:${String(minuteOfDay % 60).padStart(2, "0")}`;
|
|
367
|
+
}
|
|
368
|
+
const rawMax = asString(props["max"]);
|
|
369
|
+
const maxParts = splitTemporalMinutes(rawMax);
|
|
370
|
+
const max = maxParts?.time;
|
|
371
|
+
if (classifyTemporal(rawMax).kind === "time" && maxParts?.droppedPrecision) warn(context, "dropped", "DatePicker", rawMax.slice(6, 8) === "00" ? "Nonzero fractional seconds were dropped from the time maximum." : /\.\d*[1-9]/.test(rawMax) ? "Nonzero seconds and fractional seconds were dropped from the time maximum." : "Nonzero seconds were dropped from the time maximum.");
|
|
372
|
+
return withCompanionSubmit(element, {
|
|
373
|
+
type: "Input.Time",
|
|
374
|
+
id,
|
|
375
|
+
...label ? { label } : {},
|
|
376
|
+
...classifyTemporal(rawValue).kind === "time" && value !== void 0 ? { value } : {},
|
|
377
|
+
...classifyTemporal(rawMin).kind === "time" && min !== void 0 ? { min } : {},
|
|
378
|
+
...classifyTemporal(rawMax).kind === "time" && max !== void 0 ? { max } : {}
|
|
379
|
+
}, context);
|
|
380
|
+
}
|
|
381
|
+
if (mode === "datetime") {
|
|
382
|
+
const rawValue = asString(props["value"]);
|
|
383
|
+
const temporal = classifyTemporal(rawValue);
|
|
384
|
+
const fieldId = reservedSafeId(name || "datepicker", "DatePicker", context);
|
|
385
|
+
const dateId = encodeTemporalInputId({
|
|
386
|
+
fieldId,
|
|
387
|
+
role: "date"
|
|
388
|
+
});
|
|
389
|
+
const timeId = encodeTemporalInputId({
|
|
390
|
+
fieldId,
|
|
391
|
+
role: "time",
|
|
392
|
+
...temporal.kind === "instant" ? { previousValue: rawValue } : {}
|
|
393
|
+
});
|
|
394
|
+
const parts = splitTemporalMinutes(rawValue);
|
|
395
|
+
if (temporal.kind === "floating" && parts?.droppedPrecision) warn(context, "dropped", "DatePicker", "Nonzero seconds were dropped from the datetime value.");
|
|
396
|
+
const offsetLabel = temporalOffsetLabel(rawValue);
|
|
397
|
+
const boundDate = (raw) => {
|
|
398
|
+
const value = asString(raw);
|
|
399
|
+
return classifyTemporal(value).kind === "date" ? value : splitTemporalMinutes(value, temporal.kind === "instant" ? temporal.offset : void 0)?.date;
|
|
400
|
+
};
|
|
401
|
+
const min = boundDate(props["min"]);
|
|
402
|
+
const max = boundDate(props["max"]);
|
|
403
|
+
const dateInput = {
|
|
404
|
+
type: "Input.Date",
|
|
405
|
+
id: dateId,
|
|
406
|
+
...label ? { label } : {},
|
|
407
|
+
...parts?.date !== void 0 ? { value: parts.date } : {},
|
|
408
|
+
...min !== void 0 ? { min } : {},
|
|
409
|
+
...max !== void 0 ? { max } : {}
|
|
410
|
+
};
|
|
411
|
+
const timeInput = {
|
|
412
|
+
type: "Input.Time",
|
|
413
|
+
id: timeId,
|
|
414
|
+
...label || offsetLabel ? { label: `${label ? `${label} time` : "Time"}${offsetLabel ? ` (${offsetLabel})` : ""}` } : {},
|
|
415
|
+
...parts?.time !== void 0 ? { value: parts.time } : {}
|
|
416
|
+
};
|
|
417
|
+
if (element.action === void 0) return [dateInput, timeInput];
|
|
418
|
+
const [input, submit] = withCompanionSubmit(element, timeInput, context);
|
|
419
|
+
return [
|
|
420
|
+
dateInput,
|
|
421
|
+
input,
|
|
422
|
+
submit
|
|
423
|
+
];
|
|
424
|
+
}
|
|
425
|
+
if (mode !== void 0 && mode !== "date") warn(context, "dropped", "DatePicker", "Unsupported inputType was dropped; the picker was rendered as a date input.");
|
|
309
426
|
const rawValue = props["value"];
|
|
310
427
|
const value = typeof rawValue === "string" && DATE_PATTERN.test(rawValue) ? rawValue : void 0;
|
|
311
428
|
const rawMin = props["min"];
|
|
@@ -490,10 +607,11 @@ function convertRootToCard(root, context) {
|
|
|
490
607
|
* Converts a generative-ui tree into a Microsoft Teams Adaptive Card and
|
|
491
608
|
* non-fatal conversion warnings. Sizes, weights, and colors map to Adaptive
|
|
492
609
|
* Card's semantic enums rather than raw values. An Input/Select/RadioGroup/
|
|
493
|
-
* Checkbox/DatePicker whose id would be the reserved
|
|
494
|
-
* is renamed with a warning (see `decodeSubmitData`).
|
|
495
|
-
* unknown `$type` is skipped with a "dropped" warning, and a
|
|
496
|
-
* resolves to an empty card plus a "dropped" warning instead
|
|
610
|
+
* CheckboxGroup/Checkbox/Slider/DatePicker whose id would be the reserved
|
|
611
|
+
* {@link RESERVED_INPUT_ID} is renamed with a warning (see `decodeSubmitData`).
|
|
612
|
+
* Never throws: an unknown `$type` is skipped with a "dropped" warning, and a
|
|
613
|
+
* malformed input resolves to an empty card plus a "dropped" warning instead
|
|
614
|
+
* of throwing.
|
|
497
615
|
*/
|
|
498
616
|
function toAdaptiveCard(node, _options) {
|
|
499
617
|
const context = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toAdaptiveCard.js","names":[],"sources":["../../src/teams/toAdaptiveCard.ts"],"sourcesContent":["import {\n MAX_TRAVERSAL_DEPTH,\n boundSpec,\n clampReasonDetail,\n} from \"../convert/boundSpec\";\nimport { copyBounded } from \"../convert/copyBounded\";\nimport { isElement } from \"../convert/isElement\";\nimport { takeRun } from \"../convert/takeRun\";\nimport {\n normalizeSpec,\n type NormalizedUIElement,\n type NormalizedUINode,\n} from \"../ir\";\nimport {\n CHOICE_OPTION_CAP,\n PAYLOAD_SOFT_CAP,\n PRIMARY_ACTION_CAP,\n TABLE_COLUMN_CAP,\n TABLE_ROW_CAP,\n buildCard,\n buildSubmitAction,\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 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: copies `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 copyBounded(value, 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)\n ? copyBounded(row, TABLE_COLUMN_CAP).items\n : []\n ).map((cell) => ({\n type: \"TableCell\" as const,\n items: [textBlock(stringifyCell(cell))],\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\"] ?? \"info\";\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 { run: facts, next } = takeRun(\n nodes,\n index,\n (candidate) => candidate.type === \"Fact\",\n );\n index = next;\n emit([convertFacts(facts)]);\n continue;\n }\n if (isElement(current) && current.type === \"Button\") {\n const { run: buttons, next } = takeRun(\n nodes,\n index,\n (candidate) => candidate.type === \"Button\",\n );\n index = next;\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":";;;;;;;AAgDA,MAAM,YAAY,UAChB,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAErE,MAAM,YAAY,UAChB,OAAO,UAAU,WAAW,QAAQ;AAEtC,MAAM,eAAe;AAErB,MAAM,gCAAgB,IAAI,IAAI;CAC5B;CACA;CACA;CACA;CAC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AAO,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
|
+
{"version":3,"file":"toAdaptiveCard.js","names":[],"sources":["../../src/teams/toAdaptiveCard.ts"],"sourcesContent":["import {\n MAX_TRAVERSAL_DEPTH,\n boundSpec,\n clampReasonDetail,\n} from \"../convert/boundSpec\";\nimport { copyBounded } from \"../convert/copyBounded\";\nimport { isElement } from \"../convert/isElement\";\nimport { takeRun } from \"../convert/takeRun\";\nimport {\n normalizeSpec,\n type NormalizedUIElement,\n type NormalizedUINode,\n} from \"../ir\";\nimport {\n classifyTemporal,\n splitTemporalMinutes,\n temporalOffsetLabel,\n} from \"../temporal\";\nimport {\n factTrend,\n formatFactDelta,\n formatValue,\n} from \"../vocabulary/formatValue\";\nimport {\n CHOICE_OPTION_CAP,\n PAYLOAD_SOFT_CAP,\n PRIMARY_ACTION_CAP,\n TABLE_COLUMN_CAP,\n TABLE_ROW_CAP,\n buildCard,\n buildSubmitAction,\n utf8ByteLength,\n} from \"./constants\";\nimport { encodeTemporalInputId } from \"./temporalId\";\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 asString = (value: unknown): string =>\n typeof value === \"string\" ? value : \"\";\n\nconst asFiniteNumber = (value: unknown): number | undefined =>\n typeof value === \"number\" && Number.isFinite(value) ? value : undefined;\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 temporalReserved = /^_*aui:datetime:/.test(id);\n const base = reserved\n ? `${RESERVED_INPUT_ID}_`\n : temporalReserved\n ? `_${id}`\n : 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 (temporalReserved) {\n warn(\n context,\n \"fallback\",\n component,\n `the input id \"${id}\" collides with the reserved datetime namespace 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: copies `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 copyBounded(value, 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 const label = asString(option[\"label\"]);\n const description = asString(option[\"description\"]);\n return {\n title: description\n ? [label, description].filter(Boolean).join(\": \")\n : label,\n value: option[\"value\"],\n };\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 const value = asString(fact.props[\"value\"]);\n const delta = fact.props[\"delta\"];\n const deltaText =\n typeof delta === \"string\"\n ? formatFactDelta(delta, factTrend(delta, fact.props[\"trend\"]))\n : undefined;\n return {\n title: asString(fact.props[\"label\"]),\n value: deltaText === undefined ? value : `${value} (${deltaText})`,\n };\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\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)\n ? copyBounded(row, TABLE_COLUMN_CAP).items\n : []\n ).map((cell, index) => ({\n type: \"TableCell\" as const,\n items: [\n textBlock(\n formatValue(\n cell,\n isRecord(rawColumns[index])\n ? rawColumns[index][\"format\"]\n : undefined,\n ),\n ),\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 defaultValue = props[\"defaultValue\"];\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 ...(typeof defaultValue === \"string\" && defaultValue\n ? { value: defaultValue }\n : {}),\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 \"CheckboxGroup\": {\n const name = asString(props[\"name\"]);\n const label = asString(props[\"label\"]);\n const checked = Array.isArray(props[\"defaultValue\"])\n ? props[\"defaultValue\"].filter(\n (value): value is string =>\n typeof value === \"string\" && value !== \"\",\n )\n : [];\n const input: TeamsCardElement = {\n type: \"Input.ChoiceSet\",\n id: reservedSafeId(name || \"checkboxgroup\", \"CheckboxGroup\", context),\n style: \"expanded\",\n isMultiSelect: true,\n choices: choicesFrom(props[\"options\"], \"CheckboxGroup\", context),\n ...(checked.length > 0 ? { value: checked.join(\",\") } : {}),\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 \"Slider\": {\n const name = asString(props[\"name\"]);\n const label = asString(props[\"label\"]);\n const min = asFiniteNumber(props[\"min\"]);\n const max = asFiniteNumber(props[\"max\"]);\n const defaultValue = asFiniteNumber(props[\"defaultValue\"]);\n const input = {\n type: \"Input.Number\",\n id: reservedSafeId(name || \"slider\", \"Slider\", context),\n ...(label ? { label } : {}),\n ...(min !== undefined ? { min } : {}),\n ...(max !== undefined ? { max } : {}),\n ...(defaultValue !== undefined ? { value: defaultValue } : {}),\n } as unknown as TeamsCardElement;\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 defaultValue = props[\"defaultValue\"];\n const input: TeamsCardElement = {\n type: \"Input.Text\",\n id: reservedSafeId(name || \"input\", \"Input\", context),\n ...(props[\"inputType\"] === \"password\" ? { style: \"password\" } : {}),\n ...(label ? { label } : {}),\n ...(placeholder ? { placeholder } : {}),\n ...(typeof defaultValue === \"string\" && defaultValue\n ? { value: defaultValue }\n : {}),\n ...(props[\"multiline\"] === true &&\n (props[\"inputType\"] === undefined || props[\"inputType\"] === \"text\")\n ? { isMultiline: true }\n : {}),\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 mode = props[\"inputType\"];\n if (mode === \"time\") {\n const id = reservedSafeId(name || \"datepicker\", \"DatePicker\", context);\n const rawValue = asString(props[\"value\"]);\n const parts = splitTemporalMinutes(rawValue);\n if (\n classifyTemporal(rawValue).kind === \"time\" &&\n parts?.droppedPrecision\n ) {\n warn(\n context,\n \"dropped\",\n \"DatePicker\",\n \"Nonzero seconds were dropped from the time value.\",\n );\n }\n const value = parts?.time;\n const rawMin = asString(props[\"min\"]);\n const minParts = splitTemporalMinutes(rawMin);\n let min = minParts?.time;\n if (\n classifyTemporal(rawMin).kind === \"time\" &&\n minParts?.droppedPrecision\n ) {\n const minuteOfDay =\n Number(minParts.time.slice(0, 2)) * 60 +\n Number(minParts.time.slice(3, 5)) +\n 1;\n if (minuteOfDay === 24 * 60) {\n min = undefined;\n warn(\n context,\n \"dropped\",\n \"DatePicker\",\n \"The time minimum rounds past 23:59 and was dropped.\",\n );\n } else {\n min = `${String(Math.floor(minuteOfDay / 60)).padStart(2, \"0\")}:${String(minuteOfDay % 60).padStart(2, \"0\")}`;\n }\n }\n const rawMax = asString(props[\"max\"]);\n const maxParts = splitTemporalMinutes(rawMax);\n const max = maxParts?.time;\n if (\n classifyTemporal(rawMax).kind === \"time\" &&\n maxParts?.droppedPrecision\n ) {\n warn(\n context,\n \"dropped\",\n \"DatePicker\",\n rawMax.slice(6, 8) === \"00\"\n ? \"Nonzero fractional seconds were dropped from the time maximum.\"\n : /\\.\\d*[1-9]/.test(rawMax)\n ? \"Nonzero seconds and fractional seconds were dropped from the time maximum.\"\n : \"Nonzero seconds were dropped from the time maximum.\",\n );\n }\n const input: TeamsCardElement = {\n type: \"Input.Time\",\n id,\n ...(label ? { label } : {}),\n ...(classifyTemporal(rawValue).kind === \"time\" && value !== undefined\n ? { value }\n : {}),\n ...(classifyTemporal(rawMin).kind === \"time\" && min !== undefined\n ? { min }\n : {}),\n ...(classifyTemporal(rawMax).kind === \"time\" && max !== undefined\n ? { max }\n : {}),\n };\n return withCompanionSubmit(element, input, context);\n }\n if (mode === \"datetime\") {\n const rawValue = asString(props[\"value\"]);\n const temporal = classifyTemporal(rawValue);\n const fieldId = reservedSafeId(\n name || \"datepicker\",\n \"DatePicker\",\n context,\n );\n const dateId = encodeTemporalInputId({ fieldId, role: \"date\" });\n const timeId = encodeTemporalInputId({\n fieldId,\n role: \"time\",\n ...(temporal.kind === \"instant\" ? { previousValue: rawValue } : {}),\n });\n const parts = splitTemporalMinutes(rawValue);\n if (temporal.kind === \"floating\" && parts?.droppedPrecision) {\n warn(\n context,\n \"dropped\",\n \"DatePicker\",\n \"Nonzero seconds were dropped from the datetime value.\",\n );\n }\n const offsetLabel = temporalOffsetLabel(rawValue);\n const boundDate = (raw: unknown) => {\n const value = asString(raw);\n return classifyTemporal(value).kind === \"date\"\n ? value\n : splitTemporalMinutes(\n value,\n temporal.kind === \"instant\" ? temporal.offset : undefined,\n )?.date;\n };\n const min = boundDate(props[\"min\"]);\n const max = boundDate(props[\"max\"]);\n const dateInput: TeamsCardElement = {\n type: \"Input.Date\",\n id: dateId,\n ...(label ? { label } : {}),\n ...(parts?.date !== undefined ? { value: parts.date } : {}),\n ...(min !== undefined ? { min } : {}),\n ...(max !== undefined ? { max } : {}),\n };\n const timeInput: TeamsCardElement = {\n type: \"Input.Time\",\n id: timeId,\n ...(label || offsetLabel\n ? {\n label: `${label ? `${label} time` : \"Time\"}${offsetLabel ? ` (${offsetLabel})` : \"\"}`,\n }\n : {}),\n ...(parts?.time !== undefined ? { value: parts.time } : {}),\n };\n if (element.action === undefined) return [dateInput, timeInput];\n const [input, submit] = withCompanionSubmit(\n element,\n timeInput,\n context,\n );\n return [dateInput, input!, submit!];\n }\n if (mode !== undefined && mode !== \"date\") {\n warn(\n context,\n \"dropped\",\n \"DatePicker\",\n \"Unsupported inputType was dropped; the picker was rendered as a date input.\",\n );\n }\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\"] ?? \"info\";\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 { run: facts, next } = takeRun(\n nodes,\n index,\n (candidate) => candidate.type === \"Fact\",\n );\n index = next;\n emit([convertFacts(facts)]);\n continue;\n }\n if (isElement(current) && current.type === \"Button\") {\n const { run: buttons, next } = takeRun(\n nodes,\n index,\n (candidate) => candidate.type === \"Button\",\n );\n index = next;\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 * CheckboxGroup/Checkbox/Slider/DatePicker whose id would be the reserved\n * {@link RESERVED_INPUT_ID} is renamed with a warning (see `decodeSubmitData`).\n * Never throws: an unknown `$type` is skipped with a \"dropped\" warning, and a\n * malformed input resolves to an empty card plus a \"dropped\" warning instead\n * of throwing.\n */\nexport function toAdaptiveCard(\n node: unknown,\n _options?: ToAdaptiveCardOptions,\n): AdaptiveCardResult {\n const context: ConversionContext = {\n warnings: [],\n usedInputIds: new Set(),\n };\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":";;;;;;;;;;AA2DA,MAAM,YAAY,UAChB,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAErE,MAAM,YAAY,UAChB,OAAO,UAAU,WAAW,QAAQ;AAEtC,MAAM,kBAAkB,UACtB,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,IAAI,QAAQ,KAAA;AAEhE,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,mBAAmB,mBAAmB,KAAK,EAAE;CACnD,MAAM,OAAO,WACT,GAAG,kBAA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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;;;;;;;;;;;AAYA,SAAgB,eACd,MACA,UACoB;CACpB,MAAM,UAA6B;EACjC,UAAU,CAAC;EACX,8BAAc,IAAI,IAAI;CACxB;CACA,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","sourceRoot":"","sources":["../../src/teams/toTeamsAttachments.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EACV,sBAAsB,EAGtB,qBAAqB,EACtB,mBAAgB;AA2CjB;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,OAAO,EACb,QAAQ,CAAC,EAAE,qBAAqB,GAC/B,sBAAsB,
|
|
1
|
+
{"version":3,"file":"toTeamsAttachments.d.ts","sourceRoot":"","sources":["../../src/teams/toTeamsAttachments.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EACV,sBAAsB,EAGtB,qBAAqB,EACtB,mBAAgB;AA2CjB;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,OAAO,EACb,QAAQ,CAAC,EAAE,qBAAqB,GAC/B,sBAAsB,CAuDxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toTeamsAttachments.js","names":[],"sources":["../../src/teams/toTeamsAttachments.ts"],"sourcesContent":["import { boundSpec, clampReasonDetail } from \"../convert/boundSpec\";\nimport { copyBounded } from \"../convert/copyBounded\";\nimport { isElement } from \"../convert/isElement\";\nimport {\n normalizeSpec,\n type NormalizedUIElement,\n type NormalizedUINode,\n} from \"../ir\";\nimport {\n CAROUSEL_ATTACHMENT_CAP,\n PAYLOAD_SOFT_CAP,\n buildAttachment,\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 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\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 = {
|
|
1
|
+
{"version":3,"file":"toTeamsAttachments.js","names":[],"sources":["../../src/teams/toTeamsAttachments.ts"],"sourcesContent":["import { boundSpec, clampReasonDetail } from \"../convert/boundSpec\";\nimport { copyBounded } from \"../convert/copyBounded\";\nimport { isElement } from \"../convert/isElement\";\nimport {\n normalizeSpec,\n type NormalizedUIElement,\n type NormalizedUINode,\n} from \"../ir\";\nimport {\n CAROUSEL_ATTACHMENT_CAP,\n PAYLOAD_SOFT_CAP,\n buildAttachment,\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 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\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 = {\n warnings,\n usedInputIds: new Set(),\n };\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 } = copyBounded(\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":";;;;;;;AA0BA,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;;;;;;;;;AAUA,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,IAAI,YAAY;CAChB,KAAK,MAAM,SAAS,eAAe,QAAQ,QAAQ,GAAG;EACpD,IAAI,UAAU,KAAK,KAAK,MAAM,SAAS,QAAQ;GAC7C,MAAM,KAAK,KAAK;GAChB;EACF;EACA,IAAI,eAAe,OAAO,SAAS,CAAC,GAAG,aAAa;CACtD;CACA,IAAI,YAAY,GACd,QAAQ,SAAS,KAAK;EACpB,MAAM;EACN,WAAW;EACX,QAAQ,GAAG,UAAU,YAAY,cAAc,IAAI,cAAc,gBAAgB;CACnF,CAAC;CAEH,OAAO;AACT;;;;;;;;AASA,SAAgB,mBACd,MACA,UACwB;CACxB,MAAM,WAAqC,CAAC;CA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