/** Angular */ import * as ng from "@angular/core"; /** Core */ import { CoreComponent } from "cmf.core/src/core"; import { Button } from "../moreOptions/moreOptions"; /** Matrix */ import { MatrixRowGroup, MatrixColumnGroup, MatrixCellsContent, MatrixRowAdditionalAction, MatrixFooterContent, MatrixCellSelectionRestriction, MatrixContentChangeArgs, MatrixRowOptionsClickArgs, MatrixContentInternal, MatrixCellSelectionArgs, MatrixCellHoverArgs, MatrixRowSelectionArgs } from "./matrixModel"; /** * Directive for ngTemplateOutlet (custom items) */ export declare class MatrixMainRowCustomItems { } /** * Directive for ngTemplateOutlet (custom title) */ export declare class MatrixMainRowCustomTitle { } /** * @whatItDoes * This components allows to build and use matrix-style tables with some custom functionality. * Currently, it is possible to have n-rows and m-columns, have default actions for the rows ('SelectAll' to select all the cells for that row, * 'SelectRemaining' to select the remaining unselected cells for that row and 'UnselectAll' which unselects all cells that are selected for that row), * select/unselect cells, have cells clicking restriction and lastly, it also supports a readonly mode where actions and clickability is disabled. * * *Important* - When altering complex content such as columns and rows, it is crucial to pass a new array to the input or else ngOnChanges won't be triggered * and this component makes use of an internal matrix in code-behind in order to keep track of changes and other logic depends on it. * * * @howToUse * This component is used with the inputs and outputs mentioned below. * * ### Inputs * * `MatrixColumnGroup[]` : **columns** - The columns to be displayed in the matrix header. * * `string` : **rowsTitle** - The title to be displayed above the rows in the left side of the matrix. * * `MatrixRow[]` : **rows** - The rows to be displayed in the left side of the matrix. * * `MatrixCellsContent[]` : **matrixCellsContent** - Allows to pass content to each cell individually. * * `MatrixCellSelectionRestriction` : **cellSelectionRestriction** - Applies logic to cell selection. * *Important*: Currently, 'None' mode is not implemented. * * `MatrixRowAdditionalAction[]` : additionalActionsForRowGroups - Allows to add custom actions to rows. * * `boolean` : **showFooterContent** - If true, the footerContent will be displayed in the bottom part of the matrix. * * `MatrixFooterContent` : **footerContent** - Additional content to be displayed in the bottom part of the matrix. * * `boolean` : **readonly** : If true, the mtrix will be displayed in a read-only mode, disabling actions and clickability. * * `boolean` : **showHeaderOnSelectedCell** : If true, when a cell is selected, the column label that it belongs to will be reflected on it. * * `boolean` : **onlyBottomBorder** : If true, the matrix will be presented with only the bottom outside border. Defaults to false. * * `boolean` : **showHeaderAction** : If true, a button will be displayed next to the matrix title. Defaults to false. * * `boolean` : **ignoreRowsDefaultActions** : If true, the rows default actions willl not be available. Defaults to false. * * `number` : **numberOfDifferentColors** : The number of different colors to use in the painint of cells. The colors are generated when this input changes. * * `boolean` : **isToOutputMatrixContentChange** : Controls if the 'matrixContentChange' output is fired. Defaults to true * * `boolean` : **isToOutputMatrixCellSelected** : Controls if the 'matrixCellSelected' output is fired. Defaults to true * * `boolean` : **isToOutputOnlyColoredCellsOnHover** : Controls whether it is to output the OnHover event only in cells that have content. Defaults to false. * * `boolean` : **rowsClickable** : This flag, by default is false * * ### Outputs * * `ng.EventEmitter` : **matrixContentChange** - When data relating to the cells change (currently, cell selection), * this output will be fired with the current data as it is observed in the DOM * * `ng.EventEmitter` : **matrixRowActionClick** - When a row more options is clicked, * this output will be fired with the row and the clicked action * * `ng.EventEmitter` : **matrixHeadActionClick** - When the action on the matrix head is clicked, * this output will be fired with the value 'true' * * `ng.EventEmitter` : **matrixFooterActionClick** - When the action on the matrix footer is clicked, * this output will be fired with the value 'true' * * `ng.EventEmitter` : **matrixCellSelected** - When a new cell is selected, this output will emit the data related to that cell * * `ng.EventEmitter` : **matrixCellHover** - When a new cell is hovered, this output will emit the data related to that cell * * ### Example * To use the component, assume the following HTML Templates as examples: * * ```HTML * Basic Matrix: * * * * Basic Read-Only Matrix: * * * ``` * * ### Dependencies * * * #### Components * MoreOptions : `cmf.core.controls` * * #### Services * _This component does not depend on any service_ * * #### Directives * _This component does not depend on any directive_ * * @class Matrix */ export declare class Matrix extends CoreComponent implements ng.OnChanges { private _elementRef; /** * Debounced version of the 'emitDataChange' method in order to optimize output creation */ private _emitDataChange; /** * The ElementRef of the matrix body's right panel */ private _matrixBodyRightPanel; /** * The ElementRef of the matrix body's left panel */ private _matrixBodyLeftPanel; /** * The ElementRef of the matrix head */ private _matrixHead; /** * The generated colors to be used to paint the cells */ private _availableColors; /** * The internal matrix. * Containts information about the linear rows, linear columns and the cells */ _matrixContentInternal: MatrixContentInternal; /** * The internal columns. * Contains information about the complex columns */ _columnsInternal: MatrixColumnGroup[]; /** * The internal rows. * Contains information about the complex rows */ _rowsInternal: MatrixRowGroup[]; /** * Array of additional actions to be displayed in a row's more options */ _actionsForRows: Button[]; /** * Indicative if there are no columns. * Used to show/hide the matrix right panel */ _columnsEmpty: boolean; /** * Controls if a css class is aplpied to the matrix head */ _largeHead: boolean; /** * Boolean flag that controls if there is data to emit */ isProcessingData: boolean; /** * Matrix main row custom items template ref */ matrixMainRowCustomItemsTemplate: ng.TemplateRef; /** * Matrix main row custom title template ref */ matrixMainRowCustomTitleTemplate: ng.TemplateRef; /** * ViewChild that captures the matrix body right panel element ref and applies scrolling logic * Currently, scroll is only applied to the matrix body rows, and it is needed to manipulate both the head and left panel with jquery */ matrixAutoScroll: ng.ElementRef; /** * ViewChild that captures the matrix body left panel element ref */ matrixLeftPanelValue: ng.ElementRef; /** * ViewChild that captures the matrix head element ref */ matrixHeadValue: ng.ElementRef; /** * The matrix columns */ columns: MatrixColumnGroup[]; /** * The matrix body content */ rows: MatrixRowGroup[]; /** * The matrix rows title */ rowsTitle: string; /** * The type of cell selection restriction. * * Default value is OnePerColumn * * Important: 'None' is not currently supported! */ cellSelectionRestriction: MatrixCellSelectionRestriction; /** * Additional actions for the row groups. * These are only applied to Complex Rows (collapsible rows) */ additionalActionsForRowGroups: MatrixRowAdditionalAction[]; /** * If true, the footer content will be displayed. * * Default is false */ showFooterContent: boolean; /** * The footer content to be displayed in the bottom of the matrix */ footerContent: MatrixFooterContent; /** * If true, the matrix is displayed in a readonly mode, removing the ability to select cells and actions * * Default is false */ readonly: boolean; /** * If true, when the cell is clicked, the column text will be displayed on the cell * * Default is false */ showHeaderOnSelectedCell: boolean; /** * The custom matrix cell content */ matrixCellsContent: MatrixCellsContent[]; /** * Flag that controls if the matrix will only be displayed with the bottom border (as a datagrid). * Defaults to false. */ onlyBottomBorder: boolean; /** * Flag that controls if a button is displayed next to the matrix title. * Defaults to false. */ showHeaderAction: boolean; /** * Flag that controls if the default actions for rows are to be ignored. * Defaults to false; */ ignoreRowsDefaultActions: boolean; /** * The number of available colors to be used to paint the background of cells */ numberOfDifferentColors: number; /** * Controls if the 'matrixContentChange' output is fired. Set to false if this is not needed as building the outputs is an heavy process. * Defaults to true. */ isToOutputMatrixContentChange: boolean; /** * Controls if the 'matrixCellSelected' output is fired. Set to false if this is not needed. * Defaults to true. */ isToOutputMatrixCellSelected: boolean; /** * EventEmitter that emits the data relative to the matrix content when it changes */ matrixContentChange: ng.EventEmitter; /** * EventEmitter that emits the data containing the action and the row that was clicked */ matrixRowActionClick: ng.EventEmitter; /** * EventEmitter that emits true when the matrix head action is clicked */ matrixHeadActionClick: ng.EventEmitter; /** * EventEmitter that emits true when the matrix footer action is clicked */ matrixFooterActionClick: ng.EventEmitter; /** * EventEmitter that emits the data related to a new cell that was selected */ matrixCellSelected: ng.EventEmitter; /** * EventEmitter that emits the data related to a new cell that was hovered */ matrixCellHover: ng.EventEmitter; /** * EventEmitter that emits the data related to a new row that was selected */ matrixRowSelected: ng.EventEmitter; /** * Determines whether it is to output the OnHover event only in cells that have content (color, selected, etc.) */ isToOutputOnlyColoredCellsOnHover: boolean; /** * Row clickable flag (component input) */ rowsClickable: boolean; /** * EventEmitter that emits the data related to when mouse leaves a previously hovered cell */ matrixCellHoverLeave: ng.EventEmitter; /** * Last row selected */ lastRowSelected: any; /** * Matrix component constructor * @param _elementRef The element ref of this component */ constructor(_elementRef: ng.ElementRef); /** * Evaluates the cells content with the cell selection restriction logic * TODO: Add cell restriction logic in order to not just set cell as selected */ private evaluateCellsContent; /** * Emits data with the cells content */ private emitDataChange; /** * Callback used to emit the data related to a new selected cell/row * @param groupIndex The index of the row group * @param childRowIndex The index of the child row of the row group * @param columnIndex The index of the column */ private emitSelection; /** * Updates the internal matrix and its content (rows, columns, cells) */ private updateMatrixContentInternal; /** * Maps the default actions to an array of buttons to be used in the more options component */ private buildDefaultActionsButtons; /** * Maps the custom actions to an array of buttons to be used in the more options component */ private buildCustomActionsButtons; /** * Calculates colors for cells given the total number of wanted colors */ private calculateCellColors; /** * On matrix row click * @param groupIndex The group index * @param childRowIndex The child row index */ onMatrixRowClick(groupIndex: any, childRowIndex: any): void; /** * Handles logic of clicking in any cell present in the matrix body * @param event The mouse click event */ onMatrixBodyClick(event: MouseEvent): void; /** * Handles the logic of clicking in a row's action * @param clickedChildRow The row group where the action was clicked * @param item The action clicked on */ onRowMoreOptionsItemSelect(clickedChildRow: any, item: any): void; /** * Callback called when the action on the matrix head is clicked. * Consequently, it emits the 'matrixHeadActionClick' with value 'true'. */ onMatrixHeadActionClick(): void; /** * Callback called when the action on the matrix footer is clicked. * Consequently, it emits the 'matrixFooterActionClick' with value 'true'. */ onMatrixFooterContentActionClick(): void; /** * Gets the first color of the first row in the passed row group index, which has a colored cell for the passed column index * @param groupIndex The index of the row group * @param columnIndex The index of the column */ getColorForCell(groupIndex: number, columnIndex: number): string; isMatrixCelClickable(groupIndex: number, childRowIndex: number, columnIndex: number): boolean; getMatrixInnerText(groupIndex: number, childRowIndex: number, columnIndex: number): string; /** * Handles changes to this component's inputs * @param changes The changes made to this component's inputs */ ngOnChanges(changes: ng.SimpleChanges): void; /** * On Mouse Enter, inside colored cell, event will emit row group, row group's child row, column and the mouse event in which the mouse hovered * @param rowGroup Hovered Row Group * @param childRow Hovered Row Group's child row * @param column Hovered Column * @param event Mouse Event */ onMouseEnter(rowGroup: MatrixRowGroup, childRow: MatrixRowGroup, column: string, event: MouseEvent): void; /** * On Mouse leave, inside colored cell, event will emit row group, row group's child row, column and the mouse event in which the mouse hovered * @param rowGroup Hovered Row Group * @param childRow Hovered Row Group's child row * @param column Hovered Column * @param event Mouse Event */ onMouseLeave(rowGroup: MatrixRowGroup, childRow: MatrixRowGroup, column: string, event: MouseEvent): void; } export declare class MatrixModule { }