All files / src/components/zd-list list-item.ts

100% Statements 18/18
100% Branches 4/4
100% Functions 1/1
100% Lines 18/18

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 66 67 68 69 70 71 7293x             93x                 8x                                       8x                   8x             8x     8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x   8x      
import { ComponentRender } from '../zd-component/component-render';
import { IComponent } from '../zd-component/interfaces';
import { IListItem } from './interfaces';
 
/**
 * Base class for ListItem component.
 */
export class ListItem extends ComponentRender implements IListItem {
	/**
	 * Append an icon inside the item.
	 */
	public appendIcon?: string;
 
	/**
	 * Removes the ability to click or target the item.
	 */
	public disabled = false;
 
	/**
	 * Prepend a component inside the item.
	 */
	public leftField?: IComponent;
 
	/**
	 * Prepend an icon inside the item.
	 */
	public prependIcon?: string;
 
	/**
	 * Append a component inside the item.
	 */
	public rightField?: IComponent;
 
	/**
	 * Apply the ripple effect to show action from a user.
	 */
	public ripple = true;
 
	/**
	 * Defines the item subtitle.
	 */
	public subtitle?: string;
 
	/**
	 * Increases the item height to better support more lines of text.
	 */
	public lines?: false | 'one' | 'two' | 'three' = 'one';
 
	/**
	 * Defines the item title.
	 */
	public title?: string;
 
	public dense = false;
 
	constructor(props: IListItem) {
		super(props);
		this.appendIcon = this.getInitValue('appendIcon', props.appendIcon, this.appendIcon);
		this.disabled = this.getInitValue('disabled', props.disabled, this.disabled);
		this.leftField = props.leftField || this.leftField;
		this.prependIcon = this.getInitValue('prependIcon', props.prependIcon, this.prependIcon);
		this.rightField = props.rightField || this.rightField;
		this.ripple = this.getInitValue('ripple', props.ripple, this.ripple);
		this.subtitle = this.getInitValue('subtitle', props.subtitle, this.subtitle);
		this.lines = this.getInitValue('lines', props.lines, this.lines);
		this.title = this.getInitValue('title', props.title, this.title);
		this.dense = this.getInitValue('dense', props.dense, this.dense);
 
		this.createAccessors();
	}
}