tablor-core
Version:
Core features for data tables, grids, and advanced search, pagination, and sorting in Angular.
66 lines (65 loc) • 2.03 kB
TypeScript
import { Subject } from 'rxjs';
import { ProcessedField, ProcessedFields, RegularField, RegularFields, FieldsUpdatedPayload } from './interfaces';
import { Item } from '../items-store/interfaces';
/**
* `FieldsStore` manages fields.
*/
export declare class FieldsStore<T extends Item<T>> {
readonly $fieldsChanged: Subject<FieldsUpdatedPayload<T>>;
protected readonly _allFields: ProcessedFields<T>;
/**
* Initialize with an event manager for handling field updates.
*/
constructor();
/**
* Get all fields as an object.
*
* @returns The fields object.
*/
getFields(): ProcessedFields<T>;
/**
* Get a field by key.
*/
getField<K extends keyof T>(key: K): ProcessedField<T, K> | undefined;
/**
* Get all field keys.
*/
getFieldsKeys(): (keyof T)[];
/**
* Check if a field exists.
*/
hasField<K extends keyof T>(key: K): boolean;
/**
* Get all fields as an array for easy iteration.
*
* @returns All the fields as array.
*/
getFieldsAsArray(): ProcessedField<T, keyof T>[];
/**
* Initialize fields with provided configurations.
*
* @param fields - Initial field configurations.
*/
initialize(fields: RegularFields<T>): void;
/**
* Update fields.
*
* @param fields - Fields to update as object or array.
*/
updateFields(fields: (RegularField<T> & {
key: keyof T;
})[] | Partial<RegularFields<T>>): void;
/**
* Update a field by merging old configurations with new.
*
* @param field - Field to update.
* @param prevField - Previous field.
*/
protected overwriteFieldInPlace<K extends keyof T>(field: Partial<RegularField<T>>, prevField: ProcessedField<T, K>): Partial<ProcessedField<T, K>>;
/**
* Prepare fields by applying defaults to missing values.
*
* @param fields - Fields to prepare.
*/
protected prepareFields(fields: RegularFields<T>): ProcessedFields<T>;
}