UNPKG

@assistant-ui/react

Version:

TypeScript/React library for AI Chat

28 lines 998 B
"use client"; import { useAssistantState } from "../../context/index.js"; const useThreadIf = (props) => { return useAssistantState(({ thread }) => { if (props.empty === true && !thread.isEmpty) return false; if (props.empty === false && thread.isEmpty) 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; }); }; /** * @deprecated Use `<AssistantIf condition={({ thread }) => ...} />` instead. */ export const ThreadPrimitiveIf = ({ children, ...query }) => { const result = useThreadIf(query); return result ? children : null; }; ThreadPrimitiveIf.displayName = "ThreadPrimitive.If"; //# sourceMappingURL=ThreadIf.js.map