rmwc
Version:
A thin React wrapper for Material Design (Web) Components
220 lines (219 loc) • 8.94 kB
TypeScript
import { CustomEventT } from '../Base';
import * as React from 'react';
/****************************************************************
* Private
****************************************************************/
export declare const MenuRoot: {
new <P>(props: any, context?: any): {
render(): React.ReactElement<any> | null;
setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: any) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
forceUpdate(callBack?: (() => void) | undefined): void;
props: Readonly<{
children?: React.ReactNode;
}> & Readonly<any>;
state: Readonly<{}>;
context: any;
refs: {
[key: string]: React.ReactInstance;
};
};
displayName: string;
defaultProps: {
tag: string | React.ComponentClass<any> | React.StatelessComponent<any>;
constructor: Function;
toString(): string;
toLocaleString(): string;
valueOf(): Object;
hasOwnProperty(v: string | number | symbol): boolean;
isPrototypeOf(v: Object): boolean;
propertyIsEnumerable(v: string | number | symbol): boolean;
};
isSimpleTag: boolean;
};
export declare const MenuItems: {
new <P>(props: any, context?: any): {
render(): React.ReactElement<any> | null;
setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: any) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
forceUpdate(callBack?: (() => void) | undefined): void;
props: Readonly<{
children?: React.ReactNode;
}> & Readonly<any>;
state: Readonly<{}>;
context: any;
refs: {
[key: string]: React.ReactInstance;
};
};
displayName: string;
defaultProps: {
tag: string | React.ComponentClass<any> | React.StatelessComponent<any>;
constructor: Function;
toString(): string;
toLocaleString(): string;
valueOf(): Object;
hasOwnProperty(v: string | number | symbol): boolean;
isPrototypeOf(v: Object): boolean;
propertyIsEnumerable(v: string | number | symbol): boolean;
};
isSimpleTag: boolean;
};
/****************************************************************
* Public
****************************************************************/
/** This is just the ListItem component exported from the Menu module for convenience. */
export declare const MenuItem: React.ComponentType<any>;
/** A Menu Anchor. When using the anchorCorner prop of Menu, you must set MenuAnchors position to absolute. */
export declare const MenuAnchor: {
new <P>(props: any, context?: any): {
render(): React.ReactElement<any> | null;
setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: any) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
forceUpdate(callBack?: (() => void) | undefined): void;
props: Readonly<{
children?: React.ReactNode;
}> & Readonly<any>;
state: Readonly<{}>;
context: any;
refs: {
[key: string]: React.ReactInstance;
};
};
displayName: string;
defaultProps: {
tag: string | React.ComponentClass<any> | React.StatelessComponent<any>;
constructor: Function;
toString(): string;
toLocaleString(): string;
valueOf(): Object;
hasOwnProperty(v: string | number | symbol): boolean;
isPrototypeOf(v: Object): boolean;
propertyIsEnumerable(v: string | number | symbol): boolean;
};
isSimpleTag: boolean;
};
declare type AnchorT = 'bottomEnd' | 'bottomLeft' | 'bottomRight' | 'bottomStart' | 'topEnd' | 'topLeft' | 'topRight' | 'topStart';
export declare type MenuPropsT = {
/** Whether or not the Menu is open. */
open?: boolean;
/** Callback that fires for either onSelected or onCancel, convenient for setting the closed state. */
onClose?: (evt: CustomEventT) => any;
/** Callback that fires when a Menu item is selected. */
onSelected?: (evt: {
detail: {
index: number;
item: HTMLElement;
};
} & CustomEventT) => any;
/** Callback that fires when the menu is closed with nothing selected. */
onCancel?: (evt: CustomEventT) => any;
/** Manually position the menu to one of the corners. */
anchorCorner?: AnchorT;
/** Children to render */
children?: React.ReactNode;
};
declare const Menu_base: {
new <P>(props: P & {
tag?: string | React.ComponentClass<any> | React.StatelessComponent<any> | undefined;
className?: string | undefined;
wrap?: boolean | undefined;
elementRef?: any;
theme?: string | string[] | undefined;
children?: React.ReactNode;
apiRef?: (<S>(api: S) => S) | undefined;
} & React.HTMLProps<any>): {
foundation_: {
[key: string]: any;
adapter_: any;
/** Callback that fires when a Menu item is selected. */
init: Function;
destroy: Function;
} | null;
foundationRefs: {
[name: string]: (ref: HTMLElement) => any;
};
root_: Element | Text | null;
props: P & {
tag?: string | React.ComponentClass<any> | React.StatelessComponent<any> | undefined;
className?: string | undefined;
wrap?: boolean | undefined;
elementRef?: any;
theme?: string | string[] | undefined;
children?: React.ReactNode;
apiRef?: (<S>(api: S) => S) | undefined;
} & React.HTMLProps<any>;
componentDidMount(): void;
componentWillReceiveProps(nextProps: P & {
tag?: string | React.ComponentClass<any> | React.StatelessComponent<any> | undefined;
className?: string | undefined;
wrap?: boolean | undefined;
elementRef?: any;
theme?: string | string[] | undefined;
children?: React.ReactNode;
apiRef?: (<S>(api: S) => S) | undefined;
} & React.HTMLProps<any>): void;
componentWillUnmount(): void;
_safeSyncWithProps(props: Object): void;
initFoundation(): void;
destroyComponent(): void;
syncWithProps(nextProps: Object): void;
initialize(...args: any[]): void;
initialSyncWithDOM(): void;
destroy(): void;
getDefaultFoundation(): {
adapter_: {};
init: () => void;
destroy: () => void;
};
emit(evtType: string, evtData: Object, shouldBubble?: boolean): any;
listen(evtType: string, handler: Function): void;
unlisten(evtType: string, handler: Function): void;
setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: P & {
tag?: string | React.ComponentClass<any> | React.StatelessComponent<any> | undefined;
className?: string | undefined;
wrap?: boolean | undefined;
elementRef?: any;
theme?: string | string[] | undefined;
children?: React.ReactNode;
apiRef?: (<S>(api: S) => S) | undefined;
} & React.HTMLProps<any>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
forceUpdate(callBack?: (() => void) | undefined): void;
render(): React.ReactNode;
state: Readonly<{}>;
context: any;
refs: {
[key: string]: React.ReactInstance;
};
};
};
/** A menu component */
export declare class Menu extends Menu_base<MenuPropsT> {
static displayName: string;
open: boolean;
setAnchorCorner: Function;
syncWithProps(nextProps: MenuPropsT): void;
render(): JSX.Element;
}
export declare type SimpleMenuPropsT = {
/** An element that will open the menu when clicked */
handle: React.ReactElement<any>;
/** By default, props spread to the Menu component. These will spread to the MenuAnchor which is useful for things like overall positioning of the anchor. */
rootProps?: Object;
/** Children to render */
children?: React.ReactNode;
} & MenuPropsT;
export declare type SimpleMenuStateT = {
open: boolean;
};
/**
* A Simplified menu component that allows you to pass a handle element and will automatically control the open state and add a MenuAnchor
*/
export declare class SimpleMenu extends React.Component<SimpleMenuPropsT, SimpleMenuStateT> {
static displayName: string;
componentWillMount(): void;
componentWillReceiveProps(nextProps: SimpleMenuPropsT): void;
state: {
open: boolean;
};
syncWithOpenProp(open?: boolean): void;
render(): JSX.Element;
}
export {};