Skip to content

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.

  1. Inertia Page Prop ($react->configureTable() / $react->configureCards()): Pass directly into $this->inertiaRender(...). toInertiaProp() serializes records, column schemas, filter strips, view modes, and the signed stateToken.
  2. Classic ProcessWire Island ($react->renderTable() / $react->renderCards()): Render directly inside classic Admin screens, frontend templates, or InputfieldMarkup panels 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,
]);
UI Primitives and DataViewport components share consistent cards, badges, alerts, tabs, and table typography across light and dark modes.
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())

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:

  1. The client posts { stateToken, action, state, payload } to /_react/viewport.
  2. ReactGatewayRouter enforces authentication (403), requires POST (405), validates $session->CSRF (419) on mutating actions, blocks writes in $config->demo (403), and verifies the HMAC-SHA256 stateToken bound to $user->id.
  3. CSV exports neutralize spreadsheet formula prefixes (=, +, -, @) via MarkupReactViewport::sanitizeCsvCell().
  4. ReactViewPreferenceStore persists each user’s hidden columns, active view mode, page size, sort order, and saved filter views to $user->meta('react_view_prefs_*').

Next steps