rmwc
Version:
A thin React wrapper for Material Design (Web) Components
61 lines (60 loc) • 2.38 kB
TypeScript
import { SimpleTagPropsT } from './simpleTag';
import * as React from 'react';
/** Simplifies redundant checks for syncWithProps */
export declare const syncFoundationProp: (prop: any, foundationValue: any, callback: () => any) => void;
/************************************************************************
* HOC
***********************************************************************/
declare type FoundationT = {
constructor: Function;
adapter?: {
[functionName: string]: Function;
};
refs?: string[];
};
declare type FoundationPropsT<P> = P & SimpleTagPropsT;
export declare const withFoundation: ({ constructor: FoundationConstructor, adapter, refs }: FoundationT) => {
new <P>(props: FoundationPropsT<P>): {
foundation_: {
[key: string]: any;
adapter_: any;
init: Function;
destroy: Function;
} | null;
foundationRefs: {
[name: string]: (ref: HTMLElement) => any;
};
root_: Element | Text | null;
props: FoundationPropsT<P>;
componentDidMount(): void;
componentWillReceiveProps(nextProps: FoundationPropsT<P>): 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;
};
/**
* Fires a cross-browser-compatible custom event from the component root of the given type,
*/
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: FoundationPropsT<P>) => {} | 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;
};
};
};
export {};