UNPKG

@copilotkit/a2ui-renderer

Version:

A2UI Renderer for CopilotKit - render A2UI surfaces in React applications

1 lines 3.55 kB
{"version":3,"file":"Modal.mjs","names":[],"sources":["../../../../../../src/react-renderer/a2ui-react/catalog/basic/components/Modal.tsx"],"sourcesContent":["/**\n * Copyright 2026 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useState } from \"react\";\nimport { createReactComponent } from \"../../../adapter\";\nimport { ModalApi } from \"@a2ui/web_core/v0_9/basic_catalog\";\n\nexport const Modal = createReactComponent(ModalApi, ({ props, buildChild }) => {\n const [isOpen, setIsOpen] = useState(false);\n\n return (\n <>\n <div onClick={() => setIsOpen(true)} style={{ display: \"inline-block\" }}>\n {props.trigger ? buildChild(props.trigger) : null}\n </div>\n {isOpen && (\n <div\n style={{\n position: \"fixed\",\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n backgroundColor: \"rgba(0,0,0,0.5)\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n zIndex: 1000,\n }}\n onClick={() => setIsOpen(false)}\n >\n <div\n style={{\n backgroundColor: \"#fff\",\n padding: \"24px\",\n borderRadius: \"8px\",\n maxWidth: \"90%\",\n maxHeight: \"90%\",\n overflow: \"auto\",\n display: \"flex\",\n flexDirection: \"column\",\n }}\n onClick={(e) => e.stopPropagation()}\n >\n <div style={{ display: \"flex\", justifyContent: \"flex-end\" }}>\n <button\n onClick={() => setIsOpen(false)}\n style={{\n border: \"none\",\n background: \"none\",\n fontSize: \"20px\",\n cursor: \"pointer\",\n padding: \"4px\",\n }}\n >\n &times;\n </button>\n </div>\n <div style={{ flex: 1 }}>\n {props.content ? buildChild(props.content) : null}\n </div>\n </div>\n </div>\n )}\n </>\n );\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAoBA,MAAa,QAAQ,qBAAqB,WAAW,EAAE,OAAO,iBAAiB;CAC7E,MAAM,CAAC,QAAQ,aAAa,SAAS,MAAM;AAE3C,QACE,4CACE,oBAAC;EAAI,eAAe,UAAU,KAAK;EAAE,OAAO,EAAE,SAAS,gBAAgB;YACpE,MAAM,UAAU,WAAW,MAAM,QAAQ,GAAG;GACzC,EACL,UACC,oBAAC;EACC,OAAO;GACL,UAAU;GACV,KAAK;GACL,MAAM;GACN,OAAO;GACP,QAAQ;GACR,iBAAiB;GACjB,SAAS;GACT,YAAY;GACZ,gBAAgB;GAChB,QAAQ;GACT;EACD,eAAe,UAAU,MAAM;YAE/B,qBAAC;GACC,OAAO;IACL,iBAAiB;IACjB,SAAS;IACT,cAAc;IACd,UAAU;IACV,WAAW;IACX,UAAU;IACV,SAAS;IACT,eAAe;IAChB;GACD,UAAU,MAAM,EAAE,iBAAiB;cAEnC,oBAAC;IAAI,OAAO;KAAE,SAAS;KAAQ,gBAAgB;KAAY;cACzD,oBAAC;KACC,eAAe,UAAU,MAAM;KAC/B,OAAO;MACL,QAAQ;MACR,YAAY;MACZ,UAAU;MACV,QAAQ;MACR,SAAS;MACV;eACF;MAEQ;KACL,EACN,oBAAC;IAAI,OAAO,EAAE,MAAM,GAAG;cACpB,MAAM,UAAU,WAAW,MAAM,QAAQ,GAAG;KACzC;IACF;GACF,IAEP;EAEL"}