mirror of
https://github.com/bitbaum/chatkit.git
synced 2026-12-04 16:27:42 +01:00
* feat(messenger): replies, reactions, and things of value in a conversation (0.31.0) Reply to any message (the answer carries one line of the original, which leads back to it); emoji reactions, one per person, shown at once; cards for value in a thread (a payment request, money sent, a gift), written by the app for this reader and drawn in one shape; the app's own actions in the box's "+", with one "how much?" sheet for those that need an amount. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmsmMXvM981mcszxEA6 * feat(messenger): an action's amount sheet takes the app's note length Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmsmMXvM981mcszxEA6 * feat(messenger): an action's amount sheet takes the app's note length Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmsmMXvM981mcszxEA6 * chore(release): 0.31.1 Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmsmMXvM981mcszxEA6 --------- Co-authored-by: Claude <noreply@anthropic.com>
111 lines
5.5 KiB
TypeScript
111 lines
5.5 KiB
TypeScript
import { type ReactNode, type RefObject } from "react";
|
|
import { type MessengerAgent, type MessengerCard, type MessengerConversation, type MessengerDrafts, type MessengerMessage, type MessengerParticipant, type MessengerTransport } from "../messenger.js";
|
|
import { type ComposerLabelOverrides, type ComposerVoice } from "./Composer.js";
|
|
import { type ConversationListProps } from "./ConversationList.js";
|
|
import type { RenderLink } from "./Markdown.js";
|
|
import { type MessengerLabelOverrides } from "./messenger-labels.js";
|
|
import { type UploadOptions } from "./use-uploads.js";
|
|
export type MessengerComposerOptions = {
|
|
/** The microphone. Pass `{ transcribeUrl }` so it works where the browser's
|
|
* recogniser does not. */
|
|
voice?: ComposerVoice | false;
|
|
/** What may be attached and how photos are shrunk. `false` offers no files
|
|
* even when the transport can upload. */
|
|
attach?: UploadOptions | false;
|
|
/** Inside the box, above the words: a product's own line ("Sending as …"). */
|
|
header?: ReactNode;
|
|
/** Around the box: a menu that needs the keys before the box does. */
|
|
wrap?: (box: ReactNode) => ReactNode;
|
|
inputRef?: RefObject<HTMLTextAreaElement | null>;
|
|
/** What a conversation's box holds when it is opened by a link that says
|
|
* what to write. Wins over a kept draft, once. */
|
|
initialDraft?: (conversationId: string) => string | undefined;
|
|
labels?: ComposerLabelOverrides;
|
|
};
|
|
/**
|
|
* Something the app lets people do from the box's "+": send money, ask for
|
|
* it, send a gift, share a listing. The app owns what happens; the package
|
|
* owns where it is offered and, with `amount`, the one sheet that asks how
|
|
* much — so "Request money" looks the same in every product.
|
|
*/
|
|
export type MessengerComposerAction = {
|
|
id: string;
|
|
label: string;
|
|
detail?: string;
|
|
icon?: ReactNode;
|
|
/** Ask for an amount and a note first. `unit` is shown beside the number
|
|
* ("CHF"); `confirm` is the sheet's button ("Request"); `noteMaxLength` is
|
|
* how long a note the app can keep (140 when not given). */
|
|
amount?: {
|
|
unit: string;
|
|
confirm: string;
|
|
noteMaxLength?: number;
|
|
};
|
|
/** Leave it out of conversations it makes no sense in (a group, an agent). */
|
|
available?: (conversation: MessengerConversation) => boolean;
|
|
onPick: (context: {
|
|
conversation: MessengerConversation;
|
|
/** Set when `amount` asked for them. */
|
|
amount?: number;
|
|
note?: string;
|
|
/** Put a message in this conversation: words, a card, or both. */
|
|
send: (body: string, card?: MessengerCard) => Promise<boolean>;
|
|
}) => void | Promise<void>;
|
|
};
|
|
export type MessengerProps = {
|
|
/** Who is using it. `id` is what their own messages carry as `authorId`. */
|
|
viewer: {
|
|
id: string;
|
|
};
|
|
/** The app's backend (see `MessengerTransport`). */
|
|
transport: MessengerTransport;
|
|
/** Agents people can bring in by naming them. */
|
|
agents?: readonly MessengerAgent[];
|
|
/** The open conversation, when the app keeps it (the URL). */
|
|
conversationId?: string | null;
|
|
onConversationChange?: (id: string | null) => void;
|
|
composer?: MessengerComposerOptions;
|
|
/** Where unsent words are kept. Default: this tab (`sessionDrafts`). */
|
|
drafts?: MessengerDrafts;
|
|
/** Under the list's title. */
|
|
listHeader?: ReactNode;
|
|
/** What the app adds to the box's "+" (see `MessengerComposerAction`). */
|
|
actions?: readonly MessengerComposerAction[];
|
|
/** At the end of a card, for this reader (a product's own control). */
|
|
renderCardAction?: (card: MessengerCard, message: MessengerMessage) => ReactNode;
|
|
/** At the end of a conversation's top bar: a product's own controls. */
|
|
headerActions?: (conversation: MessengerConversation) => ReactNode;
|
|
/** Where the name in the top bar leads (a profile), if anywhere. */
|
|
profileHref?: (participant: MessengerParticipant) => string | undefined;
|
|
search?: ConversationListProps["search"];
|
|
renderLink?: RenderLink;
|
|
/** The product's own mark for its agent, where it has no picture. */
|
|
agentMark?: ReactNode;
|
|
/**
|
|
* `"parent"` (the default) fills the box it is given — give it a height.
|
|
* `"viewport"` is the whole display and follows the visual viewport, so the
|
|
* box rides above the phone keyboard.
|
|
*/
|
|
fill?: "parent" | "viewport";
|
|
locale?: string;
|
|
timeZone?: string;
|
|
agentPatienceMs?: number;
|
|
labels?: MessengerLabelOverrides;
|
|
className?: string;
|
|
};
|
|
/**
|
|
* The messenger, whole: the list of conversations, the conversation, the box.
|
|
* On a phone it is one screen at a time — the list, then the conversation
|
|
* with its own way back — and from 48rem of its own width the two sit side
|
|
* by side. The app gives it a `transport` and a place to live; it has no
|
|
* database, no websocket and no storage of its own.
|
|
*
|
|
* <Messenger viewer={{ id }} transport={transport} agents={[cat]}
|
|
* conversationId={id} onConversationChange={setId}
|
|
* composer={{ voice: { transcribeUrl: "/api/transcribe" } }} />
|
|
*
|
|
* An app that needs its own arrangement uses the parts it is made of:
|
|
* `useMessenger`, `ConversationList`, `MessageThread`.
|
|
*/
|
|
export declare function Messenger({ viewer, transport, agents, conversationId, onConversationChange, composer, drafts, listHeader, actions, renderCardAction, headerActions, profileHref, search, renderLink, agentMark, fill, locale, timeZone, agentPatienceMs, labels: labelOverrides, className, }: MessengerProps): import("react").JSX.Element;
|
|
//# sourceMappingURL=MessengerScreen.d.ts.map
|