Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

补充plugins types #103

Merged
merged 4 commits into from
Apr 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/sula/src/types/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ export type FieldNamePath = string | FieldNameList;

export type FieldSource = Array<{
text: string;
value: string;
value: string | number | boolean;
[key: string]: any;
}>;
10 changes: 6 additions & 4 deletions packages/sula/src/types/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type TableCtx = {
dataSource: Record<string, any>[];
}

type RenderCtx = FormCtx & TableCtx;
export type RenderCtx = FormCtx & TableCtx;

// Action Context
type ActionResultCtx = {
Expand All @@ -58,14 +58,16 @@ type ConverterCtx = {
type ConverterComboCtx = ConverterCtx & Partial<ActionResultComboCtx>;

// 渲染插件
export type RenderPluginFunction = (ctx: RenderCtx) => React.ReactElement;
export type RenderPluginFunction = (ctx: RenderCtx) => React.ReactElement | string;
export type DisabledFunction = (ctx: RenderCtx) => boolean
export type RenderPlugin = {
type: string | RenderPluginFunction;
props?: Record<string, any>;
funcProps?: Record<string, (ctx: RenderCtx) => string>;
confirm?: string | PopconfirmProps;
tooltip?: string | TooltipProps;
disabled?: boolean;
disabled?: boolean | DisabledFunction;
visible?: string | boolean;
action?: ActionPlugin | ActionPlugin[];
} | string | RenderPluginFunction;

Expand Down Expand Up @@ -168,4 +170,4 @@ export type ConverterPlugin = {
// 过滤插件
export type FilterPlugin = {
type: string;
} | string;
} | string;