diff --git a/packages/@react-spectrum/list/docs/ListView.mdx b/packages/@react-spectrum/list/docs/ListView.mdx index 84c39fd67f5..4073cd41253 100644 --- a/packages/@react-spectrum/list/docs/ListView.mdx +++ b/packages/@react-spectrum/list/docs/ListView.mdx @@ -30,6 +30,9 @@ import {Image} from '@react-spectrum/image'; import Info from '@spectrum-icons/workflow/Info'; import {Item, ListView} from '@react-spectrum/list'; import {Link} from '@react-spectrum/link'; +import Copy from '@spectrum-icons/workflow/Copy'; +import Edit from '@spectrum-icons/workflow/Edit'; +import Delete from '@spectrum-icons/workflow/Delete'; ``` --- @@ -363,6 +366,55 @@ This behavior is slightly different in the highlight selection style, where sing ``` + +### Action bar + +An [Action bar](ActionBar.html) can be used when a user needs to perform actions on one or more items at the same time. + +```tsx example keepIndividualImports +import {ActionBar, ActionBarContainer, Item} from '@react-spectrum/actionbar'; + +function Example() { + let items = [ + {key: 0, name: 'Adobe Photoshop'}, + {key: 1, name: 'Adobe Illustrator'}, + {key: 2, name: 'Adobe XD'} + ]; + + let [selectedKeys, setSelectedKeys] = React.useState(new Set([0])); + + return ( + + + {(item) => ( + + {item.name} + + )} + + alert(`Action: ${key}`)} + onClearSelection={() => setSelectedKeys(new Set([]))}> + + + Edit + + + + Copy + + + + Delete + + + + ); +} +``` + ## Drag and drop To enable drag and drop in a ListView, you must provide the drag and drop hooks sourced from to the ListView's `dragAndDropHooks` prop. diff --git a/packages/@react-spectrum/table/docs/TableView.mdx b/packages/@react-spectrum/table/docs/TableView.mdx index ad2591b2064..d62dea8f120 100644 --- a/packages/@react-spectrum/table/docs/TableView.mdx +++ b/packages/@react-spectrum/table/docs/TableView.mdx @@ -21,6 +21,10 @@ import {ActionButton} from '@react-spectrum/button'; import Add from '@spectrum-icons/workflow/Add'; import {Cell, Column, Row, TableView, TableBody, TableHeader} from '@react-spectrum/table'; import {Flex} from '@react-spectrum/layout'; +import Copy from '@spectrum-icons/workflow/Copy'; +import Edit from '@spectrum-icons/workflow/Edit'; +import Delete from '@spectrum-icons/workflow/Delete'; +import {Text} from '@react-spectrum/text'; ``` --- @@ -500,6 +504,71 @@ This behavior is slightly different in the highlight selection style, where sing ``` +### Action bar + +An [Action bar](ActionBar.html) can be used when a user needs to perform actions on one or more rows at the same time. + +```tsx example keepIndividualImports +import {ActionBar, ActionBarContainer, Item} from '@react-spectrum/actionbar'; + +function Example() { + let columns = [ + {name: 'Name', uid: 'name'}, + {name: 'Type', uid: 'type'}, + {name: 'Level', uid: 'level'} + ]; + + let rows = [ + {id: 1, name: 'Charizard', type: 'Fire, Flying', level: '67'}, + {id: 2, name: 'Blastoise', type: 'Water', level: '56'}, + {id: 3, name: 'Venusaur', type: 'Grass, Poison', level: '83'}, + {id: 4, name: 'Pikachu', type: 'Electric', level: '100'} + ]; + + let [selectedKeys, setSelectedKeys] = React.useState(new Set([1])); + + return ( + + + + {column => {column.name}} + + + {item => ( + + {key => {item[key]}} + + )} + + + setSelectedKeys(new Set())} + onAction={(key) => alert(`Action: ${key}`)}> + + + Edit + + + + Copy + + + + Delete + + + + ); +} +``` + ## Sorting TableView supports sorting its data when a column header is pressed. To designate that a Column should support sorting, provide it with