@ipi-soft/ng-components
Version:
Custom Angular Components
134 lines (133 loc) • 5.02 kB
TypeScript
import { QueryList, ElementRef, EventEmitter, ChangeDetectorRef, SimpleChanges } from '@angular/core';
import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
import { IpiSelectOptions } from '@ipi-soft/ng-components/select';
import { OSService } from '@ipi-soft/ng-components/services';
import { TooltipPosition } from '@ipi-soft/ng-components/tooltip';
import * as i0 from "@angular/core";
export interface IpiTableColumn {
label?: string;
value?: string;
type?: IpiTableColumnType;
width?: string;
editable?: boolean;
prefix?: string;
suffix?: string;
singleActions?: Action[];
multipleActions?: Action[];
dateFormat?: IpiDateFormatOptions;
chipLabel?: {
[key: string]: string;
};
class?: string | {
[key: string]: string;
};
}
export declare enum IpiTableColumnType {
Text = 0,
Date = 1,
Currency = 2,
Chip = 3,
Number = 4,
NumberMath = 5,
Actions = 6,
Checkbox = 7
}
export type ActionShowType = Array<{
property: string;
values: any[];
exists?: boolean;
}>;
export interface Action {
icon: string;
label: string;
class?: string;
showOn?: ActionShowType;
disabled?: boolean;
execute?: (row: any) => void;
}
export interface IpiTableChange {
from: number;
to: number;
filter?: string;
sort?: any;
}
export interface IpiDateFormatOptions {
format: string;
locale: string;
timezone?: string;
}
interface PageFormControls {
pageSize: FormControl<{
label: string;
value: number;
}>;
}
export declare class IpiTableComponent {
private osService;
private formBuilder;
private changeDetectorRef;
constructor(osService: OSService, formBuilder: FormBuilder, changeDetectorRef: ChangeDetectorRef);
DropdownElement: ElementRef<any> | null;
moreActionsList: QueryList<ElementRef>;
data: any[];
dataLength: number;
serverSide: boolean;
isLoading: boolean;
columns: IpiTableColumn[];
filter: string;
sortIndex: number;
sortable: boolean;
sortDirection: 'asc' | 'desc';
pageSize: number;
currentPage: number;
pageable: boolean;
pageSizeOptions: number[];
tableChange: EventEmitter<IpiTableChange>;
tooltipPosition: typeof TooltipPosition;
TableColumnType: typeof IpiTableColumnType;
totalPages: number;
visibleRange: string;
filteredData: any[];
pageSizeSelectOptions: IpiSelectOptions;
currentActiveRow: any;
isDropdown: boolean;
formGroup: FormGroup<PageFormControls>;
private _dataLength;
onClick(event: any): void;
onScroll(): void;
onResize(): void;
ngAfterViewInit(): void;
ngOnChanges(changes: SimpleChanges): void;
getPageData(): any[];
updateVisibleRange(start: number, end: number): void;
calculateTotalPages(): void;
goToPage(page: number): void;
goToPreviousPage(): void;
goToNextPage(): void;
goToFirstPage(): void;
goToLastPage(): void;
cellEdit(event: KeyboardEvent, column: string, currentPageRowIndex: number): void;
formatDate(dateAsString: string, formatDateOptions?: IpiDateFormatOptions): string;
getClass(row: any, column: IpiTableColumn): {
[key: string]: boolean;
} | string;
getDescendantProp(row: any, column: IpiTableColumn): any;
getChipLabel(row: any, column: IpiTableColumn): string;
getCheckboxState(row: any, column: IpiTableColumn): boolean;
handleActionShow(action: Action, row: any, column?: IpiTableColumn): boolean;
sortColumn(column: any, changeSortDirection?: boolean): void;
toggleActionDropdown(row: any, event: any): Promise<void>;
private preprocessData;
private calculateNumberMathCell;
private filterData;
private sortData;
private sortByProperty;
private sortReverse;
private getAccessIfColumnValueIsObject;
private buildPaginationSelectDependecies;
private subscribeToFormValueChanges;
private calculatePages;
static ɵfac: i0.ɵɵFactoryDeclaration<IpiTableComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<IpiTableComponent, "ipi-table", never, { "data": { "alias": "data"; "required": false; }; "dataLength": { "alias": "dataLength"; "required": false; }; "serverSide": { "alias": "serverSide"; "required": false; }; "isLoading": { "alias": "isLoading"; "required": false; }; "columns": { "alias": "columns"; "required": false; }; "filter": { "alias": "filter"; "required": false; }; "sortIndex": { "alias": "sortIndex"; "required": false; }; "sortable": { "alias": "sortable"; "required": false; }; "sortDirection": { "alias": "sortDirection"; "required": false; }; "pageSize": { "alias": "pageSize"; "required": false; }; "currentPage": { "alias": "currentPage"; "required": false; }; "pageable": { "alias": "pageable"; "required": false; }; "pageSizeOptions": { "alias": "pageSizeOptions"; "required": false; }; }, { "tableChange": "tableChange"; }, never, never, true, never>;
}
export {};