UNPKG

@copilotkit/a2ui-renderer

Version:

A2UI Renderer for CopilotKit - render A2UI surfaces in React applications

1 lines 2.84 kB
{"version":3,"file":"CheckBox.mjs","names":[],"sources":["../../../../../../src/react-renderer/a2ui-react/catalog/basic/components/CheckBox.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 React from \"react\";\nimport { createReactComponent } from \"../../../adapter\";\nimport { CheckBoxApi } from \"@a2ui/web_core/v0_9/basic_catalog\";\nimport { LEAF_MARGIN } from \"../utils\";\n\nexport const CheckBox = createReactComponent(CheckBoxApi, ({ props }) => {\n const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n props.setValue(e.target.checked);\n };\n\n const uniqueId = React.useId();\n\n const hasError = props.validationErrors && props.validationErrors.length > 0;\n\n return (\n <div\n style={{ display: \"flex\", flexDirection: \"column\", margin: LEAF_MARGIN }}\n >\n <div style={{ display: \"flex\", alignItems: \"center\", gap: \"8px\" }}>\n <input\n id={uniqueId}\n type=\"checkbox\"\n checked={!!props.value}\n onChange={onChange}\n style={{\n cursor: \"pointer\",\n outline: hasError ? \"1px solid red\" : \"none\",\n }}\n />\n {props.label && (\n <label\n htmlFor={uniqueId}\n style={{ cursor: \"pointer\", color: hasError ? \"red\" : \"inherit\" }}\n >\n {props.label}\n </label>\n )}\n </div>\n {hasError && (\n <span style={{ fontSize: \"12px\", color: \"red\", marginTop: \"4px\" }}>\n {props.validationErrors?.[0]}\n </span>\n )}\n </div>\n );\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAqBA,MAAa,WAAW,qBAAqB,cAAc,EAAE,YAAY;CACvE,MAAM,YAAY,MAA2C;AAC3D,QAAM,SAAS,EAAE,OAAO,QAAQ;;CAGlC,MAAM,WAAW,MAAM,OAAO;CAE9B,MAAM,WAAW,MAAM,oBAAoB,MAAM,iBAAiB,SAAS;AAE3E,QACE,qBAAC;EACC,OAAO;GAAE,SAAS;GAAQ,eAAe;GAAU,QAAQ;GAAa;aAExE,qBAAC;GAAI,OAAO;IAAE,SAAS;IAAQ,YAAY;IAAU,KAAK;IAAO;cAC/D,oBAAC;IACC,IAAI;IACJ,MAAK;IACL,SAAS,CAAC,CAAC,MAAM;IACP;IACV,OAAO;KACL,QAAQ;KACR,SAAS,WAAW,kBAAkB;KACvC;KACD,EACD,MAAM,SACL,oBAAC;IACC,SAAS;IACT,OAAO;KAAE,QAAQ;KAAW,OAAO,WAAW,QAAQ;KAAW;cAEhE,MAAM;KACD;IAEN,EACL,YACC,oBAAC;GAAK,OAAO;IAAE,UAAU;IAAQ,OAAO;IAAO,WAAW;IAAO;aAC9D,MAAM,mBAAmB;IACrB;GAEL;EAER"}