import type { Event, ShapeAttrs } from '@antv/g-canvas'; import type { CellTypes } from '../../common/constant'; import type { Condition, CustomTreeItem, Data, ResizeInfo } from '../../common/interface'; import type { FrameConfig } from '../../common/interface/frame'; import type { S2BasicOptions, S2TableSheetOptions } from '../../common/interface/s2Options'; import type { BaseDataSet, DataType } from '../../data-set'; import type { Frame } from '../../facet/header'; import type { BaseHeaderConfig } from '../../facet/header/base'; import type { Hierarchy } from '../../facet/layout/hierarchy'; import type { Node } from '../../facet/layout/node'; import type { SpreadSheet } from '../../sheet-type'; import type { S2CellType } from './interaction'; import type { DataItem } from './s2DataConfig'; export declare type Formatter = (v: unknown, data?: Data | Data[]) => string; export interface FormatResult { formattedValue: string; value: DataItem; } export declare type SortMethod = 'ASC' | 'DESC' | 'asc' | 'desc'; export declare enum CellBorderPosition { TOP = "TOP", BOTTOM = "BOTTOM", LEFT = "LEFT", RIGHT = "RIGHT" } /** * 布局类型: * adaptive: 行列等宽,均分整个 canvas 画布宽度 * colAdaptive:列等宽,行头紧凑布局,列等分画布宽度减去行头宽度的剩余宽度 * compact:行列紧凑布局,指标维度少的时候无法布满整个画布 */ export declare type LayoutWidthType = 'adaptive' | 'colAdaptive' | 'compact'; export interface Meta { field?: string; name?: string; description?: string; formatter?: Formatter; } /** * Strategy mode's value type * data's key size must be equals fields.length * value can be empty * FieldC(Last fields is real value field) * example: * { * fields: [fieldA, fieldB, fieldC], * data: [ * { * fieldA: 'valueA', * fieldB: 'valueB', * fieldC: 'valueC', * } * { * fieldA: 'valueA', * fieldB: '', * fieldC: 'valueC', * } * ] * } */ export interface Extra { key: string; collapse: boolean; remark: string; } export interface Fields { rows?: string[]; customTreeItems?: CustomTreeItem[]; columns?: string[]; values?: string[]; valueInCols?: boolean; customValueOrder?: number; } export interface TotalsStatus { isRowTotal: boolean; isRowSubTotal: boolean; isColTotal: boolean; isColSubTotal: boolean; } export declare enum Aggregation { SUM = "SUM", MIN = "MIN", MAX = "MAX", AVG = "AVG" } export interface CalcTotals { aggregation?: Aggregation; calcFunc?: (query: DataType, arr: DataType[]) => number; } export interface Total { /** 是否显示总计 */ showGrandTotals: boolean; /** 是否显示小计 */ showSubTotals: boolean | { /** 当子维度个数 <=1 时,仍然展示小计:默认 true */ always: boolean; }; calcTotals?: CalcTotals; calcSubTotals?: CalcTotals; /** 小计的汇总维度 */ subTotalsDimensions: string[]; /** 总计布局位置,默认是下或右 */ reverseLayout: boolean; /** 小计布局位置,默认下或者右 */ reverseSubLayout: boolean; label?: string; subLabel?: string; } /** * tableau的英文是这个,这里有个绕的概念 * 如,某行维度需要展示小计,实际上是将对应的一列数据进行聚合,所以文案上显示的应该是“展示列小计” * 但是内部配置我倾向于仍然按照字段所属维度区,即配置的row,代表的是行维度而不是行小计 */ export interface Totals { row?: Partial; col?: Partial; } export interface Sort { /** 字段id,业务中一般是displayId */ sortFieldId: string; sortMethod?: SortMethod; /** 自定义排序 */ sortBy?: string[]; /** 按照数值字段排序 */ sortByMeasure?: string; /** 筛选条件,缩小排序范围 */ query?: Record; /** 组内排序用来显示icon */ type?: string; } export interface SortFuncParam extends Sort { data: (string | Record)[]; } export interface SortParam extends Sort { /** 自定义func */ sortFunc?: (v: SortFuncParam) => (string | Record)[]; } export interface FilterParam { filterKey: string; filteredValues?: unknown[]; customFilter?: (row: DataType) => boolean; } export declare type SortParams = SortParam[]; export interface Style { layoutWidthType?: LayoutWidthType; showTreeLeafNodeAlignDot?: boolean; treeRowsWidth?: number; collapsedRows?: Record; collapsedCols?: Record; cellCfg?: CellCfg; colCfg?: ColCfg; rowCfg?: RowCfg; device?: 'pc' | 'mobile'; } export declare type Pagination = { pageSize: number; current: number; total?: number; }; export interface CustomSVGIcon { name: string; svg: string; } export interface HeaderActionIconProps { iconName: string; meta: Node; event?: Event; } export interface HeaderActionIconOptions { iconName: string; x: number; y: number; action: (props: HeaderActionIconProps) => void; defaultHide?: boolean; } export interface HeaderActionIcon { iconNames: string[]; belongsCell: Omit; defaultHide?: boolean; displayCondition?: (mete: Node) => boolean; action?: (headerActionIconProps: HeaderActionIconProps) => void; } export declare type LayoutArrangeCallback = (spreadsheet: SpreadSheet, parent: Node, field: string, fieldValues: string[]) => string[]; export declare type LayoutCallback = (spreadsheet: SpreadSheet, rowNode: Node, colNode: Node) => void; export declare type CellCallback = (node: Node, spreadsheet: SpreadSheet, headerConfig: T) => S2CellType; export declare type DataCellCallback = (viewMeta: ViewMeta) => S2CellType; export declare type FrameCallback = (cfg: FrameConfig) => Frame; export declare type CornerHeaderCallback = (parent: S2CellType, spreadsheet: SpreadSheet, ...restOptions: unknown[]) => void; export declare type HierarchyResult = { nodes: Node[]; push: boolean; }; export declare type HierarchyCallback = (spreadsheet: SpreadSheet, node: Node) => HierarchyResult; export interface CellCfg { width?: number; height?: number; valuesCfg?: { originalValueField?: string; widthPercent?: number[]; conditions?: { text: Condition; }; }; } export interface RowCfg { width?: number; widthByField?: Record; heightByField?: Record; treeRowsWidth?: number; } export interface ColCfg { height?: number; widthByFieldValue?: Record; heightByField?: Record; hideMeasureColumn?: boolean; } /** * the label names of rows or columns. * Using the ID_SEPARATOR('[&]') to join two labels * when there are hierarchical relations between them. */ export interface CustomHeaderCells { cellLabels: string[]; mode?: 'pick' | 'omit'; } /** * the index of rows or columns. */ export interface MergedCellInfo { colIndex?: number; rowIndex?: number; showText?: boolean; } /** * the data cell and meta that make up the mergedCell, temporary use */ export declare type TempMergedCell = { cells: S2CellType[]; viewMeta: ViewMeta; isPartiallyVisible?: boolean; }; export declare type FilterDataItemCallback = (valueField: string, data: DataItem) => DataItem; export declare type MappingDataItemCallback = (valueField: string, data: DataItem) => Record | DataItem; /** * Spreadsheet facet config */ export interface SpreadSheetFacetCfg extends Fields, S2BasicOptions, S2TableSheetOptions, Style { spreadsheet: SpreadSheet; dataSet: BaseDataSet; meta?: Meta[]; } export interface ViewMeta { spreadsheet: SpreadSheet; id: string; x: number; y: number; width: number; height: number; data: Record; rowIndex: number; colIndex: number; valueField: string; fieldValue: DataItem; isTotals?: boolean; rowQuery?: Record; colQuery?: Record; rowId?: string; colId?: string; field?: string; isFrozenCorner?: boolean; [key: string]: any; } export declare type ViewMetaIndexType = keyof Pick; export declare type GetCellMeta = (rowIndex?: number, colIndex?: number) => ViewMeta; export interface LayoutResult { colNodes: Node[]; colsHierarchy: Hierarchy; rowNodes: Node[]; rowsHierarchy: Hierarchy; rowLeafNodes: Node[]; colLeafNodes: Node[]; getCellMeta: GetCellMeta; spreadsheet: SpreadSheet; } export interface OffsetConfig { offsetX?: { value: number | undefined; animate?: boolean; }; offsetY?: { value: number | undefined; animate?: boolean; }; } export interface CellAppendInfo extends Partial { isRowHeaderText?: boolean; cellData?: T; } export interface CellAttrs = Node> extends ShapeAttrs { text?: string; appendInfo?: CellAppendInfo; } export declare type S2MountContainer = string | Element; export interface OriginalEvent extends Event { layerX: number; layerY: number; } export interface PartDrillDownDataCache { rowId: string; drillLevel: number; drillField: string; drillData: Record[]; } export interface PartDrillDownFieldInLevel { drillField: string; drillLevel: number; } export interface TableSortParam extends SortParam { sortKey: string; } export interface GridInfo { cols: number[]; rows: number[]; }