(props: any)
| 22 | import {useListState} from 'react-stately/useListState'; |
| 23 | |
| 24 | export function Grid(props: any): JSX.Element { |
| 25 | let {gridFocusMode = 'row', cellFocusMode = 'child'} = props; |
| 26 | let state = useListState(props); |
| 27 | let gridState = useGridState({ |
| 28 | ...props, |
| 29 | selectionMode: 'multiple', |
| 30 | collection: React.useMemo( |
| 31 | () => |
| 32 | new GridCollection({ |
| 33 | columnCount: 1, |
| 34 | items: [...state.collection].map(item => ({ |
| 35 | type: 'item', |
| 36 | childNodes: [ |
| 37 | { |
| 38 | ...item, |
| 39 | index: 0, |
| 40 | type: 'cell' |
| 41 | } |
| 42 | ] |
| 43 | })) |
| 44 | }), |
| 45 | [state.collection] |
| 46 | ) |
| 47 | }); |
| 48 | |
| 49 | let ref = React.useRef(null); |
| 50 | let {gridProps} = useGrid( |
| 51 | { |
| 52 | 'aria-label': 'Grid', |
| 53 | focusMode: gridFocusMode |
| 54 | }, |
| 55 | gridState, |
| 56 | ref |
| 57 | ); |
| 58 | |
| 59 | return ( |
| 60 | <div {...gridProps} ref={ref}> |
| 61 | {[...gridState.collection].map(item => ( |
| 62 | <Row key={item.key} state={gridState} item={item} focusMode={cellFocusMode} /> |
| 63 | ))} |
| 64 | </div> |
| 65 | ); |
| 66 | } |
| 67 | |
| 68 | function Row({state, item, focusMode}) { |
| 69 | let rowRef = React.useRef(null); |
nothing calls this directly
no test coverage detected