156 lines
5.0 KiB
TypeScript
156 lines
5.0 KiB
TypeScript
import { EntityDict } from 'oak-domain/lib/types/Entity';
|
|
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
|
import { DataType, DataTypeParams } from 'oak-domain/lib/types/schema/DataTypes';
|
|
import { ActionDef } from './Page';
|
|
export type ED = BaseEntityDict & EntityDict;
|
|
export type RenderAlign = 'left' | 'right' | 'center';
|
|
export type RenderFixed = 'left' | 'right';
|
|
export type ButtonType = "link" | "text" | "default" | "primary" | "dashed";
|
|
export type ColSpanType = 1 | 2 | 3 | 4;
|
|
export type Width = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
|
|
export type OakActionBtnProps = {
|
|
label: string;
|
|
action: string;
|
|
type?: 'a' | 'button';
|
|
ctxType?: string;
|
|
};
|
|
export type OakExtraActionProps = {
|
|
action: string;
|
|
label: string;
|
|
show: boolean;
|
|
};
|
|
export type OakActionsProps = {
|
|
action: string;
|
|
label?: string;
|
|
};
|
|
export type OakAbsNativeAttrDef = {
|
|
path: string;
|
|
span?: ColSpanType;
|
|
};
|
|
export type OakAbsDerivedAttrDef = {
|
|
path: string;
|
|
label: string;
|
|
width?: number;
|
|
span?: number;
|
|
type?: 'image' | 'link' | 'ref' | DataType;
|
|
linkUrl?: string;
|
|
render?: (row: any) => React.ReactNode;
|
|
fixed?: RenderFixed;
|
|
align?: RenderAlign;
|
|
ellipsis?: boolean;
|
|
};
|
|
export type OakAbsAttrDef = string | OakAbsDerivedAttrDef;
|
|
export type OakAbsAttrJudgeDef = {
|
|
path: string;
|
|
entity: keyof ED;
|
|
attr: string;
|
|
attribute: OakAbsAttrDef;
|
|
attrType: DataType | 'ref' | undefined;
|
|
render?: (row: any) => React.ReactNode;
|
|
};
|
|
export type CardDef = {
|
|
title: string | React.ReactNode;
|
|
state?: string | React.ReactNode;
|
|
rows: OakAbsAttrDef[];
|
|
};
|
|
export interface OakAbsRefAttrPickerDef<ED2 extends ED, T extends keyof ED2> {
|
|
type: 'ref';
|
|
mode: 'select' | 'list' | 'radio';
|
|
attr: string;
|
|
entity: T;
|
|
projection: ED2[T]['Projection'];
|
|
title: (row: Partial<ED2[T]['Schema']>) => string;
|
|
titleLabel?: string;
|
|
filter?: ED2[T]['Filter'];
|
|
sorter?: ED2[T]['Sorter'];
|
|
getDynamicSelectors?: () => Promise<{
|
|
filter?: ED2[T]['Filter'];
|
|
sorter?: ED2[T]['Sorter'];
|
|
projection?: ED2[T]['Projection'];
|
|
}>;
|
|
count?: number;
|
|
label?: string;
|
|
placeholder?: string;
|
|
allowNull?: boolean;
|
|
}
|
|
export interface OakAbsRefAttrPickerRender<ED extends EntityDict & BaseEntityDict, T extends keyof ED> extends OakAbsRefAttrPickerDef<ED, T> {
|
|
required?: boolean;
|
|
}
|
|
export interface OakAbsGeoAttrUpsertDef {
|
|
type: 'geo';
|
|
category: 'point';
|
|
attributes?: {
|
|
areaId?: string;
|
|
poiName?: string;
|
|
coordinate?: string;
|
|
};
|
|
allowNull?: boolean;
|
|
}
|
|
export interface OakAbsNativeAttrUpsertDef<ED extends EntityDict & BaseEntityDict, T extends keyof ED, A extends keyof ED[T]['OpSchema']> {
|
|
attr: A;
|
|
type: Omit<DataType, 'ref' | 'geo'>;
|
|
label?: string;
|
|
placeholder?: string;
|
|
max?: number;
|
|
min?: number;
|
|
maxLength?: number;
|
|
defaultValue?: any;
|
|
required?: boolean;
|
|
allowNull?: boolean;
|
|
}
|
|
export type OakAbsAttrUpsertDef<ED extends EntityDict & BaseEntityDict, T extends keyof ED, T2 extends keyof ED = keyof ED> = OakAbsGeoAttrUpsertDef | OakAbsRefAttrPickerDef<ED, T2> | keyof ED[T]['OpSchema'] | OakAbsNativeAttrUpsertDef<ED, T, keyof ED[T]['OpSchema']>;
|
|
export type AttrRender = {
|
|
label: string;
|
|
value: any;
|
|
type: DataType | 'image' | 'link' | 'ref';
|
|
color?: string;
|
|
span?: ColSpanType;
|
|
attr: string;
|
|
};
|
|
export interface OakAbsNativeAttrUpsertRender<ED extends EntityDict & BaseEntityDict, T extends keyof ED, A extends keyof ED[T]['OpSchema']> extends Omit<OakAbsNativeAttrUpsertDef<ED, T, A>, 'type'> {
|
|
value: any;
|
|
type: Omit<DataType, 'ref'> | 'coordinate' | 'poiName';
|
|
enumeration?: Array<{
|
|
label: string;
|
|
value: string;
|
|
}>;
|
|
extra?: any;
|
|
params: DataTypeParams;
|
|
}
|
|
export type AttrUpsertRender<ED extends EntityDict & BaseEntityDict, T extends keyof ED> = OakAbsNativeAttrUpsertRender<ED, T, keyof ED[T]['OpSchema']> | OakAbsRefAttrPickerRender<ED, T>;
|
|
export type ColumnDefProps = {
|
|
width: number;
|
|
title: string;
|
|
entity: string;
|
|
attr: string;
|
|
path: string;
|
|
type: DataType & ('img' | 'file' | 'avatar');
|
|
fixed?: RenderFixed;
|
|
};
|
|
export type DataTransformer = (data: object) => AttrRender[];
|
|
export type DataUpsertTransformer<ED extends EntityDict & BaseEntityDict, T extends keyof ED> = (data: object) => AttrUpsertRender<ED, T>[];
|
|
export type DataConverter = (data: any[]) => Record<string, any>;
|
|
export type CascadeActionProps = {
|
|
path: string;
|
|
action: string;
|
|
};
|
|
export type onActionFnDef = (row: any, action: string, cascadeAction?: CascadeActionProps) => void;
|
|
export type CascadeActionDef = {
|
|
[K in keyof ED[keyof EntityDict]['Schema']]?: ActionDef<ED, keyof ED>[];
|
|
};
|
|
export type ListButtonProps = {
|
|
label: string;
|
|
show?: boolean;
|
|
type?: ButtonType;
|
|
icon?: React.ReactNode;
|
|
onClick: () => void;
|
|
};
|
|
export type ColumnMapType = {
|
|
xxl: ColSpanType;
|
|
xl: ColSpanType;
|
|
lg: ColSpanType;
|
|
md: ColSpanType;
|
|
sm: ColSpanType;
|
|
xs: ColSpanType;
|
|
};
|