Skip to content

Commit baf0af7

Browse files
author
Luis M Torres
committed
feat: icon template and select item output call
1 parent 7183b99 commit baf0af7

File tree

5 files changed

+45
-8
lines changed

5 files changed

+45
-8
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@dotted-labs/ngx-bootstrap-components",
3-
"version": "0.0.11",
3+
"version": "1.0.0",
44
"scripts": {
55
"ng": "ng",
66
"start": "ng serve",

projects/ngx-bootstrap-components/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@dotted-labs/ngx-bootstrap-components",
3-
"version": "0.0.11",
3+
"version": "0.0.14",
44
"peerDependencies": {
55
"@angular/common": "^17.3.0",
66
"@angular/core": "^17.3.0",

projects/ngx-bootstrap-components/table/src/components/table/table.component.html

+22-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
<table class="table m-0" [class.table-hover]="isClickable()">
1111
<thead>
1212
<tr>
13+
@if (iconTemplate()) {
14+
<th scope="col"></th>
15+
}
1316
@for (column of columns(); track column) {
1417
<th scope="col">{{ column | translate }}</th>
1518
}
@@ -19,6 +22,13 @@
1922
@if (isLoading() && isEmpty()) {
2023
@for (column of skeletonRowsArr(); track column) {
2124
<tr>
25+
@if (iconTemplate()) {
26+
<td style="width: 40px">
27+
<span class="placeholder-glow">
28+
<span class="placeholder col-12"></span>
29+
</span>
30+
</td>
31+
}
2232
@for (column of columns(); track column) {
2333
<td>
2434
<span class="placeholder-glow">
@@ -48,9 +58,18 @@ <h6 class="text-body-secondary">
4858
</tr>
4959
} @else {
5060
@for (item of items(); track item) {
51-
@if (rowTemplate()) {
52-
<ng-container [ngTemplateOutlet]="rowTemplate()" [ngTemplateOutletContext]="{ $implicit: item }"></ng-container>
53-
}
61+
<tr [class.table-active]="selectedIds()?.includes(item.id)" [class.cursor-pointer]="isClickable()" (click)="selectItem.emit(item)">
62+
@if (iconTemplate()) {
63+
<td style="width: 40px">
64+
<div class="d-flex align-items-center justify-content-center" style="height: 21px">
65+
<ng-container [ngTemplateOutlet]="iconTemplate()" [ngTemplateOutletContext]="{ $implicit: item }"></ng-container>
66+
</div>
67+
</td>
68+
}
69+
@if (rowTemplate()) {
70+
<ng-container [ngTemplateOutlet]="rowTemplate()" [ngTemplateOutletContext]="{ $implicit: item }"></ng-container>
71+
}
72+
</tr>
5473
}
5574
}
5675
</tbody>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
:host {
2+
.cursor-pointer {
3+
cursor: pointer;
4+
}
5+
}

projects/ngx-bootstrap-components/table/src/components/table/table.component.ts

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
import { NgTemplateOutlet } from '@angular/common';
2-
import { ChangeDetectionStrategy, Component, InputSignal, Signal, TemplateRef, computed, input } from '@angular/core';
2+
import {
3+
ChangeDetectionStrategy,
4+
Component,
5+
InputSignal,
6+
OutputEmitterRef,
7+
Signal,
8+
TemplateRef,
9+
computed,
10+
input,
11+
output,
12+
} from '@angular/core';
313
import { TranslateModule } from '@ngx-translate/core';
414

515
@Component({
@@ -11,7 +21,7 @@ import { TranslateModule } from '@ngx-translate/core';
1121
changeDetection: ChangeDetectionStrategy.OnPush,
1222
})
1323
export class DtlTableComponent {
14-
public items: InputSignal<unknown[]> = input.required<unknown[]>();
24+
public items: InputSignal<({ id: string } & unknown)[]> = input.required<({ id: string } & unknown)[]>();
1525
public columns: InputSignal<string[]> = input.required<string[]>();
1626
public isLoaded: InputSignal<boolean> = input.required<boolean>();
1727
public isLoading: InputSignal<boolean> = input.required<boolean>();
@@ -21,6 +31,9 @@ export class DtlTableComponent {
2131
public skeletonRowsArr: Signal<number[]> = computed<number[]>(() => Array(this.skeletonRows()));
2232
public rowTemplate: InputSignal<TemplateRef<unknown>> = input.required<TemplateRef<unknown>>();
2333
public emptyTemplate: InputSignal<TemplateRef<unknown>> = input<TemplateRef<unknown>>();
24-
34+
public iconTemplate: InputSignal<TemplateRef<unknown>> = input<TemplateRef<unknown>>();
35+
public selectedIds: InputSignal<unknown[]> = input<unknown[]>();
2536
public isClickable: InputSignal<boolean> = input<boolean>(true);
37+
38+
public selectItem: OutputEmitterRef<unknown> = output<unknown>();
2639
}

0 commit comments

Comments
 (0)