carbon-components-angular
Version:
Next generation components
87 lines • 8.71 kB
JavaScript
import { Component, Input, Output, EventEmitter } from "@angular/core";
import * as i0 from "@angular/core";
import * as i1 from "carbon-components-angular/i18n";
import * as i2 from "@angular/common";
import * as i3 from "carbon-components-angular/checkbox";
export class TableCheckbox {
constructor(i18n) {
this.i18n = i18n;
this.selected = false;
this.name = "";
/**
* Size of the table rows.
*/
this.size = "md";
this.skeleton = false;
/**
* Emits if a single row is selected.
*/
this.selectedChange = new EventEmitter();
this._label = this.i18n.getOverridable("TABLE.CHECKBOX_ROW");
}
get disabled() {
return this.row ? !!this.row.disabled : false;
}
set label(value) {
this._label.override(value);
}
get label() {
return this._label.value;
}
getSelectionLabelValue(row) {
if (!this.selectionLabelColumn) {
return { value: this.i18n.get().TABLE.ROW };
}
return { value: row[this.selectionLabelColumn].data };
}
getLabel() {
return this._label.subject;
}
}
TableCheckbox.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TableCheckbox, deps: [{ token: i1.I18n }], target: i0.ɵɵFactoryTarget.Component });
TableCheckbox.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: TableCheckbox, selector: "[cdsTableCheckbox], [ibmTableCheckbox]", inputs: { row: "row", selected: "selected", name: "name", size: "size", label: "label", selectionLabelColumn: "selectionLabelColumn", skeleton: "skeleton" }, outputs: { selectedChange: "selectedChange" }, ngImport: i0, template: `
<cds-checkbox
*ngIf="!skeleton"
inline="true"
[name]="name"
[ariaLabel]="getLabel() | i18nReplace:getSelectionLabelValue(row) | async"
[checked]="selected"
[disabled]="disabled"
(checkedChange)="selectedChange.emit()">
</cds-checkbox>
`, isInline: true, dependencies: [{ kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i3.Checkbox, selector: "cds-checkbox, ibm-checkbox", inputs: ["disabled", "skeleton", "hideLabel", "name", "id", "required", "value", "ariaLabel", "ariaLabelledby", "indeterminate", "checked"], outputs: ["click", "checkedChange", "indeterminateChange"] }, { kind: "pipe", type: i2.AsyncPipe, name: "async" }, { kind: "pipe", type: i1.ReplacePipe, name: "i18nReplace" }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TableCheckbox, decorators: [{
type: Component,
args: [{
// tslint:disable-next-line: component-selector
selector: "[cdsTableCheckbox], [ibmTableCheckbox]",
template: `
<cds-checkbox
*ngIf="!skeleton"
inline="true"
[name]="name"
[ariaLabel]="getLabel() | i18nReplace:getSelectionLabelValue(row) | async"
[checked]="selected"
[disabled]="disabled"
(checkedChange)="selectedChange.emit()">
</cds-checkbox>
`
}]
}], ctorParameters: function () { return [{ type: i1.I18n }]; }, propDecorators: { row: [{
type: Input
}], selected: [{
type: Input
}], name: [{
type: Input
}], size: [{
type: Input
}], label: [{
type: Input
}], selectionLabelColumn: [{
type: Input
}], skeleton: [{
type: Input
}], selectedChange: [{
type: Output
}] } });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFibGUtY2hlY2tib3guY29tcG9uZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL3RhYmxlL2NlbGwvdGFibGUtY2hlY2tib3guY29tcG9uZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFDTixTQUFTLEVBQ1QsS0FBSyxFQUNMLE1BQU0sRUFDTixZQUFZLEVBQ1osTUFBTSxlQUFlLENBQUM7Ozs7O0FBc0J2QixNQUFNLE9BQU8sYUFBYTtJQThDekIsWUFBc0IsSUFBVTtRQUFWLFNBQUksR0FBSixJQUFJLENBQU07UUEzQ3ZCLGFBQVEsR0FBRyxLQUFLLENBQUM7UUFFakIsU0FBSSxHQUFHLEVBQUUsQ0FBQztRQU1uQjs7V0FFRztRQUNNLFNBQUksR0F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