X Enterprises
nuxt-x-app

Bulk Action

Toolbar components for applying batch operations to selected table rows — export, delete, assign, and status change.

Bulk Action

Bulk action components sit in a table toolbar and operate on an array of selected rows. Each component is disabled when no rows are selected and emits success/error events so the parent can refresh data and clear the selection.

Components

<XABulkActionExport />

Exports the selected rows to CSV (always available) or JSON (when enableJson is set). Shows a dropdown to choose format when JSON is enabled; otherwise renders a single button that triggers CSV download directly. Fires a toast notification on export and emits the export event with the format and file content.

<XABulkActionExport
  :selected="selectedRows"
  :columns="[
    { key: 'name', label: 'Name' },
    { key: 'email', label: 'Email' },
    { key: 'status', label: 'Status' },
  ]"
  filename="users-export"
  enable-json
/>

Props

PropTypeDefaultDescription
selectedunknown[]Required. Array of selected row data objects.
columnsExportColumn[]Required. Column definitions: { key, label, formatter? }.
filenamestring'export'File name without extension.
labelstring'Export'Button label text.
showLabelbooleantrueShow label text on the button.
enableJsonbooleanfalseAdd a JSON export option to a dropdown menu.
disabledbooleanfalseForce-disable the button regardless of selection.

Emits

EventPayloadDescription
export(format: 'csv' | 'json', content: string)Fired after a successful export with the generated file content.

<XABulkActionDelete />

Renders a red "Delete" button. On click, opens a XAModalConfirm dialog. On confirmation, sends DELETE requests to endpoint for each selected item ID and emits success or error.

<XABulkActionDelete
  :selected="selectedRows"
  endpoint="api/users"
  item-name="users"
  :on-success="() => refresh()"
  :clear-selection="() => (selectedRows = [])"
/>

Props

PropTypeDefaultDescription
selectedunknown[]Required. Array of selected row data objects.
endpointstringRequired. API endpoint path (no leading slash).
idKeystring'id'Key used to extract the ID from each item.
labelstring'Delete'Button label text.
showLabelbooleantrueShow label text on the button.
titlestring'Delete Items'Confirmation modal title.
messagestringOverride the auto-generated confirmation message.
itemNamestring'items'Noun used in the auto-generated confirmation message.
confirmTextstring'Delete'Confirm button label.
cancelTextstring'Cancel'Cancel button label.
disabledbooleanfalseForce-disable the button.
onSuccess() => void | Promise<void>Callback invoked after a successful delete.
clearSelection() => voidCallback to clear the parent selection state.

Emits

EventPayloadDescription
success(ids: (string | number)[])Fired after all deletes succeed.
error(error: unknown)Fired if any delete request fails.
cancelFired when the user cancels the confirmation modal.

<XABulkActionAssign />

Renders a neutral dropdown button listing options. Selecting an option sends a PATCH to endpoint with { [assignField]: value } for each selected item ID.

<XABulkActionAssign
  :selected="selectedRows"
  endpoint="api/tasks"
  :options="[
    { value: 1, label: 'Alice', avatar: '/avatars/alice.png' },
    { value: 2, label: 'Bob' },
  ]"
  item-name="tasks"
  target-name="assignee"
  allow-unassign
  :on-success="() => refresh()"
/>

Props

PropTypeDefaultDescription
selectedunknown[]Required. Array of selected row data objects.
endpointstringRequired. API endpoint path (no leading slash).
optionsAssignOption[]Required. Items to list: { value, label, icon?, avatar? }.
idKeystring'id'Key used to extract the ID from each item.
assignFieldstring'assigneeId'Payload field name for the assignment value.
labelstring'Assign'Button label text.
iconstring'i-lucide-user-plus'Button icon name.
showLabelbooleantrueShow label text on the button.
itemNamestring'items'Noun used in toast messages.
targetNamestring'assignee'Assignment target noun used in toast messages.
disabledbooleanfalseForce-disable the button.
allowUnassignbooleanfalsePrepend an "Unassign" option to the dropdown.
onSuccess() => void | Promise<void>Callback invoked after a successful assignment.
clearSelection() => voidCallback to clear the parent selection state.

Emits

EventPayloadDescription
success(ids: (string | number)[], assigneeId: string | number | null)Fired after all assignments succeed.
error(error: unknown)Fired if any PATCH request fails.

<XABulkActionStatus />

Renders a neutral dropdown listing available statuses. Selecting one sends a PATCH with { [statusField]: value } for each selected item ID.

<XABulkActionStatus
  :selected="selectedRows"
  endpoint="api/orders"
  :statuses="[
    { value: 'active', label: 'Active', icon: 'i-lucide-check' },
    { value: 'archived', label: 'Archived', icon: 'i-lucide-archive' },
  ]"
  item-name="orders"
  :on-success="() => refresh()"
/>

Props

PropTypeDefaultDescription
selectedunknown[]Required. Array of selected row data objects.
endpointstringRequired. API endpoint path (no leading slash).
statusesStatusOption[]Required. Status options: { value, label, icon?, color? }.
idKeystring'id'Key used to extract the ID from each item.
statusFieldstring'status'Payload field name for the status value.
labelstring'Status'Button label text.
showLabelbooleantrueShow label text on the button.
itemNamestring'items'Noun used in toast messages.
disabledbooleanfalseForce-disable the button.
onSuccess() => void | Promise<void>Callback invoked after a successful update.
clearSelection() => voidCallback to clear the parent selection state.

Emits

EventPayloadDescription
success(ids: (string | number)[], status: string)Fired after all status updates succeed.
error(error: unknown)Fired if any PATCH request fails.

AI Context

category: BulkAction
package: "@xenterprises/nuxt-x-app"
components:
  - XABulkActionExport
  - XABulkActionDelete
  - XABulkActionAssign
  - XABulkActionStatus
use-when: >
  User has selected one or more rows in a data table and needs to
  perform a batch operation (export, delete, assign, or change status).
  Place these components in the table toolbar alongside the selection checkbox.
patterns:
  - All components accept a `selected` array and disable themselves when it is empty.
  - API calls use `config.public.x.app.apiUrl` as the base URL.
  - Pass `onSuccess` and `clearSelection` callbacks to refresh data after an operation.
  - Delete uses a confirmation modal; assign and status use inline dropdowns.
Copyright © 2026