UNPKG

@assistant-ui/react

Version:

Typescript/React library for AI Chat

25 lines 831 B
"use client"; import { useThread } from "../../context"; const useThreadIf = (props) => { return useThread((thread) => { if (props.empty === true && thread.messages.length !== 0) return false; if (props.empty === false && thread.messages.length === 0) return false; if (props.running === true && !thread.isRunning) return false; if (props.running === false && thread.isRunning) return false; if (props.disabled === true && !thread.isDisabled) return false; if (props.disabled === false && thread.isDisabled) return false; return true; }); }; const ThreadPrimitiveIf = ({ children, ...query }) => { const result = useThreadIf(query); return result ? children : null; }; ThreadPrimitiveIf.displayName = "ThreadPrimitive.If"; export { ThreadPrimitiveIf }; //# sourceMappingURL=ThreadIf.js.map