Docyrus

Email Compose Dialog

A batteries-included launcher that opens the Docyrus EmailComposer (wired to the messaging API) inside a dialog, seeded with recipients/subject/body.

Client Only

Email Compose Dialog opens the Docyrus EmailComposer inside a modal, fully wired to the tenant messaging API through useDocyrusEmailComposer. Give it a client and an optional to / cc / bcc / subject / body seed and it handles account loading, sending, and a success/error toast.

The composer body only mounts while the dialog is open, so each open re-reads the current seeds and the GET /v1/messaging/email/accounts query fires only when visible. On a successful send it calls onSent(result), shows a toast, and closes.

The body editor's @ mention autocomplete is active out of the box — the underlying hook loads the tenant's users from /v1/users by default (see the hook's mentions option to disable).

It is the component behind the inline compose action on the EmailFormField and EmailValue renderer — pass a client to those (directly or via useDocyrusFormView / useDocyrusDataGrid / useDocyrusDataTable) and the action lights up automatically.

This is a Docyrus-connection component. It needs an authenticated RestApiClient to list email accounts and send, so the preview above is informational only — wire it against your tenant (or the playground) to see it work. Sending requires the OAuth token to carry the Messaging.Email.Send scope.

Installation

pnpm dlx @docyrus/cli add @docyrus/ui-email-compose-dialog
Required Packages(3 packages)
pnpm add @tanstack/react-query sonner @docyrus/api-client

Usage

Standalone

import { useDocyrusAuth } from '@docyrus/signin';
import { EmailComposeDialog } from '@docyrus/ui/components/email-compose-dialog';

function ContactActions({ email }: { email: string }) {
  const { client } = useDocyrusAuth();

  if (!client) return null;

  return (
    <EmailComposeDialog
      client={client}
      to={[email]}
      subject="Following up"
      onSent={result => console.log('accepted', result.accepted)} />
  );
}

Custom trigger

<EmailComposeDialog
  client={client}
  to={[email]}
  trigger={<Button variant="outline">Email contact</Button>} />

Automatic on fields, values, and grids

Pass a client to the email form field / value renderer (or let the Docyrus hooks thread it for you) and the compose action appears with no extra wiring:

// Form field + value renderer
<EmailFormField field={field} form={form} client={client} />
<EmailValue field={field} value={record.email} client={client} />

// Whole form — useDocyrusFormView threads `client` into every field
const formView = useDocyrusFormView({ client, appSlug, dataSourceSlug, itemId });

// Grids — EmailCell (data grid) and EmailValue (data table) light up automatically
const grid = useDocyrusDataGrid({ client, appSlug, dataSourceSlug });

API Reference

PropTypeDefaultDescription
clientRestApiClient—Authenticated Docyrus REST client. Required.
tostring[]—Pre-filled recipients.
ccstring[]—Pre-filled Cc recipients.
bccstring[]—Pre-filled Bcc recipients.
subjectstring—Pre-filled subject.
bodystring—Pre-filled body (HTML).
triggerReactNodeGhost mail icon buttonCustom element that opens the dialog.
openboolean—Controlled open state.
onOpenChange(open: boolean) => void—Open-state change handler.
titlestring"Compose email"Dialog title.
disabledbooleanfalseDisables the default trigger button.
sendAsUserboolean—Send through the tenant account with the user's identity (subject to account override rules).
slashCommandsEmailComposerSlashCommand[]—Developer-defined / slash commands forwarded to the composer body editor (see the composer's Slash Commands section).
onSent(result: DocyrusEmailSendResult) => void—Called after a successful send.
classNamestring—Extra class for the default trigger button.

On this page