es-grid-template
Version:
es-grid-template
79 lines (78 loc) • 3.18 kB
TypeScript
import type { ArtColumn, TableTransform, Transform } from '../interfaces';
import type { BaseTableProps, PrimaryKey } from '../base-table/table';
type RowPropsGetter = BaseTableProps['getRowProps'];
export interface TablePipelineIndentsConfig {
iconIndent: number;
iconWidth: 16;
iconGap: number;
indentSize: number;
}
export interface TablePipelineCtx {
primaryKey?: PrimaryKey;
components: Record<string, any>;
indents: TablePipelineIndentsConfig;
[key: string]: any;
}
/**
* Table data processing pipeline. TablePipeline provides context and helper methods used during table data processing, including:
*
* 1. ctx: the context object. A step (a stage in the pipeline) can read/write fields on ctx.
* Some field names in ctx have special meanings (for example, primaryKey represents the row primary key);
* avoid using these names for custom context fields.
*
* 2. rowPropsGetters: a queue of getRowProps callbacks. A step can append callbacks via pipeline.appendRowPropsGetter;
* when calling pipeline.getProps(), the queued functions are combined to form the final getRowProps.
*
* 3. Current pipeline state: dataSource, columns, and rowPropsGetters.
*
* 4. Snapshots: calling pipeline.snapshot(name) records the current state, which can be retrieved later by name.
*/
export declare class TablePipeline {
private readonly _snapshots;
private readonly _rowPropsGetters;
private _dataSource;
private _columns;
static defaultIndents: TablePipelineIndentsConfig;
readonly ctx: TablePipelineCtx;
private readonly state;
private readonly setState;
constructor({ state, setState, ctx, }: {
state: any;
setState: TablePipeline['setState'];
ctx: Partial<TablePipelineCtx>;
});
appendRowPropsGetter(getter: RowPropsGetter): this;
getDataSource(name?: string): any[];
getColumns(name?: string): any[];
getStateAtKey<T = any>(stateKey: string, defaultValue?: T): T;
/** stateKey partialState */
setStateAtKey(stateKey: string, partialState: any, extraInfo?: any): void;
/** Ensure primaryKey is set and return it */
ensurePrimaryKey(hint?: string): PrimaryKey;
/** Set pipeline input data */
input(input: {
dataSource: any[];
columns: ArtColumn[];
}): this;
/** Set dataSource */
dataSource(rows: any[]): this;
/** Set columns */
columns(cols: ArtColumn[]): this;
/** Set primaryKey */
primaryKey(key: PrimaryKey): this;
/** Save snapshot */
snapshot(name: string): this;
/** @deprecated
* Apply an ali-react-table Table transform */
useTransform(transform: TableTransform): this;
/** Use a pipeline extension step */
use(step: (pipeline: this) => this): this;
/** Transform dataSource */
mapDataSource(mapper: Transform<any[]>): this;
/** Transform columns */
mapColumns(mapper: Transform<ArtColumn[]>): this;
/** Get BaseTable props; result includes dataSource, columns, primaryKey, and getRowProps */
getProps(): BaseTableProps;
}
export declare function useTablePipeline(ctx?: Partial<TablePipelineCtx>): TablePipeline;
export {};