@assistant-ui/react
Version:
Open-source TypeScript/React library for building production-grade AI chat experiences
52 lines • 2.44 kB
TypeScript
import type { Unstable_TriggerAdapter, Unstable_TriggerItem } from "@assistant-ui/core";
import type { Unstable_IconComponent } from "./useMentionAdapter.js";
/** @deprecated Experimental since 2026-04-15. Not scheduled for removal; the API may change in any release. */
export type Unstable_SlashCommand = {
readonly id: string;
readonly label?: string | undefined;
readonly description?: string | undefined;
readonly icon?: string | undefined;
readonly execute: () => void;
};
/** @deprecated Experimental since 2026-04-06. Not scheduled for removal; the API may change in any release. */
export type Unstable_UseSlashCommandAdapterOptions = {
readonly commands: readonly Unstable_SlashCommand[];
/** Strip the trigger text from the composer after executing. @default false */
readonly removeOnExecute?: boolean | undefined;
/** Maps `metadata.icon` / `category.id` string keys to React components. */
readonly iconMap?: Record<string, Unstable_IconComponent>;
/** Fallback icon when no entry in `iconMap` matches. */
readonly fallbackIcon?: Unstable_IconComponent;
};
/** @deprecated Experimental since 2026-04-15. Not scheduled for removal; the API may change in any release. */
export type Unstable_SlashCommandAction = {
readonly onExecute: (item: Unstable_TriggerItem) => void;
readonly removeOnExecute?: boolean | undefined;
};
/**
* Bundles slash command definitions (with inline `execute` callbacks) into
* `{adapter, action}` that plug directly into `ComposerTriggerPopover`.
* `execute` stays in the hook closure and is never attached to the returned
* `TriggerItem`, keeping items serializable.
*
* @deprecated Experimental since 2026-04-06. Not scheduled for removal; the API may change in any release.
*
* @example
* ```tsx
* const slash = unstable_useSlashCommandAdapter({
* commands: [
* { id: "summarize", execute: () => runSummarize(), icon: "FileText" },
* { id: "translate", execute: () => runTranslate(), icon: "Languages" },
* ],
* });
*
* <ComposerTriggerPopover char="/" {...slash} />
* ```
*/
export declare function unstable_useSlashCommandAdapter(options: Unstable_UseSlashCommandAdapterOptions): {
adapter: Unstable_TriggerAdapter;
action: Unstable_SlashCommandAction;
iconMap?: Record<string, Unstable_IconComponent>;
fallbackIcon?: Unstable_IconComponent;
};
//# sourceMappingURL=useSlashCommandAdapter.d.ts.map