@doreamonjs/page-creator
Version:
page-creator for doreamonjs
1,057 lines (1,056 loc) • 38 kB
TypeScript
/// <reference types="react" />
import { IRuleNode } from '@zodash/rule-engine/lib/core/sync/types';
import { Renderable as ManifestActionRuntimeRenderItem } from '@doreamonjs/components/lib/Table/utils';
import { InformationProps } from '@doreamonjs/components/lib/Card/Information';
import { INutField } from '@doreamonjs/components';
import { RenderOptions } from '@doreamonjs/gate/lib/common/global/dialog';
import { Config, StandardAPI } from './config';
import { buildGlobalRequestConfigContext } from './type';
export interface ManifestField {
uuid?: string;
key: string;
title: string;
type: 'string' | 'number' | 'boolean' | 'array' | 'object' | 'virtual';
advanced?: boolean;
tip?: string;
required?: boolean;
disabled?: boolean;
minLength?: number;
maxLength?: number;
length?: number;
regexp?: string;
minimum?: number;
maximum?: number;
validator?: (value: any) => boolean;
transform?: (value: any) => any;
isFuzzy?: boolean;
depends_on?: string[];
uiType?: string;
placeholder?: string | string[];
initialValue?: any;
step?: string;
group?: string;
mode?: 'multiple' | 'single';
options?: string[] | {
dict: {
uuid: string;
};
} | {
label?: string;
value?: any;
}[] | {
api: string;
search?: {
key?: string;
};
transform?: {
items: {
key: string;
};
label: {
key?: string;
template?: string;
format?: (item: any, items: any) => string;
};
value: {
key?: string;
template?: string;
format?: (item: any, items: any) => string | number | boolean;
};
};
empty?: {
label: string;
value: any;
};
query?: object;
params?: object;
body?: object;
} | (() => Promise<{
label: string;
value: string;
}[]>);
option?: {
request: {
api?: string;
method?: string;
path?: string;
query?: object;
params?: object;
body?: object;
};
response: {
item?: {
key: string;
};
label: {
key?: string;
template?: string;
format?: (item: any, items: any) => string;
};
value: {
key?: string;
template?: string;
format?: (item: any, items: any) => string | number | boolean;
};
};
} | {
api: string;
transform?: {
item?: {
key: string;
};
label: {
key?: string;
template?: string;
format?: (item: any, items: any) => string;
};
value: {
key?: string;
template?: string;
format?: (item: any, items: any) => string | number | boolean;
};
};
} | ((id: string) => Promise<{
label: string;
value: string;
}>);
clearable?: boolean;
searchable?: boolean;
prefix?: string | ((value: any, values: any, index: string) => string);
suffix?: string | ((value: any, values: any, index: string) => string);
value?: string | boolean | number | ((value: any, values: any, index: string) => string | boolean | number) | {
key?: string;
compute?: (value: any, values: any, index: string) => string | boolean | number;
readonly?: boolean;
disabled?: boolean;
};
rows?: number;
disabledBeforeToday?: boolean;
format?: string;
rules?: any[];
rollout?: string;
ui?: {
visible?: {
default?: boolean;
form?: {
create?: boolean;
update?: boolean;
} | boolean;
table?: {
list?: boolean;
} | boolean;
search?: boolean;
};
form?: {
rollout?: string;
column?: number;
layout?: 'horizontal' | 'vertical';
itemLayout?: {
labelCol?: {
span?: number;
flex?: number | 'none' | 'auto' | string;
order?: number | string;
offset?: number | string;
xs?: {
span?: number;
flex?: number | 'none' | 'auto' | string;
order?: number | string;
offset?: number | string;
};
sm?: {
span?: number;
flex?: number | 'none' | 'auto' | string;
order?: number | string;
offset?: number | string;
};
};
wrapperCol: {
span?: number;
flex?: number | 'none' | 'auto' | string;
order?: number | string;
offset?: number | string;
xs?: {
span?: number;
flex?: number | 'none' | 'auto' | string;
order?: number | string;
offset?: number | string;
};
sm?: {
span?: number;
flex?: number | 'none' | 'auto' | string;
order?: number | string;
offset?: number | string;
};
};
};
type?: 'input' | 'text' | 'banner' | 'avatar' | 'textarea' | 'select' | 'date' | 'datetime' | 'date-month' | 'time' | 'checkbox' | 'radio' | 'switch' | 'slider' | 'rate' | 'color' | 'file' | 'image' | 'editor' | 'json' | 'avatar' | 'cascader' | 'phone' | 'email' | 'password' | 'string' | 'number' | 'boolean' | 'time-picker' | 'time-range-picker' | 'date-picker' | 'date-range-picker' | 'date-week-picker' | 'date-month-picker' | 'tree-select' | 'upload' | 'input-array';
tip?: string;
initialValue?: any;
placeholder?: string | string[];
rules?: any[];
depends_on?: string[];
prefix?: string | ((value: any, values: any, index: string) => string);
suffix?: string | ((value: any, values: any, index: string) => string);
value?: string | boolean | number | ((value: any, values: any, index: string) => string | boolean | number) | {
key?: string;
compute?: (value: any, values: any, index: string) => string | boolean | number;
readonly?: boolean;
disabled?: boolean;
};
rows?: number;
fullscreenable?: boolean;
maxLength?: number;
showCount?: boolean;
language?: string | 'javascript' | 'typescript' | 'json' | 'yaml';
mode?: 'multiple' | 'simple';
options?: string[] | {
dict: {
uuid: string;
};
} | {
label?: string;
value?: any;
children?: {
label: string;
value: string;
}[];
}[] | {
api: string;
search?: {
key?: string;
};
transform?: {
items: {
key: string;
};
label: {
key?: string;
template?: string;
format?: (item: any, items: any) => string;
};
value: {
key?: string;
template?: string;
format?: (item: any, items: any) => string | number | boolean;
};
};
empty?: {
label: string;
value: any;
} | {
disable?: boolean;
};
query?: object;
params?: object;
body?: object;
} | (() => Promise<{
label: string;
value: string;
}[]>);
option?: {
request: {
api?: string;
method?: string;
path?: string;
query?: object;
params?: object;
body?: object;
};
response: {
item?: {
key: string;
};
label: {
key?: string;
template?: string;
format?: (item: any, items: any) => string;
};
value: {
key?: string;
template?: string;
format?: (item: any, items: any) => string | number | boolean;
};
};
} | {
api: string;
transform?: {
item?: {
key: string;
};
label: {
key?: string;
template?: string;
format?: (item: any, items: any) => string;
};
value: {
key?: string;
template?: string;
format?: (item: any, items: any) => string | number | boolean;
};
};
} | ((id: string) => Promise<{
label: string;
value: string;
}>);
dateFormat?: string;
timeFormat?: string;
searchable?: boolean;
clearable?: boolean;
inputable?: boolean;
addNew?: {
label: string;
service?: {
api: string;
};
action?: {
key: string;
};
};
disabledBeforeToday?: boolean;
custom?: {
create?: {
rollout?: string;
[key: string]: any;
};
update?: {
rollout?: string;
[key: string]: any;
};
};
showTime?: boolean;
display?: boolean;
extra?: {
action?: {
icon: string;
key: string;
};
};
upload?: {
action?: string;
mode?: 'image' | 'file';
maxCount?: number;
};
};
search?: {
rollout?: string;
dataType?: 'string' | 'number' | 'boolean';
type?: 'input' | 'text' | 'textarea' | 'select' | 'date' | 'datetime' | 'time' | 'checkbox' | 'radio' | 'switch' | 'slider' | 'rate' | 'color' | 'file' | 'image' | 'editor' | 'json' | 'avatar' | 'time-picker' | 'time-range-picker' | 'date-picker' | 'date-range-picker' | 'date-week-picker' | 'date-month-picker' | 'tree-select' | 'input-array';
options?: string[] | {
dict: {
uuid: string;
};
} | {
label?: string;
value?: any;
}[] | {
api: string;
search?: {
key?: string;
};
transform?: {
items: {
key: string;
};
label: {
key: string;
};
value: {
key: string;
};
};
empty?: {
label: string;
value: any;
};
query?: object;
params?: object;
body?: object;
};
clearable?: boolean;
searchable?: boolean;
advanced?: boolean;
};
table?: {
list?: {
category?: string[];
id?: {
key: string;
} | ((value: any, values: any, index: string) => string);
title?: string;
type?: 'link' | 'datetime' | 'format' | 'avatar' | 'banner' | 'image' | 'mapping' | 'length' | 'index' | 'yesno' | 'template' | 'navigate' | 'action' | 'select' | 'copy' | 'component';
sortable?: boolean;
collapsed?: boolean;
width?: number;
default?: any;
formatter?: (value: any) => string | number | JSX.Element;
tooltip?: {
enable?: boolean | {
key?: string;
};
key?: string;
format?: (value: any, values: any, index: string) => string;
template?: string;
default?: string;
};
link?: {
type?: 'spa' | 'system';
href?: {
key?: string;
format?: (value: any, values: any, index: string) => string | undefined;
template?: string;
disable?: boolean | ((value: any, values: any, index: string) => boolean);
};
text?: {
key?: string;
format?: (value: any, values: any, index: string) => string;
template?: string;
default?: string;
empty?: string;
};
target?: '_blank';
};
datetime?: {
default?: string;
key?: string;
alias?: string;
format?: string;
};
format?: {
key?: string;
default?: string;
format?: (value: any, values: any, index: string) => string;
};
avatar?: {
key?: string;
default?: string;
};
banner?: {
key?: string;
default?: string;
};
image?: {
key?: string;
default?: string;
style?: Record<string, string>;
};
mapping?: {
key?: string;
default?: string;
map: Record<string, string>;
};
length?: {};
index?: {
start?: number;
};
yesno?: {
enums?: {
true?: string;
false?: string;
};
colors?: {
true?: string;
false?: string;
};
};
template?: {
template?: string;
default?: string;
validation?: {
keys: string[];
relation: 'and' | 'or';
};
};
navigate?: {
template?: string;
target?: string;
};
action?: {
key: string;
};
select?: {
mode?: 'multiple' | 'simple';
options: {
label: string;
value: string | boolean | number;
color?: string;
}[] | {
dict: {
uuid: string;
};
};
renderTooltip?: (options: any[], values: string[], props: any) => JSX.Element;
progress?: {
visible?: boolean;
compute?(steps: {
value: string;
}[], value: string | number): {
steps: {
label: string;
value: string | number;
}[];
current: number;
status?: 'wait' | 'process' | 'finish' | 'error';
};
};
};
copy?: {
enable?: boolean;
key?: string;
default?: string;
template?: string;
};
component?: {
render(value: any, values: Record<string, any>, index: number): React.ReactNode | React.ReactElement<any, any> | null;
};
};
};
};
}
export declare type ManifestApi = string | StandardAPI;
export interface ManifestAction {
key: string;
title: ManifestActionRuntimeRenderItem<string>;
type: 'filter' | 'item' | 'single' | 'batch' | 'custom';
group?: string;
icon?: ManifestActionRuntimeRenderItem<string>;
iconOnly?: ManifestActionRuntimeRenderItem<boolean>;
buttonType?: ManifestActionRuntimeRenderItem<'primary' | 'default' | 'danger' | 'dashed'>;
style?: ManifestActionRuntimeRenderItem<React.CSSProperties>;
styleInMobile?: ManifestActionRuntimeRenderItem<React.CSSProperties>;
direction?: 'right' | 'left';
disabled?: ManifestActionRuntimeRenderItem<boolean>;
loading?: ManifestActionRuntimeRenderItem<boolean>;
hidden?: ManifestActionRuntimeRenderItem<boolean>;
visible?: ManifestActionRuntimeRenderItem<boolean>;
category?: string | string[];
tip?: ManifestActionRuntimeRenderItem<string>;
advanced?: boolean;
divided?: boolean;
dividePosition?: 'top' | 'bottom';
sort?: number;
quiet?: boolean;
refresh?: boolean;
pipeline?: ManifestActionPipeline[];
pipelineTo?: {
action: string;
onBefore?: (item: any) => any;
};
remark?: string;
rollout?: string;
permissions?: ManifestActionPermission[];
}
export interface ManifestCategory {
label: string;
value: string;
where?: Record<string, string | number | boolean>;
orderBy?: string[];
rollout?: string;
}
export declare type ManifestActionPermissionOperator = 'not' | '!';
export declare type ManifestActionPermissionBuiltInKey = '@@superadmin' | '@@owner' | '@@email' | string;
export declare type ManifestActionPermissionValuesKey = string | undefined;
export declare type ManifestActionPermissionValues = (string | number | boolean)[];
export declare type ManifestActionPermission = ManifestActionPermissionBuiltInKey | [ManifestActionPermissionBuiltInKey, ManifestActionPermissionValuesKey] | [
ManifestActionPermissionBuiltInKey,
ManifestActionPermissionValuesKey,
ManifestActionPermissionValues
] | [
ManifestActionPermissionBuiltInKey,
ManifestActionPermissionValuesKey,
ManifestActionPermissionOperator
] | [
ManifestActionPermissionBuiltInKey,
ManifestActionRuntimeRenderItem<any>
];
export interface ManifestActionPipeline {
type: 'service' | 'form' | 'confirm' | 'navigate' | 'copy' | 'transfer' | 'treeselect' | 'values' | 'preview' | 'dialog' | 'action' | 'logs' | 'terminal' | 'message' | 'download' | 'iframe';
quiet?: boolean;
refresh?: boolean;
pass?: (values: any, pipeline: ManifestActionPipeline, action: ManifestAction, manifest: Manifest) => boolean | Promise<boolean>;
service?: {
method?: string;
path?: string;
api?: string | ManifestApi;
request?: {
params?: (values: any, context: any) => any;
query?: ((values: any, context: any) => any) | {
pick: string[];
};
body?: ((values: any, context: any) => any) | {
pick: string[];
};
};
message?: {
success?: string;
failure?: string;
};
tip?: string;
quiet?: boolean;
refresh?: boolean;
timeout?: number;
delay?: number;
values?: (response: any, pipeline: any) => Promise<any> | any;
picks?: {
query?: string[];
body?: string[];
};
};
form?: {
type?: ManifestActionPipelineRenderableAttr<'modal' | 'drawer'>;
title?: ManifestActionPipelineRenderableAttr<string>;
layout?: ManifestActionPipelineRenderableAttr<'horizontal' | 'vertical'>;
column?: ManifestActionPipelineRenderableAttr<number>;
rules?: ManifestActionPipelineRenderableAttr<IRuleNode[]>;
fields: ManifestActionPipelineRenderableAttr<ManifestField[]>;
mode?: ManifestActionPipelineRenderableAttr<'step' | 'group'>;
steps?: ManifestActionPipelineRenderableAttr<ManifestFormStep[]>;
stepConfig?: ManifestActionPipelineRenderableAttr<{
layout?: 'top' | 'left';
prevButtonText?: string;
nextButtonText?: string;
submitButtonText?: string;
}>;
groups?: ManifestActionPipelineRenderableAttr<ManifestFormGroup[]>;
groupConfig?: ManifestActionPipelineRenderableAttr<{
layout?: 'top' | 'left';
}>;
name?: ManifestActionPipelineRenderableAttr<string>;
alwaysRecreate?: ManifestActionPipelineRenderableAttr<boolean>;
width?: ManifestActionPipelineRenderableAttr<number | string>;
valuesFromFieldsOnly?: ManifestActionPipelineRenderableAttr<boolean>;
display?: boolean;
};
confirm?: {
type?: ManifestActionPipelineRenderableAttr<'modal' | 'drawer'>;
title?: ManifestActionPipelineRenderableAttr<string>;
description?: ManifestActionPipelineRenderableAttr<string | React.ReactNode>;
descriptionConfig?: ManifestActionPipelineRenderableAttr<{
mode?: 'html';
}>;
cancelText?: ManifestActionPipelineRenderableAttr<string>;
confirmText?: ManifestActionPipelineRenderableAttr<string>;
information?: ManifestActionPipelineRenderableAttr<Pick<InformationProps, 'items' | 'column'>>;
};
navigate?: {
template?: string;
key?: string;
type: 'spa' | 'system' | 'iframe';
target?: '_blank';
format?: (values: any) => string;
iframe?: {
allowFullScreen?: boolean;
allowOpenInNewTab?: boolean;
sanbox?: 'allow-forms' | 'allow-pointer-lock' | 'allow-popups' | 'allow-same-origin' | 'allow-scripts' | 'allow-top-navigation';
allow?: 'geolocation' | 'microphone' | 'camera' | 'midi' | 'encrypted-media';
title?: string;
width?: number | string;
placement?: 'left' | 'right' | 'top' | 'bottom';
className?: string;
style?: React.CSSProperties;
};
};
copy?: {
default?: string;
key?: string;
template?: string;
format?: (values: any) => string;
message?: {
success?: string;
};
};
transfer?: {
type?: ManifestActionPipelineRenderableAttr<'modal' | 'drawer'>;
layout?: ManifestActionPipelineRenderableAttr<'horizontal' | 'vertical'>;
title: ManifestActionPipelineRenderableAttr<string>;
titles: ManifestActionPipelineRenderableAttr<string[]>;
values?: ManifestActionPipelineRenderableAttr<{
dataSource: {
key: string;
title: string;
}[];
targetKeys: string[];
}>;
};
treeselect?: {
type?: ManifestActionPipelineRenderableAttr<'modal' | 'drawer'>;
title: ManifestActionPipelineRenderableAttr<string>;
layout?: ManifestActionPipelineRenderableAttr<'horizontal' | 'vertical'>;
};
values?: {
onBefore?: (values: any, pipeline: any, action: any, config: Config) => object;
pick?: string[] | ((values: any, pipeline: any, action: any, config: Config) => object);
ignored?: boolean;
};
logs?: {
log?: ManifestActionPipelineRenderableAttr<string>;
sse?: ManifestActionPipelineRenderableAttr<string>;
sseOptions?: ManifestActionPipelineRenderableAttr<{
method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
headers?: Record<string, string>;
body?: any;
}>;
downloadURL?: ManifestActionPipelineRenderableAttr<string>;
downloadFilename?: ManifestActionPipelineRenderableAttr<string>;
downloadBtnText?: ManifestActionPipelineRenderableAttr<string>;
width?: number;
title?: string;
};
preview?: {
title?: ManifestActionPipelineRenderableAttr<string>;
valuesKey?: ManifestActionPipelineRenderableAttr<string>;
fields?: ManifestActionPipelineRenderableAttr<{
key: string;
title: string;
type?: 'text' | 'avatar' | 'link';
}[]>;
mode?: ManifestActionPipelineRenderableAttr<'config' | 'code' | 'json' | 'yaml' | 'env' | 'shell' | 'markdown'>;
config?: ManifestActionPipelineRenderableAttr<{
key?: string;
language?: 'yaml' | 'json' | 'toml' | 'ini';
render?(values: any): string;
}>;
code?: ManifestActionPipelineRenderableAttr<{
key?: string;
language?: 'javascript' | 'typescript' | 'go' | 'java' | 'python' | 'ruby' | 'shell' | string;
render?(values: any): string;
}>;
markdown?: {
key?: string;
value?: (values: any) => string;
};
width?: number | string;
};
dialog?: {
type?: 'modal' | 'drawer';
placement?: 'left' | 'right' | 'top' | 'bottom';
title: ManifestActionPipelineRenderableAttr<string>;
width?: ManifestActionPipelineRenderableAttr<number | string>;
height?: ManifestActionPipelineRenderableAttr<number | string>;
render?: string | ((values: any, onChange: (values: any) => void, options?: RenderOptions) => JSX.Element | string);
fullscreen?: ManifestActionPipelineRenderableAttr<boolean>;
hideHeader?: ManifestActionPipelineRenderableAttr<boolean>;
hideFooter?: ManifestActionPipelineRenderableAttr<boolean>;
hideClose?: ManifestActionPipelineRenderableAttr<boolean>;
maskClosable?: ManifestActionPipelineRenderableAttr<boolean>;
noPadding?: ManifestActionPipelineRenderableAttr<boolean>;
};
terminal?: {
url?: string;
title?: string;
width?: string;
placement?: 'left' | 'right' | 'top' | 'bottom';
style?: Record<string, any>;
once?: boolean;
};
iframe?: {
src: string;
allowFullScreen?: boolean;
allowOpenInNewTab?: boolean;
sanbox?: 'allow-forms' | 'allow-pointer-lock' | 'allow-popups' | 'allow-same-origin' | 'allow-scripts' | 'allow-top-navigation';
allow?: 'geolocation' | 'microphone' | 'camera' | 'midi' | 'encrypted-media';
title?: string;
width?: number | string;
placement?: 'left' | 'right' | 'top' | 'bottom';
className?: string;
style?: React.CSSProperties;
};
action?: {
namespace?: string;
key: string;
callback?: (err: Error, values: any) => void;
quiet?: boolean;
refresh?: boolean;
delay?: number;
};
message?: {
type?: ManifestActionPipelineRenderableAttr<'success' | 'error' | 'info' | 'warn'>;
message: ManifestActionPipelineRenderableAttr<string>;
};
download?: {
url: {
key?: string;
template?: string;
format?: (values: any) => string;
};
type?: 'link' | 'fetch';
filename?: ManifestActionPipelineRenderableAttr<string>;
method?: ManifestActionPipelineRenderableAttr<'GET' | 'POST' | 'PUT' | 'DELETE'>;
headers?: ManifestActionPipelineRenderableAttr<Record<string, string>>;
body?: ManifestActionPipelineRenderableAttr<any>;
successMessage?: ManifestActionPipelineRenderableAttr<string>;
errorMessage?: ManifestActionPipelineRenderableAttr<string>;
};
}
export declare type ManifestActionPipelineRenderableAttr<T> = T | ((values: any, pipeline: any, action: any, config: Config) => T);
export interface ManifestFormStep {
key: string;
title: string;
rollout?: string;
form?: (config: {
values: Record<string, any>;
fields: INutField[];
currentStep: number;
}) => Promise<{
values: Record<string, any>;
fields: INutField[];
currentStep: number;
}>;
config?: (origin: {
values: Record<string, any>;
fields: INutField[];
currentStep: number;
}) => Promise<{
values: Record<string, any>;
fields: INutField[];
currentStep: number;
}>;
render?: (values: Record<string, any>, onChange: (key: string, value: any, allValues: any, context?: any) => void, config: {
values: Record<string, any>;
fields: INutField[];
currentStep: number;
onChange?(key: string, value: any, allValues: any, context?: any): void;
}) => any;
}
export interface ManifestFormGroup {
key: string;
title: string;
rollout?: string;
render?: (values: Record<string, any>, onChange: (key: string, value: any, allValues: any, context?: any) => void, config: {
values: Record<string, any>;
fields: INutField[];
currentGroup: string;
onChange?(key: string, value: any, allValues: any, context?: any): void;
}) => any;
}
export interface ManifestRunTimeAction extends Partial<ManifestAction> {
prePipeline?: ManifestActionPipeline[];
postPipeline?: ManifestActionPipeline[];
}
export interface ManifestConfigs {
setup?: boolean;
page?: {
mode?: 'list' | 'detail';
urlSearchUsedForListAPI?: boolean;
watch?: {
refresh?: {
key: string;
} | ((currentProps: any, prevProps: any) => boolean);
reset?: {
key: string;
} | ((currentProps: any, prevProps: any) => boolean);
};
};
searchable?: boolean;
dialog?: {
type?: 'modal' | 'drawer';
form?: {
type?: 'modal' | 'drawer';
layout?: 'horizontal' | 'vertical';
};
confirm?: {
type?: 'modal' | 'drawer';
drawer?: {
placement?: 'left' | 'right' | 'top' | 'bottom';
width?: number | string;
};
};
};
apis?: {
prefix?: string;
version?: string;
headers?: Record<string, string | ((context: buildGlobalRequestConfigContext) => string | Promise<string>)>;
params?: Record<string, string | ((context: buildGlobalRequestConfigContext) => string | Promise<string>)>;
query?: Record<string, string | ((context: buildGlobalRequestConfigContext) => string | Promise<string>)>;
body?: Record<string, any | ((context: buildGlobalRequestConfigContext) => any | Promise<any>)>;
};
actions?: {
disable?: string[];
search?: boolean;
runtime?: {
query?: ManifestRunTimeAction;
create?: ManifestRunTimeAction;
update?: ManifestRunTimeAction;
delete?: ManifestRunTimeAction;
refresh?: ManifestRunTimeAction;
};
};
filters?: {
disable?: string[];
};
columns?: {
disable?: string[];
};
table?: {
defaultPageSize?: number;
defaultPageSizeOptions?: number[];
disablePagination?: boolean;
disableColumnFieldsSetting?: boolean;
disableHeader?: boolean;
operatorColumnWidth?: number;
type?: 'card';
card?: {
columns?: number;
renderItem?: (item: any, index: number, onClick: () => void) => JSX.Element;
renderFirstItem?: () => JSX.Element;
renderLastItem?: () => JSX.Element;
};
};
analysis?: {
action?: {
type: {
custom: Record<string, string>;
};
};
};
categories?: {
enable?: boolean;
searchKey?: string;
defaultValue?: string;
rollout?: string;
};
scheduler?: {
actions?: string[];
services?: string[];
refresh?: boolean;
};
datasets?: {
defaultValues?: any;
defaultTable?: any;
};
search?: {
disabled?: boolean;
mode?: 'default' | 'simple';
simple?: {
searchKey?: string;
isFuzzy?: boolean;
placeholder?: string;
render?: (props: any, onChange: (value: string) => void, context: any) => JSX.Element;
hideInMobile?: boolean;
};
};
}
export interface ManifestLifeCycle {
onBeforeLoad?: (manifest: Manifest) => Promise<void>;
onRouteIn?: (pathname: string) => boolean | undefined;
onRouteOut?: (pathname: string, isNeedCleanup?: boolean) => boolean | undefined;
onRouteChange?: (pathname: string) => boolean | undefined;
}
export interface ManifestDetail {
loading?: (id: string, values: any, context: any) => boolean;
basis: ManifestDetailBasis | ((values: any, context: any) => JSX.Element);
modules: ManifestDetailModules | ((values: any, context: any) => JSX.Element);
}
export interface ManifestDetailBasis {
items: ManifestInfoItem[][];
title?: string | ((values: any, context: any) => string);
subTitle?: string | ((values: any, context: any) => string);
column?: number;
hideContentInMobile?: boolean;
renderBottom?(values: any, context: any): JSX.Element;
}
export interface ManifestInfoItem {
key: string;
label: string;
value?: string | JSX.Element | ((value: any, context: any) => string | JSX.Element);
span?: number;
rollout?: string;
visible?: boolean | ((value: any, values: any, index: string) => boolean);
width?: number | string;
icon?: string;
action?: string;
type?: 'datetime' | 'link' | 'yesno' | 'description' | 'copy' | 'template' | 'mapping' | 'html';
datetime?: {
default?: string;
format?: string;
};
link?: {
type?: 'spa' | 'system';
href?: {
key?: string;
format?: (value: any, values: any, index: string) => string | undefined;
template?: string;
disable?: boolean | ((value: any, values: any, index: string) => boolean);
};
text?: {
key?: string;
format?: (value: any, values: any, index: string) => string | undefined;
template?: string;
default?: string;
empty?: string;
};
target?: '_blank';
copyable?: boolean;
};
yesno?: {
enums?: {
true?: string;
false?: string;
};
colors?: {
true?: string;
false?: string;
};
};
copy?: {
enable?: boolean;
key?: string;
default?: string;
template?: string;
};
template?: {
template?: string;
default?: string;
validation?: {
keys: string[];
relation: 'and' | 'or';
};
};
mapping?: {
key?: string;
default?: string;
map: Record<string, string | boolean | number>;
};
html?: {
key?: string;
template?: string;
format?: (value: any, values: any, index: string) => string | undefined;
default?: string;
empty?: string;
};
textarea?: {
key?: string;
template?: string;
format?: (value: any, values: any, index: string) => string | undefined;
default?: string;
empty?: string;
};
}
export interface ManifestDetailModules {
items: ManifestModuleItem[];
default?: string;
}
export interface ManifestModuleItem {
key: string;
title: string | ((values: any, context: any) => string);
icon?: string;
disabled?: boolean;
render?(values: any, index: number, context: any): JSX.Element;
rollout?: string;
visible?: boolean | ((values: any, tab: ManifestModuleItem, index: number, context: any) => boolean);
}
export interface Manifest {
path: string;
title: string;
description?: string;
fields?: ManifestField[];
rules?: IRuleNode[];
apis?: Record<string, ManifestApi>;
type?: 'page' | 'component';
namespace?: string;
actions?: ManifestAction[];
categories?: ManifestCategory[];
configs?: ManifestConfigs;
lifeCycle?: ManifestLifeCycle;
detail?: ManifestDetail;
}
export declare function create(manifest: Manifest): Manifest;