UNPKG

@assistant-ui/react

Version:

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

79 lines (78 loc) • 2.18 kB
"use client"; import { Primitive as Primitive$1 } from "../../utils/Primitive.js"; import { c } from "@assistant-ui/tap/react-shim/compiler-runtime"; import { forwardRef } from "@assistant-ui/tap/react-shim"; import { useAui, useAuiState } from "@assistant-ui/store"; import { jsx } from "react/jsx-runtime"; import { composeEventHandlers } from "radix-ui/internal"; // src/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.tsx /** * A button component that toggles the collapsed state of the chain of thought accordion. * * This component automatically handles the toggle functionality, expanding or collapsing * the chain of thought parts when clicked. * Exposes the current disclosure state through `aria-expanded`. * * @example * ```tsx * <ChainOfThoughtPrimitive.AccordionTrigger> * Toggle Reasoning * </ChainOfThoughtPrimitive.AccordionTrigger> * ``` */ const ChainOfThoughtPrimitiveAccordionTrigger = forwardRef((t0, ref) => { const $ = c(14); let onClick; let props; if ($[0] !== t0) { ({onClick, ...props} = t0); $[0] = t0; $[1] = onClick; $[2] = props; } else { onClick = $[1]; props = $[2]; } const aui = useAui(); const collapsed = useAuiState(_temp); let t1; if ($[3] !== aui || $[4] !== collapsed) { t1 = () => { aui.chainOfThought.setCollapsed(!collapsed); }; $[3] = aui; $[4] = collapsed; $[5] = t1; } else t1 = $[5]; const toggle = t1; const t2 = !collapsed; let t3; if ($[6] !== onClick || $[7] !== toggle) { t3 = composeEventHandlers(onClick, toggle); $[6] = onClick; $[7] = toggle; $[8] = t3; } else t3 = $[8]; let t4; if ($[9] !== props || $[10] !== ref || $[11] !== t2 || $[12] !== t3) { t4 = /* @__PURE__ */ jsx(Primitive$1.button, { type: "button", ...props, ref, "aria-expanded": t2, onClick: t3 }); $[9] = props; $[10] = ref; $[11] = t2; $[12] = t3; $[13] = t4; } else t4 = $[13]; return t4; }); ChainOfThoughtPrimitiveAccordionTrigger.displayName = "ChainOfThoughtPrimitive.AccordionTrigger"; function _temp(s) { return s.chainOfThought.collapsed; } export { ChainOfThoughtPrimitiveAccordionTrigger }; //# sourceMappingURL=ChainOfThoughtAccordionTrigger.js.map