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

Function ListViewItem

packages/@react-spectrum/s2/src/ListView.tsx:857–1029  ·  view source on GitHub ↗
(props: ListViewItemProps)

Source from the content-addressed store, hash-verified

855}
856
857export function ListViewItem(props: ListViewItemProps): ReactNode {
858 let ref = useRef(null);
859 let {hasChildItems, ...otherProps} = props;
860 let isLink = props.href != null;
861 let isLinkOut = isLink && props.target === '_blank';
862 let {
863 isQuiet,
864 selectionStyle,
865 overflowMode,
866 scale,
867 hideLinkOutIcon = false
868 } = useContext(InternalListViewContext);
869 let textValue =
870 props.textValue || (typeof props.children === 'string' ? props.children : undefined);
871 let {direction} = useLocale();
872 let hasTrailingIcon = hasChildItems || (isLinkOut && !hideLinkOutIcon);
873
874 return (
875 <GridListItem
876 {...otherProps}
877 textValue={textValue}
878 ref={ref}
879 {...(hasTrailingIcon ? {'data-has-trailing-icon': ''} : {})}
880 className={renderProps =>
881 listitem({
882 ...renderProps,
883 isLink,
884 isQuiet,
885 scale,
886 selectionStyle,
887 isPrevNotSelected: !isPrevSelected(renderProps.id, renderProps.state),
888 isNextSelected: isNextSelected(renderProps.id, renderProps.state),
889 isNextNotSelected: !isNextSelected(renderProps.id, renderProps.state),
890 isFirstItem: isFirstItem(renderProps.id, renderProps.state),
891 isLastItem: isLastItem(renderProps.id, renderProps.state)
892 })
893 }>
894 {renderProps => {
895 let {children} = props;
896 let {
897 selectionMode,
898 selectionBehavior,
899 isDisabled,
900 id,
901 state,
902 allowsDragging,
903 isFocusVisibleWithin
904 } = renderProps;
905 return (
906 <Provider
907 values={[
908 [
909 TextContext,
910 {
911 slots: {
912 [DEFAULT_SLOT]: {styles: label({...renderProps, overflowMode})},
913 label: {styles: label({...renderProps, overflowMode})},
914 description: {styles: description({...renderProps, overflowMode})}

Callers

nothing calls this directly

Calls 6

useLocaleFunction · 0.90
centerBaselineFunction · 0.90
isLastItemFunction · 0.85
isPrevSelectedFunction · 0.70
isNextSelectedFunction · 0.70
isFirstItemFunction · 0.70

Tested by

no test coverage detected