UNPKG

catreact

Version:

Catavolt Core React Components

42 lines (41 loc) 2.06 kB
/** * Created by rburson on 3/11/16. */ import * as React from 'react'; import { CvContext, CvActionBaseProps } from './catreact-core'; import { MenuDef } from 'catavolt-sdk'; import { CvActionBaseState } from "./CvAction"; export declare var CvMenuItemBase: { getChildContext: () => any; }; export interface CvMenuItemState extends CvActionBaseState { } export interface CvMenuItemProps extends CvActionBaseProps { /** * If no menuDef property and no actionId property is provided, the render method will * render all child MenuDefs of the given parentMenuItem (or attempt to find it in scope) */ parentMenuItem?: MenuDef; /** * If provided, each 'child' sdk {MenuDef} of the current MenuDef is passed to the function, which should return a a component * to be rendered. The function should accept 2 params: * * @param cvContext The current {@link CvContext}. The cvContext.cvScope.scopeObj will be the current sdk {MenuDef} * @param menuItem A child sdk {MenuDef} of the current MenuDef */ subMenuItemRenderer?: (cvContext: CvContext, menuItem: MenuDef) => {}; } /** * There are several ways to use CvMenuItem * * 1. Simple wrapper - Provide an actionId OR menuItem and (optionally) a wrapperElem and wrapperElemProps. * This will render your child tags wrapped in wrapperElem with an onClick that fires 'this' action * 1. Function for submenus - Provide an actionId OR menuItem and a subMenuItemRenderer * see {@link CvMenuItemProps.subMenuItemRenderer}. * Providing this function will allow you to render all 'child' MenuDefs (but not 'this' MenuDef). * The result will be wrapped in wrapperElem (if provided) * 1. Recursive rendering of child menus - Omit both an actionId and menuItem and (optionally) specify a parentMenuItem * The render method will render each child of the parentMenuItem (provided or found in scope) passing along all * additional properties to new child {@link CvMenuItem}s */ export declare var CvMenuItem: React.ClassicComponentClass<CvMenuItemProps>;