useDocyrusAdaptiveCardItemList
Generate an array of Adaptive Card JSON payloads from a Docyrus field list + many records, and render them as a responsive grid, a stacked list, or a single Carousel card with the shared AdaptiveCard renderer.
Installation
pnpm dlx @docyrus/cli add @docyrus/hooks-use-docyrus-adaptive-card-item-listpnpm add reactOverview
useDocyrusAdaptiveCardItemList is the list companion of
useDocyrusAdaptiveCardItemDetail.
You hand it a Docyrus field list + a list of records and it generates one
Adaptive Card JSON payload per record (cards) — mapping Docyrus field types
onto the Adaptive Cards element vocabulary — then renders them with the shared
AdaptiveCard renderer.
Both hooks share the same backend-agnostic mapper, so a card looks identical whether it's shown alone (detail) or in a list. Four layouts are supported:
grid(default) — a responsive CSS grid of cards (auto-fill or fixed columns).list— a single stacked column of cards.carousel— one combined Adaptive Card whoseCarouselpages are the per-record bodies.table— one combined Adaptive Card whoseTablehas a field-label header row and one row per record (scalar fields become columns; images / rich-text / code are excluded). The table scrolls horizontally when it's wider than its container.
When a DocyrusTenantProvider is mounted,
dates / numbers / currency are formatted with the tenant's preferences.
See useDocyrusAdaptiveCardItemDetail
for the full field-type → element mapping and slot-detection rules.
Usage
Render a responsive grid of cards
'use client';
import { useDocyrusAdaptiveCardItemList } from '@docyrus/ui/hooks/use-docyrus-adaptive-card-item-list';
export function DealGallery({ fields, records }) {
const { view } = useDocyrusAdaptiveCardItemList({
fields,
records,
layout: 'grid',
columns: 'flex',
minCardWidth: 340
});
return view;
}Per-card actions + scoped click handler
onItemAction receives the originating record and index, so one handler routes
every card (not applied in carousel layout).
const { view } = useDocyrusAdaptiveCardItemList({
fields,
records,
getItemActions: (record) => [
{ type: 'Action.OpenUrl', title: 'Open', url: `/deals/${record.id}` }
],
onItemAction: (event, record) => {
if (event.type === 'openUrl') router.push(event.url);
}
});Use the generated JSON array directly
const { cards, items } = useDocyrusAdaptiveCardItemList({ fields, records });
// `cards` is AdaptiveCardPayload[] — one per record
// `items` is [{ id, record, card }] if you need the record alongside its card
await syncToTeams(cards);Carousel
const { view, carouselCard } = useDocyrusAdaptiveCardItemList({
fields,
records,
layout: 'carousel'
});
// `carouselCard` is the single combined AdaptiveCardPayload (a Carousel).
return view;Table
const { view, tableCard } = useDocyrusAdaptiveCardItemList({
fields,
records,
layout: 'table'
});
// `tableCard` is the single combined AdaptiveCardPayload (a Table:
// header row = field labels, one row per record). Scrolls horizontally
// when wider than its container.
return view;API Reference
UseDocyrusAdaptiveCardItemListOptions
| Option | Type | Default | Description |
|---|---|---|---|
fields | DocyrusAdaptiveCardField[] | — | Field metadata (accepts IField / DataSourceField / DocyrusFieldLike). |
records | Record<string, unknown>[] | null | — | Records to render as cards. |
enumOptions | Record<string, EnumOption[]> | — | Per-field-slug enum options. Falls back to each field's inline enums. |
slots | DocyrusAdaptiveCardSlotOverrides | — | Slot bindings shared by every card. |
includeFields | string[] | — | Explicit, ordered body field list. |
excludeFields | string[] | — | Field slugs to drop from every card body. |
hideEmpty | boolean | true | Drop empty fields instead of rendering an em-dash. |
factLayout | 'facts' | 'stacked' | 'facts' | Scalar layout — a FactSet or stacked label/value blocks. |
version | string | '1.5' | Adaptive Card schema version. |
getRecordId | (record, index) => string | record.id → index | Stable key per record. |
getItemTitle | (record, index) => string | undefined | — | Per-card title override. |
getItemActions | (record, index) => AdaptiveCardAction[] | undefined | — | Per-card actions. |
onItemAction | (event, record, index) => void | — | Action handler scoped to the record. Not applied in carousel. |
layout | 'grid' | 'list' | 'carousel' | 'table' | 'grid' | Rendered layout. carousel / table produce one combined card. |
columns | number | 'flex' | 'flex' | Grid columns. 'flex' auto-fills using minCardWidth. |
minCardWidth | number | 320 | Minimum card width (px) for the 'flex' grid. |
gap | number | 16 | Gap (px) between cards. |
className | string | — | Class for the list container. |
cardClassName | string | — | Class for each card wrapper. |
emptyContent | ReactNode | built-in | Shown when there are no records. |
formatDate / formatDateTime / formatNumber | function | tenant context | Override formatters. |
hostConfig | AdaptiveCardHostConfigOverride | — | Forwarded to every rendered card. |
customElements | Record<string, ElementRenderer> | — | Forwarded to every rendered card. |
UseDocyrusAdaptiveCardItemListReturn
| Field | Type | Description |
|---|---|---|
cards | AdaptiveCardPayload[] | The generated Adaptive Card JSON payloads — the primary output. |
items | DocyrusAdaptiveCardListItem[] | { id, record, card } per record. |
slots | DocyrusAdaptiveCardSlots | Slot bindings shared by every card. |
carouselCard | AdaptiveCardPayload | null | Combined Carousel card in carousel layout, else null. |
view | ReactNode | Ready-to-render list element. |
Type Exports
| Type | Description |
|---|---|
UseDocyrusAdaptiveCardItemListOptions | Hook options. |
UseDocyrusAdaptiveCardItemListReturn | Hook return. |
DocyrusAdaptiveCardListItem | { id, record, card }. |
DocyrusAdaptiveCardListLayout | 'grid' | 'list' | 'carousel'. |
DocyrusAdaptiveCardField | Minimal field shape. |
DocyrusAdaptiveCardSlots / DocyrusAdaptiveCardSlotOverrides | Slot bindings / overrides. |
DocyrusAdaptiveCardFactLayout | 'facts' | 'stacked'. |
See also
useDocyrusAdaptiveCardItemDetail— single-record detail card + the full mapping table.AdaptiveCard— the renderer.
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 AdaptiveCard renderer.
useDocyrusAgentAttachments
useDocyrusAgentAttachments hook.