@easy-page/core
Advanced tools
Comparing version 0.1.8 to 0.1.9
@@ -6,3 +6,3 @@ export interface Empty { | ||
export type EffectDataType<PageState = Record<string, unknown>, PageProps = Empty> = Partial<PageProps extends undefined ? PageState extends undefined ? PageProps : PageState : PageState extends undefined ? PageProps : PageState & PageProps>; | ||
export type Context<FieldType, PageState, PageProps = Empty> = DataContext<FieldType, PageState, PageProps> & { | ||
export type Context<FieldType, PageState, PageProps = Empty, DefaultValues = Record<string, any>> = DataContext<FieldType, PageState, PageProps, DefaultValues> & { | ||
effectedData: Partial<EffectDataType<PageState, PageProps>>; | ||
@@ -12,7 +12,7 @@ /** whether is the first time to run action after component has mounted */ | ||
}; | ||
export type DataContext<FieldType, PageState, PageProps> = { | ||
export type DataContext<FieldType, PageState, PageProps, DefaultValues = Record<string, any>> = { | ||
pageState: Partial<PageState>; | ||
pageProps: Partial<PageProps>; | ||
value: FieldType; | ||
defaultValues: Partial<PageState>; | ||
defaultValues: Partial<DefaultValues>; | ||
}; | ||
@@ -35,3 +35,3 @@ /** returns type of effect action */ | ||
}) => ValidateResult | Promise<ValidateResult>; | ||
export type EffectActionHandlerType<FieldType, PageState = Record<string, unknown>, PageProps = Record<string, unknown>, EffectedResultType = unknown> = (context: Context<FieldType, PageState, PageProps>) => EffectActionResult<FieldType, EffectedResultType> | Promise<EffectActionResult<FieldType, EffectedResultType>>; | ||
export type EffectActionHandlerType<FieldType, PageState = Record<string, unknown>, PageProps = Record<string, unknown>, EffectedResultType = unknown, DefaultValues = Record<string, any>> = (context: Context<FieldType, PageState, PageProps, DefaultValues>) => EffectActionResult<FieldType, EffectedResultType> | Promise<EffectActionResult<FieldType, EffectedResultType>>; | ||
export type EffectKeys<PageState = Record<string, unknown>, PageProps = Record<string, unknown>> = PageState extends undefined ? PageProps extends undefined ? Array<keyof PageState> : Array<keyof PageProps> : PageProps extends undefined ? Array<keyof PageState> : Array<keyof PageState | keyof PageProps>; | ||
@@ -62,3 +62,3 @@ export type BaseSchema = { | ||
disableInitRun?: boolean; | ||
show: (context: Context<FieldType, PageState, PageProps>) => boolean; | ||
show: <DefaultValues = Record<string, unknown>>(context: Context<FieldType, PageState, PageProps, DefaultValues>) => boolean; | ||
}; | ||
@@ -75,5 +75,5 @@ /** extends info */ | ||
/** before submit handle data */ | ||
postprocess?: (context: DataContext<FieldType, PageState, PageProps>) => Record<string, unknown>; | ||
postprocess?: <DefaultValues = Record<string, any>>(context: DataContext<FieldType, PageState, PageProps, DefaultValues>) => Record<string, unknown>; | ||
/** inject data in form */ | ||
preprocess?: <DefaultValues = Record<string, any>>(context: Pick<DataContext<FieldType, DefaultValues, PageProps>, 'defaultValues' | 'pageProps'>) => FieldType; | ||
preprocess?: <DefaultValues = Record<string, any>>(context: Pick<DataContext<FieldType, PageState, PageProps, DefaultValues>, 'defaultValues' | 'pageProps'>) => FieldType; | ||
/** when state or props changed, do something */ | ||
@@ -80,0 +80,0 @@ actions?: Array<EffectActionType<FieldType, PageState, PageProps, EffectedResultType>>; |
{ | ||
"name": "@easy-page/core", | ||
"version": "0.1.8", | ||
"version": "0.1.9", | ||
"dependencies": {}, | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
35820