File
Index
Properties
|
|
Methods
|
|
Inputs
|
|
Outputs
|
|
Accessors
|
|
Constructor
constructor(i18n: I18n)
|
|
Parameters :
Name |
Type |
Optional |
i18n |
I18n
|
No
|
|
label
|
Type : string | Observable
|
|
name
|
Type : string
|
Default value : ""
|
|
selected
|
Type : boolean
|
Default value : false
|
|
selectionLabelColumn
|
Type : number
|
|
Used to populate the row selection checkbox label with a useful value if set.
Example:
Example :<cds-table [selectionLabelColumn]="0"></cds-table>
<!-- results in aria-label="Select first column value"
(where "first column value" is the value of the first column in the row -->
|
skeleton
|
Type : boolean
|
Default value : false
|
|
Outputs
selectedChange
|
Type : EventEmitter
|
|
Emits if a single row is selected.
|
Methods
getLabel
|
getLabel()
|
|
Returns : Observable<string>
|
getSelectionLabelValue
|
getSelectionLabelValue(row: TableItem[])
|
|
Returns : { value: any; }
|
Protected
_label
|
Default value : this.i18n.getOverridable("TABLE.CHECKBOX_ROW")
|
|
Accessors
label
|
getlabel()
|
|
setlabel(value: string | Observable)
|
|
Parameters :
Name |
Type |
Optional |
value |
string | Observable<string>
|
No
|
|
import {
Component,
Input,
Output,
EventEmitter
} from "@angular/core";
import { I18n, Overridable } from "carbon-components-angular/i18n";
import { TableItem } from "../table-item.class";
import { TableRow } from "../table-row.class";
import { Observable } from "rxjs";
import { TableRowSize } from "../table.types";
@Component({
// tslint:disable-next-line: component-selector
selector: "[cdsTableCheckbox], [ibmTableCheckbox]",
template: `
<cds-checkbox
*ngIf="!skeleton"
inline="true"
[name]="name"
[checked]="selected"
[disabled]="disabled"
(checkedChange)="selectedChange.emit()"
[hideLabel]="true">
{{getLabel() | i18nReplace:getSelectionLabelValue(row) | async}}
</cds-checkbox>
`
})
export class TableCheckbox {
@Input() row: TableItem[];
@Input() selected = false;
@Input() name = "";
get disabled(): boolean {
return this.row ? !!(this.row as TableRow).disabled : false;
}
/**
* Size of the table rows.
*/
@Input() size: TableRowSize = "md";
@Input()
set label(value: string | Observable<string>) {
this._label.override(value);
}
get label() {
return this._label.value;
}
/**
* Used to populate the row selection checkbox label with a useful value if set.
*
* Example:
* ```
* <cds-table [selectionLabelColumn]="0"></cds-table>
* <!-- results in aria-label="Select first column value"
* (where "first column value" is the value of the first column in the row -->
* ```
*/
@Input() selectionLabelColumn: number;
@Input() skeleton = false;
/**
* Emits if a single row is selected.
*/
@Output() selectedChange = new EventEmitter();
protected _label = this.i18n.getOverridable("TABLE.CHECKBOX_ROW");
constructor(protected i18n: I18n) { }
getSelectionLabelValue(row: TableItem[]) {
if (!this.selectionLabelColumn) {
return { value: this.i18n.get().TABLE.ROW };
}
return { value: row[this.selectionLabelColumn].data };
}
getLabel(): Observable<string> {
return this._label.subject;
}
}
Legend
Html element with directive