File

src/structured-list/list-row.component.ts

Description

ListRow provides a container for the ListColumns that make up the body of a structured list.

Example:

    <cds-list-row>
        <cds-list-column>Row 1</cds-list-column>
        <cds-list-column nowrap="true">Row One</cds-list-column>
        <cds-list-column>
            Lorem ipsum dolor sit amet,
            consectetur adipiscing elit. Nunc dui magna,
            finibus id tortor sed, aliquet bibendum augue.
            Aenean posuere sem vel euismod dignissim. Nulla ut cursus dolor.
            Pellentesque vulputate nisl a porttitor interdum.
        </cds-list-column>
    </cds-list-row>

Implements

AfterContentInit

Metadata

Index

Properties
Methods
Inputs
Outputs
HostBindings
HostListeners
Accessors

Inputs

label
Type : any

Applies an accessible label to the row. Defaults to no label.

selected
Type : boolean
Default value : false
value
Type : any

The value for the row. Returned via ngModel or selected event on the containing StructuredList.

Outputs

change
Type : EventEmitter<Event>

Internal event used to notify the containing StructuredList of changes.

HostBindings

attr.role
Type : string
Default value : "row"
attr.tabindex
Type : string
Default value : this.selection ? "0" : null
class.cds--structured-list-row
Type : boolean
Default value : true
class.cds--structured-list-row--focused-within
Type : boolean

HostListeners

blur
blur()
click
click()
focus
focus()

Methods

ngAfterContentInit
ngAfterContentInit()
Returns : void
onblur
onblur()
Decorators :
@HostListener('blur')
Returns : void
onChange
onChange(event)
Parameters :
Name Optional
event No
Returns : void
onclick
onclick()
Decorators :
@HostListener('click')
Returns : void
onfocus
onfocus()
Decorators :
@HostListener('focus')
Returns : void

Properties

columns
Type : QueryList<ListColumn>
Decorators :
@ContentChildren(ListColumn)
input
Type : ElementRef
Decorators :
@ViewChild('input')
Private isFocused
Default value : false
name
Type : string
Default value : "list"

Set by the containing StructuredList. When selection = true, used for the name property on the radio input.

role
Type : string
Default value : "row"
Decorators :
@HostBinding('attr.role')
selection
Default value : false

Set by the containing StructuredList. Enables or disables row level selection features.

tabindex
Default value : this.selection ? "0" : null
Decorators :
@HostBinding('attr.tabindex')
wrapper
Default value : true
Decorators :
@HostBinding('class.cds--structured-list-row')

Accessors

focusClass
getfocusClass()
import {
	Component,
	HostBinding,
	ContentChildren,
	QueryList,
	AfterContentInit,
	Input,
	HostListener,
	ViewChild,
	ElementRef,
	EventEmitter,
	Output
} from "@angular/core";
import { ListColumn } from "./list-column.component";

/**
 * `ListRow` provides a container for the `ListColumn`s that make up the body of a structured list.
 *
 * Example:
 * ```html
 * 	<cds-list-row>
 *		<cds-list-column>Row 1</cds-list-column>
 *		<cds-list-column nowrap="true">Row One</cds-list-column>
 *		<cds-list-column>
 *			Lorem ipsum dolor sit amet,
 *			consectetur adipiscing elit. Nunc dui magna,
 *			finibus id tortor sed, aliquet bibendum augue.
 *			Aenean posuere sem vel euismod dignissim. Nulla ut cursus dolor.
 *			Pellentesque vulputate nisl a porttitor interdum.
 *		</cds-list-column>
 *	</cds-list-row>
 * ```
 */
@Component({
	selector: "cds-list-row, ibm-list-row",
	template: `
		<ng-content></ng-content>
		<ng-container *ngIf="selection">
			<input
				#input
				tabindex="-1"
				class="cds--structured-list-input cds--visually-hidden"
				type="radio"
				[value]="value"
				[name]="name"
				[title]="label"
				(change)="onChange($event)"
				[checked]="selected"/>
			<div class="cds--structured-list-td">
				<svg cdsIcon="checkmark--filled" size="16" class="cds--structured-list-svg"></svg>
			</div>
		</ng-container>
	`
})
export class ListRow implements AfterContentInit {
	@HostBinding("class.cds--structured-list-row--focused-within") get focusClass() {
		return this.isFocused;
	}
	@Input() @HostBinding("class.cds--structured-list-row--selected") selected = false;
	/**
	 * Applies an accessible label to the row. Defaults to no label.
	 */
	@Input() @HostBinding("attr.aria-label") label;
	/**
	 * The value for the row. Returned via `ngModel` or `selected` event on the containing `StructuredList`.
	 */
	@Input() value;
	/**
	 * Internal event used to notify the containing `StructuredList` of changes.
	 */
	@Output() change: EventEmitter<Event> = new EventEmitter();

	/**
	 * Set by the containing `StructuredList`. Enables or disables row level selection features.
	 */
	selection = false;
	/**
	 * Set by the containing `StructuredList`. When `selection = true`, used for the `name` property on the radio input.
	 */
	name = "list";

	@HostBinding("class.cds--structured-list-row") wrapper = true;
	@HostBinding("attr.tabindex") tabindex = this.selection ? "0" : null;
	@HostBinding("attr.role") role = "row";

	@ContentChildren(ListColumn) columns: QueryList<ListColumn>;

	@ViewChild("input") input: ElementRef;

	private isFocused = false;

	ngAfterContentInit() {
		this.columns.forEach(column => {
			column.isBodyColumn = true;
			column.isHeaderColumn = false;
		});
	}

	@HostListener("click")
	onclick() {
		if (this.selection) {
			this.input.nativeElement.click();
		}
	}

	@HostListener("focus")
	onfocus() {
		this.isFocused = true;
	}

	@HostListener("blur")
	onblur() {
		this.isFocused = false;
	}

	onChange(event) {
		this.change.emit(event);
	}
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""