UNPKG

@assistant-ui/react

Version:

Open-source TypeScript/React library for building production-grade AI chat experiences

45 lines (44 loc) • 1.37 kB
"use client"; import { Primitive } from "../../utils/Primitive.js"; import { c } from "@assistant-ui/tap/react-shim/compiler-runtime"; import { forwardRef } from "@assistant-ui/tap/react-shim"; import { useAuiState } from "@assistant-ui/store"; import { jsx } from "react/jsx-runtime"; // src/primitives/error/ErrorRoot.tsx /** * The container of a message's error. It carries `data-run-state` (`stale` or * `in-progress`) when the error stands for a run another tab or session * drove, and announces an in-progress run as a status instead of an alert. */ const ErrorPrimitiveRoot = forwardRef((props, forwardRef) => { const $ = c(7); const runState = useAuiState(_temp); const t0 = runState === "in-progress" ? "status" : "alert"; let t1; if ($[0] !== runState) { t1 = runState ? { "data-run-state": runState } : void 0; $[0] = runState; $[1] = t1; } else t1 = $[1]; let t2; if ($[2] !== forwardRef || $[3] !== props || $[4] !== t0 || $[5] !== t1) { t2 = /* @__PURE__ */ jsx(Primitive.div, { role: t0, ...t1, ...props, ref: forwardRef }); $[2] = forwardRef; $[3] = props; $[4] = t0; $[5] = t1; $[6] = t2; } else t2 = $[6]; return t2; }); ErrorPrimitiveRoot.displayName = "ErrorPrimitive.Root"; function _temp(s) { return s.optional.message?.runState; } export { ErrorPrimitiveRoot }; //# sourceMappingURL=ErrorRoot.js.map