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 | selectedboolean- The item will be selected if true and unselected if false. |
| Param | idany- The item id. |
Descriptionβ
Toggle a specific item.
resources.toggleAllβ
| Type | Function |
|---|---|
| Param | selectedboolean- All items will be selected if true and unselected if false. |
Descriptionβ
Toggle all items.
resources.toggleAllVisibleβ
| Type | Function |
|---|---|
| Param | selectedboolean- All visible items will be selected if true and unselected if false. |
Descriptionβ
Toggle all visible items.