# `LedgerUI.Components.BulkBar`
[🔗](https://github.com/devaction-labs/ledger_ui/blob/v0.2.0/lib/ledger_ui/components/bulk_bar.ex#L1)

The bar of bulk actions for a table with selection: how many are selected, optional fields,
buttons for the actions and a close that clears the selection. It shows only while `count` is
above zero.

    <.bulk_bar
      id="orders-bulk"
      count={@count}
      label="selecionado"
      label_plural="selecionados"
      total={@total}
      on_select_all="select_all"
      on_clear="clear_selection"
    >
      <:action icon="file" phx-click="issue">Emitir NF-e</:action>
      <:action icon="download" phx-click="export">Exportar</:action>
      <:action variant="danger" icon="trash" phx-click="delete" confirm="Excluir 3 pedidos?"
        confirm_text="Os rascunhos somem para todos." confirm_label="Excluir" cancel_label="Cancelar">
        Excluir
      </:action>
    </.bulk_bar>

Texts come from outside (`label`, `label_plural`, `select_all_label` with `%{total}`,
`clear_label`); nothing is pluralized here.

## Looks

  * `inverse` (default), `soft` and `solid`: the `lu-selbar` pill (dark, accent-soft and teal).
  * `inline`: the strip at the top of a table (`lu-panel` tinted with the accent): a checkbox
    that clears the selection, the count, "select all" and the buttons.

  * `float` (`lu-bulkfloat`, the canvas template's bar): a dark pill absolutely positioned at the
    bottom center of the closest positioned ancestor (the app shell), with the count, one
    `:action` per button (`variant="danger"` is red and set apart by a rule) and the close. It
    ignores `floating`, `progress` and the `confirm` of an action (the action runs at once).

`floating` (default) pins a pill to the bottom center of the viewport; `floating={false}` lays
it out where it is (a bar inside a card or a toolbar). `progress`/`progress_max` turn the bar
into a progress bar while a bulk action runs. Esc runs `on_clear` (`phx-window-keydown`).

An `:action` with `confirm` opens a small card first (above the bar when floating, below
otherwise); only its confirm button runs the action's `phx-click`. A `disabled` action keeps the
focus (`aria-disabled`) and renders no `phx-*` attributes.

`selection_bar/1` is the same bar with `floating` off by default.

# `bulk_bar`

## Attributes

* `id` (`:string`) (required)
* `count` (`:integer`) (required) - How many are selected; the bar shows only above zero.
* `label` (`:string`) - The text after the count, for one selected. Defaults to `"selected"`.
* `label_plural` (`:string`) - Defaults to `nil`.
* `total` (`:integer`) - How many there are in all (every page). Defaults to `nil`.
* `select_all_label` (`:string`) - Defaults to `"Select all %{total}"`.
* `on_clear` (`:any`) - Defaults to `nil`.
* `on_select_all` (`:any`) - Defaults to `nil`.
* `target` (`:any`) - Defaults to `nil`.
* `clear_label` (`:string`) - Defaults to `"Clear selection"`.
* `check_label` (`:string`) - `aria-label` of the `inline` checkbox. Defaults to `"Selection"`.
* `show_esc` (`:boolean`) - Defaults to `false`.
* `variant` (`:string`) - Defaults to `"inverse"`. Must be one of `"inverse"`, `"soft"`, `"solid"`, `"inline"`, or `"float"`.
* `floating` (`:boolean`) - Defaults to `true`.
* `progress` (`:integer`) - Defaults to `nil`.
* `progress_max` (`:integer`) - Defaults to `nil`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.
## Slots

* `action` - A button. Accepts attributes:

  * `variant` (`:string`) - Must be one of `"default"`, `"primary"`, or `"danger"`.
  * `disabled` (`:boolean`)
  * `icon` (`:string`)
  * `confirm` (`:string`)
  * `confirm_text` (`:string`)
  * `confirm_label` (`:string`)
  * `cancel_label` (`:string`)
  * `id` (`:string`)
  * `title` (`:string`)
  * `aria-label` (`:string`)
  * `phx-click` (`:any`)
  * `phx-target` (`:any`)
  * `phx-disable-with` (`:string`)
  * `phx-value-id` (`:any`)
* `field` - A control (a select, an input) in the bar.

# `selection_bar`

The selection pill: `bulk_bar/1` laid out in place (not floating) by default.
## Attributes

* `id` (`:string`) - Defaults to `"selection-bar"`.
* `count` (`:integer`) (required)
* `label` (`:string`) - Defaults to `"selected"`.
* `label_plural` (`:string`) - Defaults to `nil`.
* `variant` (`:string`) - Defaults to `"inverse"`. Must be one of `"inverse"`, `"soft"`, `"solid"`, or `"inline"`.
* `floating` (`:boolean`) - Defaults to `false`.
* `on_clear` (`:any`) - Defaults to `nil`.
* `clear_label` (`:string`) - Defaults to `"Clear selection"`.
* `target` (`:any`) - Defaults to `nil`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.
## Slots

* `action`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
