import React from 'react' ; import { IndexPath } from '../../devsupport' ; export interface MenuItemDescriptor { index : IndexPath ; groupIndices ? : IndexPath [ ] ; } export class MenuService { public createDescriptorForElement = ( element , index ) : MenuItemDescriptor => { const groupIndices = React . Children . map ( element . props . children , ( ( child , row ) => { return new IndexPath ( row , index ) ; } ) ) ; return { groupIndices , index : new IndexPath ( index ) } ; } ; public createDescriptorForNestedElement = ( groupDescriptor , index ) : MenuItemDescriptor => { return { index : new IndexPath ( index , groupDescriptor . index . row ) , groupIndices : null , } ; } ; }