refire-react
Version:
React components and helpers for Refire
44 lines (43 loc) • 1.31 kB
TypeScript
/// <reference types="react" />
/// <reference types="react-redux" />
import * as React from "react";
import * as ReactRedux from "react-redux";
export interface RegistrationOptions {
fields?: string[];
submit?: (dispatch: ReactRedux.Dispatch<any>, state: RegistrationState) => void;
validator?: (state: RegistrationState) => boolean;
}
export interface Status {
errors: {
createUser: string;
};
processing: {
createUser: boolean;
};
completed: {
createUser: boolean;
};
}
export interface RegistrationProps {
readonly _status: Status;
readonly dispatch?: ReactRedux.Dispatch<any>;
}
export interface RegistrationState {
[name: string]: any;
}
export interface ExtraProps {
submit?: (event: React.FormEvent<HTMLElement>) => void;
update?: (field: string) => (event: React.FormEvent<HTMLInputElement>) => void;
validInput?: boolean;
error?: string;
processing?: boolean;
completed?: boolean;
}
export default function (options?: RegistrationOptions): <P>(WrappedComponent: React.ComponentType<P>) => React.ComponentClass<Pick<RegistrationProps & P, ({
[P in keyof (RegistrationProps & P)]: P;
} & {
_status: never;
dispatch: never;
} & {
[x: string]: never;
})[keyof (RegistrationProps & P)]> & P>;