MCPcopy Create free account
hub / github.com/adobe/react-spectrum / CollectionItem

Function CollectionItem

packages/react-aria/stories/dnd/DroppableGrid.tsx:271–327  ·  view source on GitHub ↗
({item, state, dropState, onPaste})

Source from the content-addressed store, hash-verified

269});
270
271function CollectionItem({item, state, dropState, onPaste}) {
272 let rowRef = React.useRef<HTMLDivElement | null>(null);
273 let cellRef = React.useRef<HTMLDivElement | null>(null);
274 let cellNode = [...item.childNodes][0];
275
276 let {rowProps} = useGridRow({node: item}, state, rowRef);
277 let {gridCellProps} = useGridCell(
278 {
279 node: cellNode,
280 focusMode: 'cell'
281 },
282 state,
283 cellRef
284 );
285
286 let dropIndicatorRef = React.useRef<HTMLDivElement | null>(null);
287 let {dropIndicatorProps} = useDropIndicator(
288 {
289 target: {type: 'item', key: item.key, dropPosition: 'on'}
290 },
291 dropState,
292 dropIndicatorRef
293 );
294 let {visuallyHiddenProps} = useVisuallyHidden();
295
296 let {clipboardProps} = useClipboard({
297 onPaste
298 });
299
300 return (
301 <div {...rowProps} ref={rowRef} style={{outline: 'none'}}>
302 <FocusRing focusRingClass={classNames(dndStyles, 'focus-ring')}>
303 <div
304 {...mergeProps(gridCellProps, clipboardProps)}
305 ref={cellRef}
306 className={classNames(dndStyles, 'droppable', {
307 'is-drop-target': dropState.isDropTarget({
308 type: 'item',
309 key: item.key,
310 dropPosition: 'on'
311 }),
312 'is-selected': state.selectionManager.isSelected(item.key)
313 })}>
314 {item.rendered}
315 {!dropIndicatorProps['aria-hidden'] && (
316 <div
317 {...visuallyHiddenProps}
318 role="button"
319 {...dropIndicatorProps}
320 ref={dropIndicatorRef}
321 />
322 )}
323 </div>
324 </FocusRing>
325 </div>
326 );
327}
328

Callers

nothing calls this directly

Calls 9

useGridRowFunction · 0.90
useGridCellFunction · 0.90
useDropIndicatorFunction · 0.90
useVisuallyHiddenFunction · 0.90
useClipboardFunction · 0.90
classNamesFunction · 0.90
mergePropsFunction · 0.90
isDropTargetMethod · 0.80
isSelectedMethod · 0.65

Tested by

no test coverage detected