# DataTable on phones

`resources/js/components/tables/DataTable.vue` renders the normal table from `md` (768px) up.
Below that it becomes a **stacked list**: one compact row per record, swipe actions, and a
bottom action sheet. Every index page gets this for free; a few props make it read well.

Examples: `pages/Modules/admin/Users/UsersIndex.vue`, `Roles/RolesIndex.vue`, `Pages/PagesIndex.vue`.

## What a phone row shows

```
┌──────────────────────────────────────────┐
│ [img]  ● Title                         ⋮ │
│        One muted line                    │
│        (badge)                           │
└──────────────────────────────────────────┘
```

- **Title** and **one muted line**: never more. Pick the two things a user scans for.
- **Badge**: one short status/role/type pill (optional).
- **Image**: a square thumbnail (optional).
- **Dot**: the row is new/unread; the title also turns bold (optional).
- **⋮**: shown when the page passes an `#actions` slot. It opens the action sheet.
- Sorting moves into a "Sort by" control above the list (sortable columns only).

## Props

| Prop | Type | What it does on phones |
|---|---|---|
| `mobileCard` | `row => ({ title, subtitle, badge, media, highlight, meta, href })` | Content of the compact row. Without it: first column = title, second = subtitle. `meta`: short text at the end of the title line (e.g. a date). `href`: the subtitle becomes a link in the desktop list. |
| `editRow` | `row => void` or `null` | Swipe toward the end side reveals **Edit** and calls it. Pass `null` when the user can't edit. |
| `editMode` | `"edit"` (default) or `"view"` | Shows the swipe action as Edit (pencil) or View (eye), e.g. for read-only inboxes. |
| `deleteRow` | `row => void` or `null` | Swipe toward the start side reveals **Delete** and calls it. Pass your confirm-modal opener, never a direct delete. `null` hides it. |

"Start"/"end" follow the text direction, so the swipes mirror in RTL.

```vue
<DataTable
    :mobile-card="mobileCard"
    :edit-row="hasPermission('users.edit') ? editRow : null"
    :delete-row="hasPermission('users.delete') ? confirmDelete : null"
    :columns="columns"
    :data="items"
    :meta="pagination"
>
    <template #actions="{ row }"> ...desktop action buttons... </template>
</DataTable>
```

```js
// Phones: compact row (title, one line, badge) and the swipe Edit/View action
const mobileCard = (row) => ({
    title: row.name,
    subtitle: row.email,
    badge: row.roles?.[0]?.display_name || row.roles?.[0]?.name,
});
const editRow = (row) => router.visit(`/admin/users/${row.id}/edit`);
```

## Desktop list (`variant="list"`)

When a record has only one or two real fields (a name and a link, plus a date), a table only
stretches them across the screen. Pass `variant="list"` and desktop shows rows too:

```
┌──────────────────────────────────────────────────────────────┐
│ [A]  Title  (badge)                       2026-10-11  ✎  🗑 │
│      /one-muted-line-or-link                                 │
└──────────────────────────────────────────────────────────────┘
```

- Content comes from `mobileCard` (no `#cell-*` slots); the letter tile is replaced by `media` when given.
- Sorting uses the "Sort by" chips, search stays, pagination hides when there is only one page.
- The `#actions` slot shows at the end of each row, as in the table.
- Phones keep the swipe list and ⋮ sheet as before.

Used by `Pages/PagesIndex.vue`, `LegalPages/LegalPagesIndex.vue` and `Roles/RolesIndex.vue`. Keep the table for records with 3+ fields worth comparing.

## The action sheet (⋮)

The sheet shows the row's summary (image, title, line, badge) and then **the same `#actions`
slot the desktop table uses**, restyled as a list. So:

- Give every action button a `title` (translated): `:title="$t('common.edit')"`. The sheet
  prints it as the label next to the icon. A button without `title` shows only its icon.
- Danger actions keep their `text-red-*` class; the sheet styles them red.
- Disabled-looking actions (e.g. system roles) keep their own classes and checks.
- The sheet closes after the action's own click runs, so navigation and confirm modals still work.

## Rules

- One swipe-open row at a time; new data, a tap elsewhere or opening the sheet closes it.
- Keep `title`/`subtitle` plain strings. For translatable `{ar, en}` values, pick the current
  locale in `mobileCard`, or mark the column `translatable: true` and rely on the default.
- Don't add phone-only markup to the page; everything goes through these props and the slot.
- Check the page at 390px in EN and AR, light and dark, after adding a new index page.
