mirror of
https://github.com/Instadapp/assembly.git
synced 2024-07-29 22:37:06 +00:00
infer input extra params on defineStrategyComponent
This commit is contained in:
parent
d2bca27ab6
commit
76461deca6
|
@ -43,7 +43,7 @@ export enum StrategyComponentType {
|
||||||
|
|
||||||
HEADING = "heading",
|
HEADING = "heading",
|
||||||
VALUE = "value",
|
VALUE = "value",
|
||||||
STATUS = "status",
|
STATUS = "status"
|
||||||
}
|
}
|
||||||
|
|
||||||
export type StrategyComponentParameterMap = {
|
export type StrategyComponentParameterMap = {
|
||||||
|
@ -62,12 +62,14 @@ export type StrategyComponentParameterMap = {
|
||||||
[StrategyComponentType.HEADING]: {};
|
[StrategyComponentType.HEADING]: {};
|
||||||
[StrategyComponentType.VALUE]: {};
|
[StrategyComponentType.VALUE]: {};
|
||||||
[StrategyComponentType.STATUS]: {
|
[StrategyComponentType.STATUS]: {
|
||||||
liquidation?: any,
|
liquidation?: any;
|
||||||
status?: any,
|
status?: any;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface IStrategyComponent<ComponentType extends StrategyComponentType> {
|
export interface IStrategyComponent<
|
||||||
|
ComponentType extends StrategyComponentType
|
||||||
|
> {
|
||||||
type: ComponentType;
|
type: ComponentType;
|
||||||
name: string;
|
name: string;
|
||||||
|
|
||||||
|
@ -75,19 +77,22 @@ export interface IStrategyComponent<ComponentType extends StrategyComponentType>
|
||||||
|
|
||||||
placeholder?: (
|
placeholder?: (
|
||||||
context: IStrategyContext & {
|
context: IStrategyContext & {
|
||||||
component: IStrategyComponent<ComponentType> & StrategyComponentParameterMap[ComponentType];
|
component: IStrategyComponent<ComponentType> &
|
||||||
|
StrategyComponentParameterMap[ComponentType];
|
||||||
}
|
}
|
||||||
) => string;
|
) => string;
|
||||||
validate?: (
|
validate?: (
|
||||||
context: IStrategyContext & {
|
context: IStrategyContext & {
|
||||||
component: IStrategyComponent<ComponentType> & StrategyComponentParameterMap[ComponentType];
|
component: IStrategyComponent<ComponentType> &
|
||||||
|
StrategyComponentParameterMap[ComponentType];
|
||||||
}
|
}
|
||||||
) => string | void;
|
) => string | void;
|
||||||
|
|
||||||
defaults?: (context: Omit<IStrategyContext, "components">) => object;
|
defaults?: (context: Omit<IStrategyContext, "components">) => object;
|
||||||
update?: (
|
update?: (
|
||||||
context: IStrategyContext & {
|
context: IStrategyContext & {
|
||||||
component: IStrategyComponent<ComponentType> & StrategyComponentParameterMap[ComponentType];
|
component: IStrategyComponent<ComponentType> &
|
||||||
|
StrategyComponentParameterMap[ComponentType];
|
||||||
}
|
}
|
||||||
) => void;
|
) => void;
|
||||||
|
|
||||||
|
@ -122,10 +127,14 @@ export interface IStrategy {
|
||||||
submitText?: string;
|
submitText?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function defineStrategyComponent<ComponentType extends StrategyComponentType>(
|
export function defineStrategyComponent<
|
||||||
component: IStrategyComponent<ComponentType>
|
ComponentType extends StrategyComponentType
|
||||||
|
>(
|
||||||
|
component: IStrategyComponent<ComponentType> &
|
||||||
|
StrategyComponentParameterMap[ComponentType]
|
||||||
) {
|
) {
|
||||||
return component as IStrategyComponent<ComponentType>;
|
return component as IStrategyComponent<ComponentType> &
|
||||||
|
StrategyComponentParameterMap[ComponentType];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function defineStrategy(strategy: IStrategy) {
|
export function defineStrategy(strategy: IStrategy) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user