Hooks

useDocyrusAdaptiveCardItemDetail

Generate an Adaptive Card JSON payload from a Docyrus field list + a single record — mapping Docyrus field types onto the Adaptive Cards element vocabulary — and render it with the shared native AdaptiveCard renderer.

iOSAndroidExpo Go

Installation

pnpm dlx @docyrus/cli add @docyrus/rn-hooks-use-docyrus-adaptive-card-item-detail
Required Packages(1 package)
pnpm add react

Installing the hook also installs AdaptiveCard and the pure mapper helpers (_internal/docyrus-adaptive-card*.ts). The signature is identical to web @docyrus/ui, so the same field list and record produce the same card JSON on both platforms.

Overview

useDocyrusAdaptiveCardItemDetail is the bridge between Docyrus field types (field-select, field-money, field-image, …) and the Adaptive Cards element vocabulary (TextBlock, FactSet, Image, Badge, CodeBlock, …).

You hand it a field list + one record and it generates an Adaptive Card JSON payload (card) — the primary output. The card is then drawn by the shared AdaptiveCard renderer; the hook also returns a ready-to-render view and the full useAdaptiveCard runtime (state / controls / cardProps) so you can wire actions.

It is backend-agnostic — no network I/O. Pass any Docyrus-shaped field list (IField[], DataSourceField[], or the loose DocyrusAdaptiveCardField[]) and a plain record object. When a DocyrusTenantProvider is mounted, date / number / currency values are formatted with the tenant's preferences automatically.

Usage

Generate + render a detail card

import { ScrollView } from 'react-native';

import { useDocyrusAdaptiveCardItemDetail } from '@/hooks/docyrus-native/use-docyrus-adaptive-card-item-detail';

export function DealDetail({ fields, record }) {
  const { view } = useDocyrusAdaptiveCardItemDetail({ fields, record });

  return <ScrollView contentContainerClassName="p-4">{view}</ScrollView>;
}

Use the generated JSON directly

The card field is a plain Adaptive Card payload — persist it, post it to Teams, or render it yourself with <AdaptiveCard payload={card} />.

import { AdaptiveCard } from '@/components/docyrus-native/adaptive-card';
import { useDocyrusAdaptiveCardItemDetail } from '@/hooks/docyrus-native/use-docyrus-adaptive-card-item-detail';

const { card } = useDocyrusAdaptiveCardItemDetail({ fields, record });

// `card` === { type: 'AdaptiveCard', version: '1.5', body: [...] }
await client.post('/teams/notify', card);

return <AdaptiveCard payload={card} />;

Pin slots, add actions, react to clicks

const { view } = useDocyrusAdaptiveCardItemDetail({
  fields,
  record,
  slots: {
    titleField: 'name',
    badgeField: 'status',
    coverImageField: 'cover',
    subtitleField: 'description'
  },
  actions: [
    { type: 'Action.OpenUrl', title: 'Open record', url: `myapp://records/${record.id}` }
  ],
  onAction: (event) => {
    // Action.OpenUrl also opens the URL via Linking; route in-app links yourself.
    if (event.type === 'openUrl') router.push(event.url);
  }
});

Field-type → Adaptive Card element mapping

The card body is assembled from three regions: a header (cover / avatar / title / subtitle / status badge), a FactSet of scalar fields, and standalone blocks for rich fields. Slots are auto-detected from field type + slug (see Slot detection); everything else lands in the body.

Docyrus field typeAdaptive Card representation
field-text, field-email, field-url, field-phone, field-currency, field-color, field-icon, field-formula, field-identityHeader title or FactSet value (TextBlock)
field-number, field-autonumber, field-money, field-percent, field-duration, field-ratingFactSet value — formatted (currency, %, ★, hh:mm:ss)
field-checkbox, field-switchFactSet value — Yes/No, On/Off
field-date, field-dateTime, field-time, field-dateRangeFactSet value — tenant-formatted date/time
field-select, field-radioGroup, field-enum, field-systemEnum, field-status, field-approvalStatusHeader status Badge (semantic color) or FactSet value (option name)
field-multiSelect, field-tagSelectFactSet value — comma-joined option names
field-userSelectFactSet value — user display name
field-userMultiSelectFactSet value — joined user names
field-relation, field-relatedFieldFactSet value — related record label
field-image, field-avatarCover / avatar Image, or an Image / ImageSet body block
field-textarea, field-markdown, field-htmlEditor, field-emailEditor, field-docEditorWrapped TextBlock block (HTML stripped)
field-json, field-jsonSchema, field-jsonata, field-handlebars, field-code, field-codeEditor, field-queryBuilder, field-dsqlCodeBlock block (language-tagged)
field-fileFactSet value — file name
field-locationSelectFactSet value — address label
field-taskList, field-todoFactSet value — done / total summary
field-adaptiveCard, field-button, field-password, field-inlineForm, field-schema*, field-inlineData, field-dynamic, field-conversationChannel, field-fileStorageFolder, field-system*Skipped (no meaningful card representation)

