import { Component, Input, Output, EventEmitter, ChangeDetectionStrategy, ContentChild, TemplateRef } from '@angular/core'; import { CommonModule } from '@angular/common'; export type TableVariant = 'default' | 'striped' | 'bordered' | 'minimal'; export type TableSize = 'compact' | 'default' | 'comfortable'; export type TableColumnAlign = 'left' | 'center' | 'right'; export interface TableColumn { key: string; label: string; sortable?: boolean; align?: TableColumnAlign; width?: string; sticky?: boolean; } export interface TableSortEvent { column: string; direction: 'asc' | 'desc' | null; } @Component({ selector: 'ui-table', standalone: true, imports: [CommonModule], changeDetection: ChangeDetectionStrategy.OnPush, template: `
|
{{ column.label }}
@if (column.sortable && sortColumn === column.key) {
@if (sortDirection === 'asc') {
↑
} @else if (sortDirection === 'desc') {
↓
}
}
|
}
|---|
|
@if (emptyTemplate) {
{{ emptyMessage }}
}
|
|
@if (getCellTemplate(column.key)) {
|
}