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

Function TabsMenu

packages/@react-spectrum/s2/src/Tabs.tsx:680–753  ·  view source on GitHub ↗
(
  props: {
    valueId: string;
    items: Array<Node<any>>;
    onSelectionChange: TabsProps['onSelectionChange'];
  } & Omit<TabsProps, 'children'>
)

Source from the content-addressed store, hash-verified

678};
679
680let TabsMenu = (
681 props: {
682 valueId: string;
683 items: Array<Node<any>>;
684 onSelectionChange: TabsProps['onSelectionChange'];
685 } & Omit<TabsProps, 'children'>
686) => {
687 let {id, items, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, valueId} = props;
688 let {
689 density,
690 onSelectionChange: _onSelectionChange,
691 selectedKey,
692 isDisabled,
693 disabledKeys,
694 labelBehavior
695 } = useContext(InternalTabsContext);
696 let onSelectionChange = useCallback(
697 (key: Key | null) => {
698 if (key != null) {
699 _onSelectionChange?.(key);
700 }
701 },
702 [_onSelectionChange]
703 );
704 let state = useContext(TabListStateContext);
705 let allKeysDisabled = useMemo(() => {
706 return isEveryTabDisabled(state?.collection, disabledKeys ? new Set(disabledKeys) : new Set());
707 }, [state?.collection, disabledKeys]);
708 let labelProps = useLabels({
709 id,
710 'aria-label': ariaLabel,
711 'aria-labelledby': ariaLabelledBy
712 });
713
714 return (
715 <div
716 className={style({
717 display: 'flex',
718 flexShrink: 0,
719 alignItems: 'center',
720 height: {
721 density: {
722 compact: 32,
723 regular: 48
724 }
725 }
726 })({density})}>
727 <Picker
728 id={id}
729 valueId={valueId}
730 {...labelProps}
731 aria-describedby={props['aria-describedby']}
732 aria-details={props['aria-details']}
733 isDisabled={isDisabled || allKeysDisabled}
734 density={density!}
735 labelBehavior={labelBehavior}
736 items={items}
737 disabledKeys={disabledKeys}

Callers

nothing calls this directly

Calls 2

useLabelsFunction · 0.90
isEveryTabDisabledFunction · 0.85

Tested by

no test coverage detected