import { AfterContentInit, EventEmitter, OnChanges, OnDestroy, OnInit, QueryList, SimpleChanges, TemplateRef } from '@angular/core';
import { UntypedFormControl, UntypedFormGroup } from '@angular/forms';
import { Subscription } from 'rxjs';
import { TableAppendableRowsTemplateDirective, TableFooterTemplateDirective, TableTemplateDirective } from './table.directive';
import { ariaLabelsOrderBy, OrderBy, TableColumn, TableRow } from './table.models';
import * as i0 from "@angular/core";
/**
* A table component with built-in sorting and selecting functionality.
* By default, table cells (i.e. `
` elements) and table headers (i.e. ` | ` elements) are populated with text only values.
*
* To customize the contents of either the ` | ` or ` | ` elements (like adding color, icons, form fields, extra padding etc.), provide
* the customized content within a ``-tag, and place the ng-template in the html between the start and ending tag of
* the ``. Add a `tableColumn`-attribute to the ``-element, and set the value to the specific column property.
* Set `tableColumnTarget` to either `th`, `td` or `both` (default) depending on target element type.
* The entire row from the `@Input() tableData` is available from the context `$implicit` variable.
*
* @example
*
*
*
*
*
* @example
*
*
*
*
*
* It is possible to add custom rows that are appended below data row. Use ``-tag and place the ng-template in the html between the start and ending tag of
* the ``. Add a `tableAppendableRows`-attribute to the ``-element. Any `tr` elements that exist within `` and `` tags will be put below data row's `tr` element in the table.
*
* @example
*
*
*
*
*
*
*
*
* If custom styling is needed for data row that has appended rows, you can use data attribute `data-hasrowspan` to distinguish it from data row without appended rows.
* You can pass your own custom method with conditional logic to define what value will be passed to data-hasrowspan.
* In addition, hasRowSpan function accepts item from `@Input() tableData` as argument which is of the same type as value passed to context `$implicit` variable.
* IMPORTANT: use arrow function style for defining function inside component, i.e. `hasRowSpan = (value) => output;`. If regular function will be defined, i.e. `hasRowSpan(value) { return output; }`, binding will not work.
*
* @example
*
*
*
*
*
*
* | {{ appendedRowItem }} |
*
*
*
*
*
* In addition, it is possible to add footer for the table. Similarly to adding custom columns, use ``-tag and place the ng-template in the html between the start and ending tag of
* the ``. Add a `tableFooter`-attribute to the ``-element. Any elements that exist within `` and `` tags will be put to tfoot element inside the table.
*
* @example
*
*
*
*
*
*
*
*
*/
export declare class TableComponent implements OnInit, OnChanges, AfterContentInit, OnDestroy {
/**
* @internal
* Custom templates defined in the html.
*/
customTemplates: QueryList>;
/**
* @internal
* Custom appended rows template defined in the html.
*/
appendedRowsTemplate: TableAppendableRowsTemplateDirective;
/**
* @internal
* Custom footer template defined in the html.
*/
customFooterTemplate: TableFooterTemplateDirective;
/** Emits the table row that was clicked. Works on all columns if not preventDefaultEmit is set for that column. */
ngvRowClick: EventEmitter;
/**
* Emits currently selected and deselected items in the table as key-value pairs.
* Uses each item`s itemId as key, and a boolean value to describe selected status.
*/
ngvRowSelect: EventEmitter;
/**
* Emits event to signal that the table should be reordered.
*/
ngvOrderBy: EventEmitter>;
/**
* An array of items describing how the table header should be rendered,
* together with instructions for how each row should be displayed in that column.
*/
tableColumns: TableColumn[];
/** Data array to display data in the table. Each item in the array represents a row in the table. */
tableData: T[];
/**
* Property name used to uniquely describe each item (i.e. row) in the data table.
* Defaults to \'id\'.
* Is required if selectable is true.
*/
rowId: string;
/**
* Function's return value is used for data attribute \'data-hasrowspan\'.
* If custom hasRowSpan function is not passed to the table,
* then this function returns undefined value by default which results in \'data-hasrowspan\' attribute being omitted in html
* (angular omits attributes that contain null or undefined value).
* IMPORTANT: use arrow function style for defining function inside component, i.e. `hasRowSpan = (value) => output;`. If regular function will be defined, i.e. `hasRowSpan(value) { return output; }`, binding will not work.
*/
hasRowSpan: (item: T) => any;
/**
* Used to enable/disable the left-side checkbox column.
* Defaults to true.
*/
selectable: boolean;
/**
* Array of row id's (as defined by rowId property) that should not have a checkbox even if selectable is true.
*/
hiddenCheckboxRowIds: string[];
/**
* Used to enable/disable expandable rows.
* Defaults to false.
*/
expandable: boolean;
/**
* Used to enable/disable the right-side expand icon column.
* Defaults to true.
*/
expandedByDefault: boolean;
/**
* Property name used to describe the subItems in the data table.
*/
subItemsProp: string;
/**
* Allow nggv-table to attempt sorting the data in the table. Not recommended if only a subset is loaded or if the dataset is very large.
* Disabled by default.
*/
allowLocalSort: boolean;
/** Special property used for selecting DOM elements during automated UI testing. */
thook: string;
/** Function to overwrite generated thook for each row. */
trThookFn?: (item: T) => string;
/** Aria label for the checkbox in the table header */
ariaLabelCheckboxTh?: string;
/** Aria label for the checkbox in the table header */
ariaLabelCheckboxTr?: string;
/** Aria labels for sorting in the table header */
ariaLabelsOrderBy?: ariaLabelsOrderBy;
/**
* @internal
* Internal data structure used to keep track of added content templates used in td elements.
*/
customRowTemplates: Map>;
/**
* @internal
* Internal data structure used to keep track of added content templates used in th elements.
*/
customHeaderTemplates: Map>;
/**
* @internal
* Internal data structure used to hold custom appended rows i.e. tr elements (rows).
*/
appendedRowsTemplateRef: TemplateRef;
/**
* @internal
* Internal data structure used to hold tfoot element children i.e. tr elements (rows).
*/
customFooterTemplateRef: TemplateRef;
/**
* @internal
* Incremental id.
*/
initId: number;
/**
* @internal
* FormGroup containing all row id\'s as controls, and whether these are selected or not as values.
*/
rowSelectors: UntypedFormGroup;
/**
* @internal
* Master selector for selecting or deselecting all row selectors.
*/
groupSelector: UntypedFormControl;
private selected;
private subs;
ngOnChanges(changes: SimpleChanges): void;
ngOnInit(): void;
ngAfterContentInit(): void;
ngOnDestroy(): void;
/**
* @internal
* Returns a subscription to the master selector control that either selects or deselects all row controls.
*/
get groupValueSubscription(): Subscription;
/**
* @internal
* Returns a subscription to all individual row selectors and update the master selector if all are selected.
*/
get rowValueSubscription(): Subscription;
/**
* @internal
* Registers or disables row controls for new or removed rows.
*/
registerSelectableRows(tableData: any[]): boolean;
/**
* @internal
* Returns all enabled values unless all rows are disabled.
*/
get rowSelectorsValue(): any;
toggleSortOrderWithSpace(event: any, column: TableColumn): void;
/**
* @internal
* Switches sorting order between ascending and descending order for a column.
* @param column the column to sort rows after.
*/
toggleSortOrder(column: TableColumn): void;
/** If sortable, reorders the table data using the specified column as ordering attribute. */
sortItemsBy(column: TableColumn): TableRow[] | undefined;
/**
* @internal
* Emits row data for what row was clicked if defaultEmit is allowed.
*/
propagateItemClick(item: any, preventDefaultEmit?: boolean): void;
getAriaLabel(column: TableColumn): string | undefined;
private toggleRowToExpand;
static ɵfac: i0.ɵɵFactoryDeclaration, never>;
static ɵcmp: i0.ɵɵComponentDeclaration, "nggv-table", never, { "tableColumns": { "alias": "tableColumns"; "required": false; }; "tableData": { "alias": "tableData"; "required": false; }; "rowId": { "alias": "rowId"; "required": false; }; "hasRowSpan": { "alias": "hasRowSpan"; "required": false; }; "selectable": { "alias": "selectable"; "required": false; }; "hiddenCheckboxRowIds": { "alias": "hiddenCheckboxRowIds"; "required": false; }; "expandable": { "alias": "expandable"; "required": false; }; "expandedByDefault": { "alias": "expandedByDefault"; "required": false; }; "subItemsProp": { "alias": "subItemsProp"; "required": false; }; "allowLocalSort": { "alias": "allowLocalSort"; "required": false; }; "thook": { "alias": "thook"; "required": false; }; "trThookFn": { "alias": "trThookFn"; "required": false; }; "ariaLabelCheckboxTh": { "alias": "ariaLabelCheckboxTh"; "required": false; }; "ariaLabelCheckboxTr": { "alias": "ariaLabelCheckboxTr"; "required": false; }; "ariaLabelsOrderBy": { "alias": "ariaLabelsOrderBy"; "required": false; }; }, { "ngvRowClick": "ngvRowClick"; "ngvRowSelect": "ngvRowSelect"; "ngvOrderBy": "ngvOrderBy"; }, ["appendedRowsTemplate", "customFooterTemplate", "customTemplates"], ["*"], false, never>;
}
|