Enum / status colors (Tailwind families or hex) are classified to the nearest Adaptive Card badge style: green → good, red → attention, amber → warning, blue/purple → accent, otherwise informative.

Slot detection

When you don't pin slots, bindings are auto-detected from the field list using the same heuristics as the web data gallery (slug hints first, then type; system audit columns such as id, created_by and record_owner are never picked). Override any slot with a slug, or null to disable a detected binding:

SlotAuto-detected from
titleFieldslug name / title / subject / label, then a text/identity field
subtitleFieldslug description / summary / subtitle, then a textarea field
coverImageFieldslug cover / image / thumbnail / banner, then a field-image
avatarFieldslug avatar / profile_photo, then a field-avatar
badgeFieldslug status / priority / stage, then a status/select field
timelineFieldslug due / deadline / start, then a field-date (leads the facts)
bodyFieldsevery remaining non-system field

API Reference

UseDocyrusAdaptiveCardItemDetailOptions

OptionTypeDefaultDescription
fieldsDocyrusAdaptiveCardField[]—Field metadata (accepts IField / DataSourceField / DocyrusFieldLike).
recordRecord<string, unknown> | null—The record to render.
enumOptionsRecord<string, EnumOption[]>—Per-field-slug enum options. Falls back to each field's inline enums.
slotsDocyrusAdaptiveCardSlotOverrides—Pin (string) or disable (null) individual slot bindings.
includeFieldsstring[]—Explicit, ordered body field list (replaces auto-detected body).
excludeFieldsstring[]—Field slugs to drop from the body.
titlestring—Force the header title text.
actionsAdaptiveCardAction[]—Card-level actions appended to payload.actions.
hideEmptybooleantrueDrop empty fields instead of rendering an em-dash.
factLayout'facts' | 'stacked''facts'Scalar layout — a FactSet or stacked label/value blocks.
versionstring'1.5'Adaptive Card schema version.
formatDate(value) => stringtenant contextOverride the date formatter.
formatDateTime(value) => stringtenant contextOverride the datetime formatter.
formatNumber(value, opts?: { variant?: 'number' | 'currency' | 'percent'; currency?: string; decimalPrecision?: number; thousandSeparator?: string }) => stringtenant contextOverride the number/currency/percent formatter.
classNamestring—className forwarded to the rendered view (<AdaptiveCardView>).
onAction(event: AdaptiveCardActionEvent) => void | Promise<void>—Forwarded to useAdaptiveCard.
hostConfigAdaptiveCardHostConfigOverride—Forwarded to useAdaptiveCard.
customElementsRecord<string, ElementRenderer>—Forwarded to useAdaptiveCard.
onChoiceQuery(request: AdaptiveCardChoiceQueryRequest) => Promise<AdaptiveCardChoice[]>—Forwarded to useAdaptiveCard.

UseDocyrusAdaptiveCardItemDetailReturn

Extends UseAdaptiveCardReturn (state, controls, cardProps, hostConfig) with:

FieldTypeDescription
cardAdaptiveCardPayloadThe generated Adaptive Card JSON — the primary output.
slotsDocyrusAdaptiveCardSlotsThe resolved slot bindings.
viewReactNodeReady-to-render <AdaptiveCardView> for the generated card.

Type Exports

TypeDescription
UseDocyrusAdaptiveCardItemDetailOptionsHook options.
UseDocyrusAdaptiveCardItemDetailReturnHook return.
DocyrusAdaptiveCardFieldMinimal field shape (slug + name + type, optional enums).
DocyrusAdaptiveCardSlotsResolved slot bindings.
DocyrusAdaptiveCardSlotOverridesSlot override map (string to pin, null to disable).
DocyrusAdaptiveCardFactLayout'facts' | 'stacked'.

See also

On this page