UNPKG

@assistant-ui/react

Version:

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

39 lines (38 loc) • 1.42 kB
"use client"; import { createActionButton } from "../../utils/createActionButton.js"; import { useComposerCancelWithFocus } from "./useComposerCancelWithFocus.js"; import { c } from "@assistant-ui/tap/react-shim/compiler-runtime"; import { useComposerCancel } from "@assistant-ui/core/react"; // src/primitives/composer/ComposerCancel.ts const useComposerCancel$1 = () => { const $ = c(2); const { disabled, cancel } = useComposerCancel(); const cancelWithFocus = useComposerCancelWithFocus(cancel); if (disabled) return null; let t0; if ($[0] !== cancelWithFocus) { t0 = (event) => cancelWithFocus(event.detail === 0 ? event.currentTarget : null); $[0] = cancelWithFocus; $[1] = t0; } else t0 = $[1]; return t0; }; /** * A button component that cancels the current message composition. * * This component automatically handles the cancel functionality and is disabled * when canceling is not available. * Keyboard or assistive-technology activation after editing returns focus to the * main thread composer when available, unless a handler has moved focus elsewhere. * Pointer activation preserves the existing focus behavior. * * @example * ```tsx * <ComposerPrimitive.Cancel> * Cancel * </ComposerPrimitive.Cancel> * ``` */ const ComposerPrimitiveCancel = createActionButton("ComposerPrimitive.Cancel", useComposerCancel$1); export { ComposerPrimitiveCancel }; //# sourceMappingURL=ComposerCancel.js.map