Data Viewports (Table & Cards)
MarkupReactViewport (extending Totoglu\Inertia\MarkupInertia) powers MarkupReactTable (dist/MarkupReactTable.js), MarkupReactCards (dist/MarkupReactCards.js), and any custom pluggable viewport modes registered by downstream modules.
Two Execution Modes
Section titled “Two Execution Modes”- Inertia Page Prop (
$react->configureTable()/$react->configureCards()): Pass directly into$this->inertiaRender(...).toInertiaProp()serializes records, column schemas, filter strips, view modes, and the signedstateToken. - Classic ProcessWire Island (
$react->renderTable()/$react->renderCards()): Render directly inside classic Admin screens, frontend templates, orInputfieldMarkuppanels via___render().
<?php
declare(strict_types=1);
namespace ProcessWire;
$react = React::instance($this);
echo $react->renderTable('pages:template=basic-page, sort=-modified, limit=25', [ 'title' => $this->_('Site Pages'), 'providerOptions' => [ 'showTemplateIcon' => true, 'subtitleField' => 'path', ], 'columns' => [ 'title' => $this->_('Title'), 'modified' => $this->_('Modified'), 'status' => $this->_('Status'), ], 'sortableColumns' => ['title', 'modified', 'status'], 'quickEditEnabled' => true, 'exportEnabled' => true,]);ProviderRegistry & Built-In Data Sources
Section titled “ProviderRegistry & Built-In Data Sources”| Source Descriptor | Adapter Class | Capabilities |
|---|---|---|
'pages:<selector>' or PageArray |
PagesDataProvider |
Runs ProcessWire selectors with safe top-level pagination, enforces viewable()/editable() RBAC, supports iconField, thumbField, subtitleField, showTemplateIcon, and mutates statuses (OP_PUBLISH, OP_DRAFT, OP_TRASH, OP_RESTORE, OP_DELETE, OP_LOCK, OP_UNLOCK). |
'array:<id>' or array / Closure |
ArrayDataProvider |
Wraps in-memory or dynamic array datasets with uniform search, filtering, sorting, pagination, and cell descriptors. |
Custom 'namespace:key' |
ReactDataProviderInterface |
Register lazily via React::deferProviderRegistration() (React::registerProviders hook). |
All 8 Optional Capability Contracts (Totoglu\React\Contract)
Section titled “All 8 Optional Capability Contracts (Totoglu\React\Contract)”Every custom provider implements ReactDataProviderInterface and opts into any combination of the 8 optional capability interfaces to unlock specialized viewport controls automatically:
| Contract Interface | Methods | UI Capabilities Unlocked |
|---|---|---|
ReactFieldSchemaProvider |
filterableFields(), groupableFields(), availableColumns(), inlineEditableFields() |
Dynamic filter dropdowns/pills, group-by selectors, column visibility toggles, inline cell editing |
ReactBulkFieldsProvider |
bulkEditableFields() |
Bulk field edit drawer across selected rows |
ReactQuickEditProvider |
supportsQuickEdit(), saveQuickEdit(), createQuickRecord() |
Slide-over Quick Edit sheet (open_quick_edit, save_quick_edit) and Quick Create modal (quick_create) |
ReactRecordActionsProvider |
recordActions(ReactRecord $record), createAction() |
Per-row action menus and toolbar create button or multi-option createActions |
ReactSummaryProvider |
summaryConfig(), computeSummaries() |
Footer or header KPI totals (sum, avg, counts) |
ReactViewsProvider |
savedViews() |
Preset system filter views in the viewport switcher |
ReactReorderProvider |
isSortable() |
Drag-and-drop row/card reordering (OP_REORDER, OP_MOVE) using lazy dist/ReactDnd.js |
ReactExportProvider |
exportFormats(), export() |
Structured exports alongside formula-injection-safe CSV (MarkupReactViewport::sanitizeCsvCell()) |
ReactRecord DTO & Column Hints
Section titled “ReactRecord DTO & Column Hints”Totoglu\React\Data\ReactRecord standardizes rows and cards with canonical status bitmasks (STATUS_PUBLISHED = 1, STATUS_UNPUBLISHED = 2, STATUS_DRAFT = 2, STATUS_HIDDEN = 4, STATUS_TRASH = 8, STATUS_LOCKED = 16), structured icon, thumb (src, darkSrc, alt, count, aspect), subtitle, badges, isEditableField, and per-column cells descriptors (href, external, copyValue, mono, tabular, nowrap, truncate, maxBadges).
Signed /_react/viewport Lifecycle & Saved Preferences
Section titled “Signed /_react/viewport Lifecycle & Saved Preferences”When an editor searches (/), creates (n), refreshes (r), sorts, filters, edits inline, or exports:
- The client posts
{ stateToken, action, state, payload }to/_react/viewport. ReactGatewayRouterenforces authentication (403), requiresPOST(405), validates$session->CSRF(419) on mutating actions, blocks writes in$config->demo(403), and verifies the HMAC-SHA256stateTokenbound to$user->id.- CSV exports neutralize spreadsheet formula prefixes (
=,+,-,@) viaMarkupReactViewport::sanitizeCsvCell(). ReactViewPreferenceStorepersists each user’s hidden columns, active view mode, page size, sort order, and saved filter views to$user->meta('react_view_prefs_*').