All files / src/components/zd-table table.ts

100% Statements 10/10
100% Branches 0/0
100% Functions 1/1
100% Lines 10/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 6693x   93x           93x       2x                 2x         2x           2x           2x           2x                                   1x      
import { Column } from '../zd-iterable/column';
import { IColumn } from '../zd-iterable/interfaces';
import { Iterable } from '../zd-iterable/iterable';
import { ITable, ITableCaption, ITableProps } from './interfaces';
 
/**
 * Base class for Table component.
 */
export class Table extends Iterable implements ITable {
	/**
	 * Defines table caption.
	 */
	public caption: ITableCaption = {
		label: '',
		isVisible: false,
		align: 'left',
	};
 
	/**
	 * Controls table width.
	 */
	public fillWidth = false;
 
	/**
	 * Controls table head visibility.
	 */
	public showTableHead = true;
 
	/**
	 * Defines the component height. Possible values for this property can be
	 * <samp>'auto', '100%', '400px' or 400</samp>
	 */
	public height: string | number = 'auto';
 
	/**
	 * Defines the component min height. Possible values for this property can be
	 * <samp>'auto', '100%', '400px' or 400</samp>
	 */
	public minHeight: string | number = 'auto';
 
	/**
	 * Defines the component max height. Possible values for this property can be
	 * <samp>'auto', '100%', '400px' or 400</samp>
	 */
	public maxHeight: string | number = 'none';
 
	/* istanbul ignore next */
	/**
	 * Creates a new Table.
	 * @param table Table properties
	 */
	constructor(props: ITableProps) {
		super(props);
		this.caption = { ...this.caption, ...(props.caption || {}) };
		this.fillWidth = this.getInitValue('fillWidth', props.fillWidth, this.fillWidth);
		this.showTableHead = this.getInitValue('showTableHead', props.showTableHead, this.showTableHead);
		this.height = this.getInitValue('height', props.height, this.height);
		this.minHeight = this.getInitValue('minHeight', props.minHeight, this.minHeight);
		this.maxHeight = this.getInitValue('maxHeight', props.maxHeight, this.maxHeight);
	}
 
	public createColumn(column: IColumn): Column {
		return new Column(column);
	}
}