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.