UNPKG

@assistant-ui/react

Version:

Typescript/React library for AI Chat

39 lines 1.33 kB
"use client"; import { jsx } from "react/jsx-runtime"; import { forwardRef } from "react"; import { composeEventHandlers } from "@radix-ui/primitive"; import { useMessage } from "../../context"; import { Primitive } from "@radix-ui/react-primitive"; import { useCallback } from "react"; import { useMessageRuntime } from "../../context"; const useActionBarFeedbackNegative = () => { const messageRuntime = useMessageRuntime(); const callback = useCallback(() => { messageRuntime.submitFeedback({ type: "negative" }); }, [messageRuntime]); return callback; }; const ActionBarPrimitiveFeedbackNegative = forwardRef(({ onClick, disabled, ...props }, forwardedRef) => { const isSubmitted = useMessage( (u) => u.submittedFeedback?.type === "negative" ); const callback = useActionBarFeedbackNegative(); return /* @__PURE__ */ jsx( Primitive.button, { type: "button", ...isSubmitted ? { "data-submitted": "true" } : {}, ...props, ref: forwardedRef, disabled: disabled || !callback, onClick: composeEventHandlers(onClick, () => { callback?.(); }) } ); }); ActionBarPrimitiveFeedbackNegative.displayName = "ActionBarPrimitive.FeedbackNegative"; export { ActionBarPrimitiveFeedbackNegative }; //# sourceMappingURL=ActionBarFeedbackNegative.js.map