diff --git a/src/navigation/items/NavDropDownItem.tsx b/src/navigation/items/NavDropDownItem.tsx index a977283..af0799d 100644 --- a/src/navigation/items/NavDropDownItem.tsx +++ b/src/navigation/items/NavDropDownItem.tsx @@ -1,13 +1,23 @@ import * as React from 'react' -export class NavDropDownItem extends React.Component<{label: string}, any> { +import {OnSelectCallback, Payload} from "./OnSelectCallback"; + +export class NavDropDownItem extends React.Component<{label: string, onSelect?: OnSelectCallback, payload?: Payload}, any> { static propTypes() { return { - label: React.PropTypes.string.isRequired + label: React.PropTypes.string.isRequired, + onSelect: React.PropTypes.func, + payload: React.PropTypes.object } } + private handleSelect = () => { + if (this.props.onSelect) { + this.props.onSelect(this.props.payload); + } + }; + render(): React.ReactElement { - return
  • {this.props.label}
  • + return
  • {this.props.label}
  • } } \ No newline at end of file diff --git a/src/navigation/items/NavInfoList.tsx b/src/navigation/items/NavInfoList.tsx index 1bc5b84..5c1ae7f 100644 --- a/src/navigation/items/NavInfoList.tsx +++ b/src/navigation/items/NavInfoList.tsx @@ -1,14 +1,24 @@ import * as React from 'react' -import { NavItem } from "./NavItem"; +import {NavItem} from "./NavItem"; +import {OnClearCallback} from "./OnClearCallback"; -export class NavInfoList extends NavItem<{ label: string }> { +export class NavInfoList extends NavItem<{ id: string, label: string, onClear?: OnClearCallback }> { static propTypes() { return { - label: React.PropTypes.string.isRequired + id: React.PropTypes.string.isRequired, + label: React.PropTypes.string.isRequired, + onClear: React.PropTypes.func } } + private handleClear = () => { + if (this.props.onClear) { + this.props.onClear(this.props.id); + } + }; + + render(): React.ReactElement { const length = React.Children.count(this.props.children); return
  • @@ -22,7 +32,7 @@ export class NavInfoList extends NavItem<{ label: string }> { {this.props.children}
    - Clear Messages + Clear Messages
  • diff --git a/src/navigation/items/OnClearCallback.ts b/src/navigation/items/OnClearCallback.ts new file mode 100644 index 0000000..1b97f31 --- /dev/null +++ b/src/navigation/items/OnClearCallback.ts @@ -0,0 +1,3 @@ +export interface OnClearCallback { + (id: string) +} \ No newline at end of file diff --git a/src/navigation/items/OnSelectCallback.ts b/src/navigation/items/OnSelectCallback.ts new file mode 100644 index 0000000..5e92ea2 --- /dev/null +++ b/src/navigation/items/OnSelectCallback.ts @@ -0,0 +1,11 @@ +export interface Payload { + payload: any; +} + +export interface CommandPayload extends Payload{ + command: string; +} + +export interface OnSelectCallback { + (event: Payload) +} \ No newline at end of file diff --git a/src/navigation/items/SidebarItem.tsx b/src/navigation/items/SidebarItem.tsx index 6b9b0c3..c821ed5 100644 --- a/src/navigation/items/SidebarItem.tsx +++ b/src/navigation/items/SidebarItem.tsx @@ -1,16 +1,17 @@ import * as React from 'react' -export class SidebarItem extends React.Component<{ label: string, icon: string}, any> { +export class SidebarItem extends React.Component<{ label: string, icon: string, route: string}, any> { static propTypes() { return { label: React.PropTypes.string.isRequired, - icon: React.PropTypes.string.isRequired + icon: React.PropTypes.string.isRequired, + route: React.PropTypes.string.isRequired } } render(): React.ReactElement { return
  • - + {this.props.label} diff --git a/src/navigation/items/SidebarListItem.tsx b/src/navigation/items/SidebarListItem.tsx index 8c36ff4..959dfdc 100644 --- a/src/navigation/items/SidebarListItem.tsx +++ b/src/navigation/items/SidebarListItem.tsx @@ -1,15 +1,16 @@ import * as React from 'react' -export class SidebarListItem extends React.Component<{label: string}, any> { +export class SidebarListItem extends React.Component<{label: string, route: string}, any> { static propTypes() { return { - label: React.PropTypes.string.isRequired + label: React.PropTypes.string.isRequired, + route: React.PropTypes.string.isRequired } } render(): React.ReactElement { return
  • - + {this.props.label}
  • diff --git a/src/navigation/items/index.ts b/src/navigation/items/index.ts index 8715cd8..f0b347c 100644 --- a/src/navigation/items/index.ts +++ b/src/navigation/items/index.ts @@ -5,4 +5,6 @@ export * from './NavInfoList' export * from './NavInfoItem' export * from './SidebarItem' export * from './SidebarItemList' -export * from './SidebarListItem' \ No newline at end of file +export * from './SidebarListItem' +export * from './OnSelectCallback' +export * from './OnClearCallback' \ No newline at end of file