"use client"; import { type ActionButtonElement, type ActionButtonProps, createActionButton, } from "../../utils/createActionButton"; import { useActionBarEdit as useActionBarEditBehavior } from "@assistant-ui/core/react"; /** * Hook that provides edit functionality for action bar buttons. * * This hook returns a callback function that starts editing the current message, * or null if editing is not available (e.g., already in editing mode). * * @returns An edit callback function, or null if editing is disabled * * @example * ```tsx * function CustomEditButton() { * const edit = useActionBarEdit(); * * return ( * * ); * } * ``` */ const useActionBarEdit = () => { const { disabled, edit } = useActionBarEditBehavior(); if (disabled) return null; return edit; }; export namespace ActionBarPrimitiveEdit { export type Element = ActionButtonElement; /** * Props for the ActionBarPrimitive.Edit component. * Inherits all button element props and action button functionality. */ export type Props = ActionButtonProps; } /** * A button component that starts editing the current message. * * This component automatically handles starting the edit mode for the current message * and is disabled when editing is not available (e.g., already in editing mode). * * @example * ```tsx * * Edit Message * * ``` */ export const ActionBarPrimitiveEdit = createActionButton( "ActionBarPrimitive.Edit", useActionBarEdit, );