# All files / src/NextMenu NextMenuItem.tsx

33.33% Statements 4/12
0% Branches 0/28
0% Functions 0/2
50% Lines 4/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    422x
    2x

    2x

    2x

     import React from 'react'
    import { StyledGroup, StyledItem } from './NextMenu.styles'
    import { NextMenuGroupProps, NextMenuItemProps } from './NextMenu.types'

    /**
     *  Default representation of item in menu
     * */
    export const NextMenuItem = React.forwardRef<
      HTMLDivElement,
      NextMenuItemProps<any>
    >(
      (
        { totalSize, ['data-item-index']: itemPositionInList, context, ...props },
        ref
      ) => {
        return (
          <StyledItem
            aria-setsize={context?.items?.length}
            aria-posinset={itemPositionInList + 1}
            ref={ref}
            {...props}
          >
            {context?.getItemLabel?.(context?.items?.[itemPositionInList]) ?? null}
          </StyledItem>
        )
      }
    )

    /**
     *  Default representation of group with items in menu
     * */
    export const NextMenuGroup = React.forwardRef<
      HTMLDivElement,
      NextMenuGroupProps<any>
    >(({ children, ...props }, ref) => {
      return (
        <StyledGroup ref={ref} {...props}>
          {children}
        </StyledGroup>
      )
    })