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 { type: 'ref'; mode: 'select' | 'list' | 'radio'; attr: string; entity: T; projection: ED2[T]['Projection']; title: (row: Partial) => 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 extends OakAbsRefAttrPickerDef { required?: boolean; } export interface OakAbsGeoAttrUpsertDef { type: 'geo'; category: 'point'; attributes?: { areaId?: string; poiName?: string; coordinate?: string; }; allowNull?: boolean; } export interface OakAbsNativeAttrUpsertDef { attr: A; type: Omit; label?: string; placeholder?: string; max?: number; min?: number; maxLength?: number; defaultValue?: any; required?: boolean; allowNull?: boolean; } export type OakAbsAttrUpsertDef = OakAbsGeoAttrUpsertDef | OakAbsRefAttrPickerDef | keyof ED[T]['OpSchema'] | OakAbsNativeAttrUpsertDef; export type AttrRender = { label: string; value: any; type: DataType | 'image' | 'link' | 'ref'; color?: string; span?: ColSpanType; attr: string; }; export interface OakAbsNativeAttrUpsertRender extends Omit, 'type'> { value: any; type: Omit | 'coordinate' | 'poiName'; enumeration?: Array<{ label: string; value: string; }>; extra?: any; params: DataTypeParams; } export type AttrUpsertRender = OakAbsNativeAttrUpsertRender | OakAbsRefAttrPickerRender; 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 = (data: object) => AttrUpsertRender[]; export type DataConverter = (data: any[]) => Record; 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[]; }; 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; };