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

Function ComboBoxItem

packages/@react-spectrum/s2/src/ComboBox.tsx:469–533  ·  view source on GitHub ↗
(props: ComboBoxItemProps)

Source from the content-addressed store, hash-verified

467} as const;
468
469export function ComboBoxItem(props: ComboBoxItemProps): ReactNode {
470 let ref = useRef(null);
471 let isLink = props.href != null;
472 let {size} = useContext(InternalComboboxContext);
473 return (
474 <ListBoxItem
475 {...props}
476 ref={ref}
477 textValue={
478 props.textValue ||
479 (typeof props.children === 'string' ? (props.children as string) : undefined)
480 }
481 style={pressScale(ref, props.UNSAFE_style)}
482 className={renderProps =>
483 (props.UNSAFE_className || '') + listboxItem({...renderProps, size, isLink}, props.styles)
484 }>
485 {renderProps => {
486 let {children} = props;
487 return (
488 <>
489 <Provider
490 values={[
491 [
492 IconContext,
493 {
494 slots: {
495 icon: {
496 render: centerBaseline({slot: 'icon', styles: iconCenterWrapper}),
497 styles: icon
498 }
499 }
500 }
501 ],
502 [
503 AvatarContext,
504 {
505 slots: {
506 avatar: {size: avatarSize[size], styles: avatar}
507 }
508 }
509 ],
510 [
511 TextContext,
512 {
513 slots: {
514 label: {styles: label({size})},
515 description: {styles: description({...renderProps, size})}
516 }
517 }
518 ]
519 ]}>
520 {!isLink && !props.onAction && (
521 <CheckmarkIcon
522 size={checkmarkIconSize[size]}
523 className={checkmark({...renderProps, size})}
524 />
525 )}
526 {typeof children === 'string' ? <Text slot="label">{children}</Text> : children}

Callers

nothing calls this directly

Calls 2

pressScaleFunction · 0.90
centerBaselineFunction · 0.90

Tested by

no test coverage detected