# Data Explorer (Lumen Halo): prompt.md (v1.0.0)

- id: `lumen-data-explorer` · version 1.0.0 · component · pro (All-Access)
- category: Data
- build: Base UI (one set of files; its dependencies follow the build)
- install (this build): `npx shadcn@latest add @beautiful-ui-pro/lumen-data-explorer`
- npm dependencies: @tanstack/react-table@^9
- registry dependencies: utils, @beautiful-ui-pro/lumen-filter-bar, @beautiful-ui/lumen-state-panel, @beautiful-ui-pro/lumen-bulk-action-bar, @beautiful-ui/lumen-adapters, @beautiful-ui/lumen-checkbox, @beautiful-ui-pro/lumen-popover, @beautiful-ui/lumen-button, https://beautiful-ui.dev/r/lumen-foundation.json
- docs: https://beautiful-ui.dev/components/lumen-data-explorer
- The install command carries everything this item needs (files, CSS, tokens, npm and registry dependencies). Prefer it to copying source by hand.

A table people can search, filter, sort, page, select and act on. It shows loading, empty, zero-results and error states in words, turns into cards on narrow screens, drives a chart region from every filtered row, and opens rows in a drawer. TanStack Table v9 underneath; your columns are a small plain spec.

## Build it
- Stack: React 19 (`ref` is a plain prop), TypeScript, Tailwind CSS v4 utilities, a shadcn-initialised project with the `@/*` alias.
- Packages: `@tanstack/react-table@^9`.
- Files: `components/ui/lumen/controls/data-explorer.tsx`; shared code: `lib/beautiful-ui/core/filters.ts`, `lib/beautiful-ui/core/states.ts`, `lib/beautiful-ui/core/views.ts`.
- Registry dependencies, installed with it automatically: shadcn `utils` (cn), `lumen-filter-bar`, `lumen-state-panel`, `lumen-bulk-action-bar`, `lumen-adapters`, `lumen-checkbox`, `lumen-popover`, `lumen-button`, `lumen-foundation`.
- Builds: one set of files for both, but its dependencies come in Base UI and Radix builds. Install the one that matches the project (see Install): a free item's bare URL installs the Base UI build of it and its dependencies.
- Exports to keep: `DataExplorer`, `DataExplorerToolbar`, `DataExplorerChart`, `DataExplorerTable`, `DataExplorerPagination`, `DataExplorerBulkActions`, and every exported type.
- CSS: the install merges this item's rules (the registry `css` field) into your global stylesheet, in `@layer components`, and adds the lumen foundation (tokens, keyframes, motion levels) once. Nothing to import by hand.
- Re-running `add` (or `--overwrite`) re-applies those rules: put overrides in your own CSS, never in the installed rules.
- Tokens: retheme with the `--lumen-*` custom properties (`--lumen-accent`, `--lumen-accent-text`, `--lumen-bad`, `--lumen-bad-text`, `--lumen-focus`, `--lumen-good`, `--lumen-good-text`, `--lumen-hairline`, `--lumen-ink`, `--lumen-muted-ink`, `--lumen-series-1`, `--lumen-series-2`, `--lumen-series-3`, `--lumen-series-4`, `--lumen-series-5`, `--lumen-series-6`, `--lumen-warn`, `--lumen-warn-text`); this item's CSS also reads `--lumen-font-mono`, `--lumen-font-sans`, `--lumen-radius-k`. Never add Tailwind colour classes inside the component.

```tsx
import { DataExplorer, DataExplorerToolbar, DataExplorerTable, DataExplorerPagination, DataExplorerBulkActions, type ExplorerColumn } from "@/components/ui/lumen/controls/data-explorer";
```

## Parts

| Part | data-slot | What it is for |
|---|---|---|
| `DataExplorer` | — | State: data, filters, sort, pages, selection, density. |
| `DataExplorerToolbar` | — | Filter Bar, Columns menu, density. |
| `DataExplorerChart` | — | A region fed every filtered row. |
| `DataExplorerTable` | — | The table, or cards when narrow, inside the State Panel. |
| `DataExplorerPagination` | — | Range, rows per page, previous and next. |
| `DataExplorerBulkActions` | — | Bulk actions for the selection. |

## Sound
- Keep every `data-slot` and `data-sound` attribute: the sound layer reads them.
- Installing this item adds no audio. Nothing plays until the app mounts `GlassSoundProvider` once (install: `npx shadcn@latest add https://beautiful-ui.dev/r/glass-sound.json`, import from `@/components/beautiful-ui/glass-sound`); `GlassSoundToggle` is its mute control. Without a provider the audio engine never loads.

