feat(ToolbarBatchActions): Allow showing the toolbar even if there are no selected items.

Fixes #1438.

Maintains current behavior but allows for an over-ride to ensure the toolbarbatchactions bar does not close when the user has unselected all items.

Example Useage:
```
<Toolbar>
    <ToolbarContent>
        <ToolbarBatchActions show={true}>
         ....
        </ToolbarBatchActions>
    </ToolbarContent>
</Toolbar>
```
This commit is contained in:
naegelin 2022-08-11 13:33:54 -04:00 committed by GitHub
commit 375654a283
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,12 +6,18 @@
export let formatTotalSelected = (totalSelected) => export let formatTotalSelected = (totalSelected) =>
`${totalSelected} item${totalSelected === 1 ? "" : "s"} selected`; `${totalSelected} item${totalSelected === 1 ? "" : "s"} selected`;
/**
* Set to `true` to show the ToolbarBatchActions regardless of row selection
* @type {boolean}
*/
export let show = false;
import { onMount, getContext } from "svelte"; import { onMount, getContext } from "svelte";
import Button from "../Button/Button.svelte"; import Button from "../Button/Button.svelte";
let batchSelectedIds = []; let batchSelectedIds = [];
$: showActions = batchSelectedIds.length > 0; $: showActions = batchSelectedIds.length > 0 || show;
const ctx = getContext("DataTable"); const ctx = getContext("DataTable");
const unsubscribe = ctx.batchSelectedIds.subscribe((value) => { const unsubscribe = ctx.batchSelectedIds.subscribe((value) => {