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

Function PickerItem

packages/@react-spectrum/s2/src/TabsPicker.tsx:342–390  ·  view source on GitHub ↗
(props: PickerItemProps)

Source from the content-addressed store, hash-verified

340 children: ReactNode;
341}
342export function PickerItem(props: PickerItemProps): ReactNode {
343 let ref = useRef(null);
344 let isLink = props.href != null;
345 const size = 'M';
346 // oxlint-disable react/react-compiler
347 return (
348 <ListBoxItem
349 {...props}
350 ref={ref}
351 textValue={
352 props.textValue ||
353 (typeof props.children === 'string' ? (props.children as string) : undefined)
354 }
355 style={pressScale(ref, props.UNSAFE_style)}
356 className={renderProps =>
357 (props.UNSAFE_className || '') + menuitem({...renderProps, size, isLink}, props.styles)
358 }>
359 {renderProps => {
360 let {children} = props;
361 return (
362 <DefaultProvider
363 context={IconContext}
364 value={{
365 slots: {
366 icon: {
367 render: centerBaseline({slot: 'icon', styles: iconCenterWrapper({})}),
368 styles: icon
369 }
370 }
371 }}>
372 <DefaultProvider
373 context={TextContext}
374 value={{
375 slots: {
376 [DEFAULT_SLOT]: {styles: label({size})}
377 }
378 }}>
379 {!isLink && (
380 <CheckmarkIcon size={size} className={checkmark({...renderProps, size})} />
381 )}
382 {typeof children === 'string' ? <Text>{children}</Text> : children}
383 </DefaultProvider>
384 </DefaultProvider>
385 );
386 }}
387 </ListBoxItem>
388 );
389 // oxlint-enable react/react-compiler
390}
391// A Context.Provider that only sets a value if not inside SelectValue.
392function DefaultProvider({
393 context,

Callers

nothing calls this directly

Calls 2

pressScaleFunction · 0.90
centerBaselineFunction · 0.90

Tested by

no test coverage detected