## Match the original
- Read `components/ui/lumen/controls/data-explorer.tsx` as the reference implementation before changing or recreating anything, and match it: sizes, colours per theme, motion timings, copy and behaviour.
- If you deviate (a prop you can't honour, a style you changed, a dependency you swapped), say so in your reply, part by part.
- Keep the accessibility contract, the keyboard map and the motion levels listed below.

## Use it when
- data table, data grid, table with filters, sortable table, paginated table, row selection, bulk actions, server table, TanStack table, Lumen
- Lists of records people search, narrow, compare and act on: accounts, orders, users, incidents

### Not when
- A few rows of static facts: use Lumen Table
- Spreadsheet-style cell editing: use a grid built for editing

## Mistakes
- Keep columns (and features you pass) stable: define them outside the component or memoise
- In server mode, report rowCount so pagination knows when to stop

## Usage

```tsx
import { DataExplorer, DataExplorerToolbar, DataExplorerTable, DataExplorerPagination, DataExplorerBulkActions, type ExplorerColumn } from "@/components/ui/lumen/controls/data-explorer";
import { BulkAction } from "@/components/ui/lumen/controls/bulk-action-bar";

const columns: ExplorerColumn<Account>[] = [
  { id: "name", header: "Account", value: (a) => a.name, primary: true },
  { id: "mrr", header: "MRR", value: (a) => a.mrr, align: "end", mono: true, format: (v) => money(v as number) },
];

<DataExplorer data={accounts} columns={columns} getRowId={(a) => a.id} fields={fields} accessors={accessors} selectable onRowOpen={(a) => open(a.id)}>
  <DataExplorerToolbar />
  <DataExplorerTable caption="Accounts" />
  <DataExplorerPagination />
  <DataExplorerBulkActions>{(ids) => <BulkAction onSelect={() => archive(ids)}>Archive</BulkAction>}</DataExplorerBulkActions>
</DataExplorer>
```

## Props

| Prop | Type | Default | What it does |
|---|---|---|---|
| `columns[].pinned / resizable / minWidth` | `"start" / boolean / number` |  | Keep a column in view when the table scrolls sideways; let people drag (or arrow) its edge to resize it. |
| `DataExplorerTable columnWidths / defaultColumnWidths / onColumnWidthsChange` | `Record<id, number>` |  | Column widths after resizing (controlled or not), to save with a view. |
| `paginate + DataExplorerTable virtualize` | `boolean / { height, rowHeight? }` |  | paginate={false} with virtualize renders only the rows in view: thousands of rows, with the keyboard still walking every one. |
| `data / columns / getRowId` | `Row[] / ExplorerColumn<Row>[] / (row) => string` |  | Rows, a plain column spec (id, header, value, cell, format, align, mono, sortable, hideable, hidden, primary, width) and a stable id. Keep columns stable. |
| `fields / accessors` | `FilterField[] / FilterAccessors<Row>` |  | Filters for the toolbar's Filter Bar, and how to read them from a row (client mode). |
| `filters / sorting / columnVisibility / rowSelection` | `controlled or default*` |  | Each can be controlled with its on*Change, or left to the explorer (defaultFilters, defaultSorting). |
| `selectable` | `boolean` |  | A checkbox column and the bulk actions. |
| `manual / onQueryChange` | `{ rowCount, totalCount? } / (query) => void` |  | Server mode: data is the current page, already filtered and sorted; you fetch for each query. |
| `loading / error / forbidden / neverUsed / partial / onRetry` | `facts` |  | The State Panel picks one state from these, in words, with a retry or clear-filters step. |
| `onRowOpen` | `(row, rows) => void` |  | Enter or a click on a row; rows is every row in view order, for a drawer's previous/next. |
| `density / mobileAt / noun / labels` | `…` |  | "comfortable" \| "compact"; the card breakpoint (px of the explorer, default 640); the row noun; every word for i18n. |
| `DataExplorerChart children` | `(rows) => ReactNode` |  | A region that sees every filtered row, not just the page. |
| `DataExplorerBulkActions children` | `(selectedIds) => ReactNode` |  | Bulk Actions for the selection; destructive ones confirm. |
| `useDataExplorer()` | `hook` |  | Rows in view, counts, filters, selection, state, and viewState / applyViewState for Saved Views, for your own parts inside the explorer. |

Full docs: https://beautiful-ui.dev/components/lumen-data-explorer

## Customising
- Colours: set the `--lumen-*` tokens on `:root`, or on a container with the `lumen-scope` class to retheme one area. Add the `lumen-inherit` class to follow your shadcn palette instead (`--chart-N`, `--destructive`).
- Dark mode follows the `.dark` class on an ancestor (the shadcn and next-themes convention).
- Update later by re-running the install with `--overwrite` (review the diff if you edited it). Changelog: https://beautiful-ui.dev/r/changelog.json

## Keyboard

| Keys | Action |
|---|---|
| ↑ / ↓ · Home / End | Move between rows |
| Enter | Open the row |
| Space | Select the row |
| Tab | Toolbar, table, pagination |

## Motion inventory

| Interaction | What moves |
|---|---|
| Sort | A filament lights under the sorted column's head |
| Select | Selected rows wash in the accent; the bulk bar rises in |

## Accessibility contract (preserve when editing)
- A real table: sortable heads are buttons with aria-sort on the column
- Rows are one tab stop: arrows move, Enter opens, Space selects
- Select-all is a mixed-state checkbox; every row checkbox is named by its row
- States are words (State Panel); the range and result count are polite live regions

## Install

```bash
npx shadcn@latest add @beautiful-ui-pro/lumen-data-explorer
```

Pro item: needs the `@beautiful-ui-pro` registry in `components.json` and `BEAUTIFUL_UI_TOKEN` in `.env.local` (https://beautiful-ui.dev/account). Setup: https://beautiful-ui.dev/docs/pro. Your components.json `style` picks the build: radix-*, new-york and default get Radix, base-* gets Base UI.

## Credits
- TanStack Table (https://tanstack.com/table)
- Built on shadcn/ui (https://ui.shadcn.com)

The lumen foundation (the tokens listed above, keyframes and motion levels) installs once with the first component; its CSS is public at https://beautiful-ui.dev/r/lumen-foundation.json.
