UNPKG

@copilotkit/a2ui-renderer

Version:

A2UI Renderer for CopilotKit - render A2UI surfaces in React applications

1 lines 2.05 kB
{"version":3,"file":"image.cjs","names":["createLitComponent","ImageApi","getBaseLeafStyle"],"sources":["../../../../src/web-components/catalog/basic/image.ts"],"sourcesContent":["import { html } from \"lit\";\nimport { styleMap } from \"lit/directives/style-map.js\";\nimport { ImageApi } from \"@a2ui/web_core/v0_9/basic_catalog\";\nimport { createLitComponent } from \"../../adapter\";\nimport { getBaseLeafStyle } from \"./utils\";\n\nexport const Image = createLitComponent(ImageApi, ({ props }) => {\n const mapFit = (fit?: string): string => {\n if (fit === \"scaleDown\") return \"scale-down\";\n return fit || \"fill\";\n };\n const style: Record<string, string> = {\n ...getBaseLeafStyle(),\n objectFit: mapFit(props.fit),\n width: \"100%\",\n height: \"auto\",\n display: \"block\",\n } as Record<string, string>;\n\n if (props.variant === \"icon\") {\n style.width = \"24px\";\n style.height = \"24px\";\n } else if (props.variant === \"avatar\") {\n style.width = \"40px\";\n style.height = \"40px\";\n style.borderRadius = \"50%\";\n } else if (props.variant === \"smallFeature\") {\n style.maxWidth = \"100px\";\n } else if (props.variant === \"largeFeature\") {\n style.maxHeight = \"400px\";\n } else if (props.variant === \"header\") {\n style.height = \"200px\";\n style.objectFit = \"cover\";\n }\n\n return html`<img\n src=${props.url ?? \"\"}\n alt=${props.description ?? \"\"}\n style=${styleMap(style)}\n />`;\n});\n"],"mappings":";;;;;;;AAMA,MAAa,QAAQA,mCAAmBC,6CAAW,EAAE,YAAY;CAC/D,MAAM,UAAU,QAAyB;AACvC,MAAI,QAAQ,YAAa,QAAO;AAChC,SAAO,OAAO;;CAEhB,MAAM,QAAgC;EACpC,GAAGC,gCAAkB;EACrB,WAAW,OAAO,MAAM,IAAI;EAC5B,OAAO;EACP,QAAQ;EACR,SAAS;EACV;AAED,KAAI,MAAM,YAAY,QAAQ;AAC5B,QAAM,QAAQ;AACd,QAAM,SAAS;YACN,MAAM,YAAY,UAAU;AACrC,QAAM,QAAQ;AACd,QAAM,SAAS;AACf,QAAM,eAAe;YACZ,MAAM,YAAY,eAC3B,OAAM,WAAW;UACR,MAAM,YAAY,eAC3B,OAAM,YAAY;UACT,MAAM,YAAY,UAAU;AACrC,QAAM,SAAS;AACf,QAAM,YAAY;;AAGpB,QAAO,QAAI;UACH,MAAM,OAAO,GAAG;UAChB,MAAM,eAAe,GAAG;sDACb,MAAM,CAAC;;EAE1B"}