import React from 'react'; import { AttributeValue } from '../Utils/WdkModel'; /** * React Component utils */ interface AnyObject { [key: string]: any; } /** * Stateless function component decorator that prevents rerendering * when props are equal use shallow comparison. */ export declare function pure
(Component: React.StatelessComponent
): { new (props: P | Readonly
): {
render(): JSX.Element;
context: any;
setState ) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
forceUpdate(callback?: (() => void) | undefined): void;
readonly props: Readonly & Readonly<{
children?: React.ReactNode;
}>;
state: Readonly<{}>;
refs: {
[key: string]: React.ReactInstance;
};
componentDidMount?(): void;
shouldComponentUpdate?(nextProps: Readonly , nextState: Readonly<{}>, nextContext: any): boolean;
componentWillUnmount?(): void;
componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
getSnapshotBeforeUpdate?(prevProps: Readonly , prevState: Readonly<{}>): any;
componentDidUpdate?(prevProps: Readonly , prevState: Readonly<{}>, snapshot?: any): void;
componentWillMount?(): void;
UNSAFE_componentWillMount?(): void;
componentWillReceiveProps?(nextProps: Readonly , nextContext: any): void;
UNSAFE_componentWillReceiveProps?(nextProps: Readonly , nextContext: any): void;
componentWillUpdate?(nextProps: Readonly , nextState: Readonly<{}>, nextContext: any): void;
UNSAFE_componentWillUpdate?(nextProps: Readonly , nextState: Readonly<{}>, nextContext: any): void;
};
new (props: P, context: any): {
render(): JSX.Element;
context: any;
setState ) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
forceUpdate(callback?: (() => void) | undefined): void;
readonly props: Readonly & Readonly<{
children?: React.ReactNode;
}>;
state: Readonly<{}>;
refs: {
[key: string]: React.ReactInstance;
};
componentDidMount?(): void;
shouldComponentUpdate?(nextProps: Readonly , nextState: Readonly<{}>, nextContext: any): boolean;
componentWillUnmount?(): void;
componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
getSnapshotBeforeUpdate?(prevProps: Readonly , prevState: Readonly<{}>): any;
componentDidUpdate?(prevProps: Readonly , prevState: Readonly<{}>, snapshot?: any): void;
componentWillMount?(): void;
UNSAFE_componentWillMount?(): void;
componentWillReceiveProps?(nextProps: Readonly , nextContext: any): void;
UNSAFE_componentWillReceiveProps?(nextProps: Readonly , nextContext: any): void;
componentWillUpdate?(nextProps: Readonly , nextState: Readonly<{}>, nextContext: any): void;
UNSAFE_componentWillUpdate?(nextProps: Readonly , nextState: Readonly<{}>, nextContext: any): void;
};
readonly displayName: string;
contextType?: React.Context extends React.ComponentClass {
wrapComponent(factory: (Component: React.ComponentType ) => React.ComponentType ): void;
}
/**
* A Component decorator that wraps the Component passed to it and returns a new
* Component with a static method `wrapComponent`. Use this method to replace
* the wrapped Component. See the docs for `wrapComponent` for more details.
*
*
* Rationale
* =========
*
* Components in WDK should be customizable by the application. The application
* should be able to replace the Component, surround the Component, or modify
* the props passed to the Component. By creating a wrapper Component whose
* internal Component can be replaced in-place, WDK code does not need to do
* any kind of lookup, and implementors are given a nice, convenient syntax for
* what will most likely be a common task: modifying a WDK Component.
*
* There are other approaches that would require a uniform JavaScript build
* environment, which would allow the application to perform overriding at
* build time (similar to how we do this with JSP tags). We aren't quite at a
* point where we can do this, and it might not be desirable.
*
*
* Usage
* =====
*
* // As a function
* let Answer = wrappable(Answer);
*
*
* // As an ES2016 class decorator
* @wrappable
* class Answer extends React.Component {
* // ...
* }
*
* // Using the static wrap method. Note that the function passed to `wrap`
* // will receive the currently wrapped Component as an argument. This
* // makes it possible to replace or decorate the Component, or to modify
* // the props passed to the component.
* Answer.wrap(function(Answer) {
* return React.createClass({
* render() {
* return (
* (Component: React.ComponentType ): ComponentWrapper ;
interface LazyEnhance (ms: number): LazyEnhance ;
interface InstrumentOptions {
compareProps?: boolean;
}
/**
* Takes a component and returns an intrumented wrapper component
* that will log details about props, etc.
*
* This should never be used in production code!
*/
export declare function instrument (Component: React.ComponentClass , options: InstrumentOptions): React.ComponentClass ;
export declare function instrument (Component: React.StatelessComponent , options: InstrumentOptions): React.ComponentClass ;
/** Create a React Element using preformatted HTML */
export declare function safeHtml (str: string, props?: P, Component?: React.ComponentClass ): JSX.Element;
export declare function safeHtml (str: string, props?: P, Component?: React.StatelessComponent ): JSX.Element;
export declare function safeHtml (str: string, props?: P, Component?: string): JSX.Element;
/**
* Makes a copy of the passed original object, subtracting the properties with
* names in the propsToFilter arg, which should be Array[String].
*/
export declare function filterOutProps (orig: P, propsToFilter: string[]): {};
/**
* Generates HTML markup for an attribute using duck-typing
*/
export declare function formatAttributeValue(value?: AttributeValue): string;
/**
* Creates a React-renderable element using the provided `Component`, or 'span'
* by default.
* TODO Look up or inject custom formatters
*/
export declare function renderAttributeValue (value: AttributeValue, props?: P, Component?: string): JSX.Element;
/**
* Makes a copy of current, adds value if not present, removes if present, and
* returns the copy.
* @param {Array (oldProps: P, newProps: P, propertyNameList: string[]): boolean;
interface HandlerSetObject {
[key: string]: (...args: any[]) => any;
}
/**
* Bind a collection of action functions to a dispatchAction function.
*
* @param {Function} dispatchAction
* @param {ObjectMy Custom title
* (inputName: string, onParentChange: (s: S) => S, previousState: S): (newValue: T) => void;
/**
* For each property in propertyNameList, examines each property in both
* oldProps and newProps to check for referential equality. If any prop differs
* returns true, else returns false.
*
* @param {Object} oldProps props object
* @param {Object} newProps another props object
* @param {Array