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

100% Statements 14/14
100% Branches 0/0
100% Functions 0/0
100% Lines 14/14

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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 9093x           93x       2x         2x         2x         2x         2x         2x         2x         2x         2x         2x         2x         2x                                                
import { Button } from '../zd-button/button';
import { IChip } from './interfaces';
 
/**
 * Base class for Chip component.
 */
export class Chip extends Button implements IChip {
	/**
	 * Determines whether the chip is active or not
	 */
	public active = true;
 
	/**
	 * Configure the active CSS class applied when the link is active
	 */
	public activeClass = '';
 
	/**
	 * Adds remove button
	 */
	public closable = false;
 
	/**
	 * Change the default icon used for close chips
	 */
	public closeIcon = 'delete';
 
	/**
	 * Makes the chip draggable
	 */
	public draggable = false;
 
	/**
	 * Explicitly define the chip as a link
	 */
	public link = false;
 
	/**
	 * Removes background and applies border and text color
	 */
	public outlined = false;
 
	/**
	 * Applies the ripple
	 */
	public ripple = true;
 
	/**
	 * Applies a large border radius on the chip
	 */
	public round = true;
 
	/**
	 * Value Model
	 */
	public value = false;
 
	/**
	 * Makes the component extra large
	 */
	public xLarge = false;
 
	/**
	 * Makes the component extra small
	 */
	public xSmall = false;
 
	/* istanbul ignore next */
	/**
	 * Create a new Chip
	 * @param props Chip definition
	 */
	constructor(props: IChip) {
		super(props);
		this.active = this.getInitValue('active', props.active, this.active);
		this.activeClass = this.getInitValue('activeClass', props.activeClass, this.activeClass);
		this.closable = this.getInitValue('closable', props.closable, this.closable);
		this.closeIcon = this.getInitValue('closeIcon', props.closeIcon, this.closeIcon);
		this.draggable = this.getInitValue('draggable', props.draggable, this.draggable);
		this.link = this.getInitValue('link', props.link, this.link);
		this.outlined = this.getInitValue('outlined', props.outlined, this.outlined);
		this.ripple = this.getInitValue('ripple', props.ripple, this.ripple);
		this.round = this.getInitValue('round', props.round, this.round);
		this.value = this.getInitValue('value', props.value, this.value);
		this.xLarge = this.getInitValue('xLarge', props.xLarge, this.xLarge);
		this.xSmall = this.getInitValue('xSmall', props.xSmall, this.xSmall);
		this.createAccessors();
	}
}