@limetech/lime-elements
Version:
71 lines • 2.56 kB
TypeScript
import { Column, ColumnSorter } from './table.types';
import Tabulator from 'tabulator-tables';
import { ElementPool } from './element-pool';
export declare class ColumnDefinitionFactory {
private pool;
constructor(pool: ElementPool);
/**
* Create Tabulator column definitions from a limel-table column configuration
*
* @param column - config describing the column
* @returns Tabulator column
*/
create(column: Column<object>): Tabulator.ColumnDefinition;
}
/**
* Formats the header of the column
*
* @param column - the configuration for the column
* @returns custom component that renders a column header
*/
export declare const formatHeader: (column: Column) => () => string | HTMLElement;
/**
* Create a formatter to be used to format values in a column
*
* @param column - config describing the column
* @param pool - pool to get custom components from
* @returns Tabulator formatter
*/
export declare function createFormatter(column: Column, pool: ElementPool): Tabulator.Formatter;
/**
* Format the value of a cell in the table
*
* @param cell - the cell being rendered in the table
* @param column - configuration for the current column
* @returns the formatted value
*/
export declare function formatCell(cell: Tabulator.CellComponent, column: Column): string;
/**
* Create a custom component that renders a cell value
*
* @param cell - Tabulator cell
* @param column - lime-elements column configuration
* @param value - the value of the cell being rendered
* @param pool - pool to get custom components from
* @returns custom component that renders a value in the table
*/
export declare function createCustomComponent(cell: Tabulator.CellComponent, column: Column, value: string, pool: ElementPool): HTMLElement;
/**
* Set all properties for a custom element, including event listeners
*
* @param element - the custom element
* @param props - object of properties and event listeners
*/
export declare function setElementProperties(element: HTMLElement, props: object): void;
interface TabulatorSorter extends Tabulator.Sorter {
field: string;
}
/**
* Create a column sorter from a tabulator sorter
*
* @param columns - all available columns in the table
* @returns function that creates a sorter from a tabulator sorter
*/
export declare const createColumnSorter: (columns: Column[]) => (sorter: TabulatorSorter) => ColumnSorter;
/**
*
* @param column
*/
export declare function getColumnAggregator(column: Column): Tabulator.ColumnCalc;
export {};
//# sourceMappingURL=columns.d.ts.map