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
📍
options.items
📍
Concern | 📍 Required |
---|---|
Type | Array<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
Type | number |
---|---|
Default | options.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
Type | Object |
---|
Description
An object with useful properties for controlling the state of a BulkAction
component and its associated items.
resources.items
Type | Array<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
resources.isEveryItemSelected
resources.isEveryVisibleItemSelected
resources.isEveryVisibleItemUnselected
resources.hasOnlyAFewItemsSelected
resources.total
resources.totalSelected
resources.clear
resources.toggle
Type | Function |
---|---|
Param | selected boolean - The item will be selected if true and unselected if false . |
Param | id any - The item id . |
Description
Toggle a specific item.
resources.toggleAll
Type | Function |
---|---|
Param | selected boolean - All items will be selected if true and unselected if false . |
Description
Toggle all items.
resources.toggleAllVisible
Type | Function |
---|---|
Param | selected boolean - All visible items will be selected if true and unselected if false . |
Description
Toggle all visible items.