Skip to main content

useBulkActions

A hook that makes available several pieces of information and functions to handle the BulkActions state management and your interactions with listed data.

Import​

import { useBulkActions } from '@resultadosdigitais/tangram-components'

Params​

options πŸ“β€‹

Concern
πŸ“ Required
TypeObject

Description​

The hook options.

options.items πŸ“β€‹

Concern
πŸ“ Required
TypeArray<Object>

Description​

The list of items available to selection. Is required that the objects from the array have the property id with a unique value to the item.

options.total​

Typenumber
Defaultoptions.items.length

Description​

The total number of items. Should include the number of visible and invisible (paginated) items, if exists. If not defined, it will be the length of the items param.

Returns​

resources​

TypeObject

Description​

An object with useful properties for controlling the state of a BulkAction component and its associated items.

resources.items​

TypeArray<Object>

Description​

Copy from items property with each item receiving the property selected with a boolean value. If you want to initialize with some item selected you can add the selected property to true.

resources.selectedIds​

TypeArray

Description​

List with selected visible items ids.

resources.isEveryItemSelected​

Typeboolean

Description​

Indicates if every item is selected.

resources.isEveryVisibleItemSelected​

Typeboolean

Description​

Indicates if every visible item is selected.

resources.isEveryVisibleItemUnselected​

Typeboolean

Description​

Indicates if every visible item is unselected.

resources.hasOnlyAFewItemsSelected​

Typeboolean

Description​

Indicates if has only a few items selected.

resources.total​

Typenumber

Description​

Total items.

resources.totalSelected​

Typenumber

Description​

Total selected items.

resources.clear​

TypeFunction

Description​

Clear any selection.

resources.toggle​

TypeFunction
Paramselectedboolean- The item will be selected if true and unselected if false.
Paramidany- The item id.

Description​

Toggle a specific item.

resources.toggleAll​

TypeFunction
Paramselectedboolean- All items will be selected if true and unselected if false.

Description​

Toggle all items.

resources.toggleAllVisible​

TypeFunction
Paramselectedboolean- All visible items will be selected if true and unselected if false.

Description​

Toggle all visible items.

Feedback​