import { TableConfig, TableServiceDataAndHandlers } from "./table.models"; export declare class TableService { private table; private _tableConfigs; private getTableConfig; private setTableConfig; private _sortInfos; private getSortInfo; private setSortInfo; private currentSortInfo; /** The indexes of the selected rows, paginated */ private _selectedRows; private selectedRows; private isAllSelected; private columnsList; /** The Index of the currently selected page */ private _currentPageIndex; private currentPageIndex; /** The Header List of The Master Table with all the Column Info */ private _tableHeaderList; private tableHeaderList; /** The Master Table, Sorted */ private _sortedTable; private sortedTable; /** The Master Table, Paginated */ private _paginatedTable; private paginatedTable; /** The Currently Visible Page of the Sorted and Paginated Master Table */ private _currentTable; private currentTable; /** * GET * Generic way of fetching subscribable properties like currentTable, tableHeaderList, etc... * @param id the id of the table * @param property the property to get */ private get; /** * CHANGE * Generic way of fetching handlers like changeSort, changePagination, etc... * @param id the id of the table * @param property the name of the handler to get */ private change; constructor(); /** * REGISTER DATASOURCE (INITIALIZE TABLE SERVICE) * Initialize the table service with the table data and configuration object for initial settings * @param {any[]} name the unique name of your data * @param {any[]} table the raw data * @param {TableConfig} config the table configuration settings * @returns {TableServiceDataAndHandlers} a generic getter for any subscribable property */ registerDatasource(name: string, table: any[], config?: TableConfig): TableServiceDataAndHandlers; /** * INIT CONFIG TYPES * @returns the initial configuration for config types */ private initConfigTypes; /** * RELOAD TABLE: * Responsible for recalculation (or initialisation) of everything needed for the table including the sort and pagination and rebuilds all the table components */ private reloadTable; /** * CALCULATE MAX ITEMS PER PAGE: * Calculates the current max items per page */ private calculateMaxItemsPerPage; /** * SETUP COLUMN LIST * Sets up the list of columns which should be displayed in the table based on the config or it will be inferred from the data itself * @param columns the list of columns which should be displayed in the table from the table config * @param table the table itself * @param order the order or the columns */ private setupColumnsList; /** * SETUP TABLE: * Sets up the sorted, paginated and current page table * @param {T[]} table the table * @param {SortInfo} sortInfo The information on how to sort the table: column name, type and asc/desc * @param {number} maxItems The maximum number of items to be displayed per page * @param {number[]} selectedRowIndexes the indexes of the rows selected in the master table */ private setupTable; /** * MAKE SORTED TABLE * @param table the table you wish to sort with meta data * @param sort the sort info * @returns The new sorted table */ private makeSortedTable; /** * MAKE PAGINATED TABLE * @param table the table you wish to paginate with meta data * @param maxItems the number of max items on one page * @returns the paginated table as array or arrays */ private makePaginatedTable; /** * SETUP TABLE HEADER: * Sets up the table header according to the current master table and it's config info * @param {object} types a REQUIRED map of every column name what type of data it represents * @param {object} labels an OPTIONAL map of column names and what label to display as column */ private setupTableHeader; /** * Sort the table: * * This method will sort the table based on the column selected and it's ascending/descending property * @param {TableRowWithMeta[]} table the table to be sorted with meta data * @param {SortInfo} sortInfo The information on how to sort the table: column name, type and asc/desc * @returns the sorted table */ private sortTable; /** * CHECK IS ALL SELECTED * Checks the selected rows of each table and check returns true/false if all rows in every table are selected * @returns {boolean} */ private checkIsAllSelected; /** * CHECK HAS SOME SELECTIONS * Checks if any rows (at least 1) are selected * @returns {boolean} */ private checkHasSelection; /** * HANDLE CHANGE COLUMNS * Handles the logic for changing the currently visible columns * @param {Array} newColumns the new array of visible columns */ private changeColumns; /** * HANDLE CHANGE SORT * Handles the logic for sorting the table (updates the sortInfo and reloads the table) * @param {SortInfo} value the SortInfo */ private changeSort; /** * HANDLE CHANGE PAGINATION * Handles the logic for changing the current pagination index * @param {number} newIndex the new page navigation index */ private changePagination; /** * HANDLE SELECT ROW * Handles the logic for changing the state of a row (selected/not selected) * @param {number} index index of the row of which selection should be toggled */ private selectRow; /** * handles the logic for toggling the state of selected rows to select all or deselect all */ private selectAllRows; }