ConversationListView
Props, styling and a live ConversationListView example.
Customize
Controlled search, when supplied.
Confirm the mutation through the owning source, then refresh its rows.
Only offer actions supported and authorized by the host.
React only: @polymorfa/elements has no element for ConversationListView.
npm install @polymorfa/react@dev @polymorfa/browser@devimport { useState } from "react";
import { PolymorfaProvider, ConversationListView } from "@polymorfa/react";
const appearance = { theme: "light", variables: { colorPrimary: "#635bff" } };
export function ConversationListViewExample({ conversation, conversations }) {
const [selectedId, setSelectedId] = useState("avery");
return (
<PolymorfaProvider tokenEndpoint="/api/polymorfa/token" appearance={appearance}>
<ConversationListView
conversations={conversations}
selectedId={selectedId}
title="Conversations"
search
drafts={{ sam: "Your order is ready." }}
status="ready"
hasMore={false}
onSelect={(conversation) => setSelectedId(conversation.id)}
/>
</PolymorfaProvider>
);
}ConversationListView from @polymorfa/react. Choose props and styles above; the preview stays visible in every code view.
Props#
conversationsreadonly InboxConversation[]requiredRows to show.
selectedIdstringThe open conversation.
onSelect(conversation: InboxConversation) => voidrequiredCalled when a row is selected.
titleReactNodeSame as
ConversationList.searchbooleanSame as
ConversationList.querystringControlled search, when supplied.
onQueryChange(query: string) => voidSame as
ConversationList.draftsReadonly<Record<string, string>>Same as
ConversationList.onAction(conversation: InboxConversation, action: InboxRowAction) => Promise<void>Confirm the mutation through the owning source, then refresh its rows.
actions(conversation: InboxConversation) => readonly InboxRowAction[]Only offer actions supported and authorized by the host.
onNewConversation() => voidSame as
ConversationList.statusInboxSnapshot["status"]Shows loading and error states.
onRetry() => voidRetry action for the error state.
hasMorebooleanShows Load more conversations.
Default
falseonLoadMore() => voidShows Load more conversations.
classNamestringSame as
ConversationList.classNamesSlotClassNamesSame as
ConversationList.
Types#
Named types used in the props above.
type InboxRowAction =
| "pin"
| "unpin"
| "archive"
| "unarchive"
| "mark-read"
| "mark-unread";Styling#
Use className, classNames (a class for any slot, typed SlotClassNames), appearance variables and element styles. The Style panel applies changes to the live component. See Appearance.
Setup#
Use the provider and server route for your application. The preview above uses local sample data and controllers. Chat controllers and inbox data sources keep your data separate from the UI.