ngx-simple-datatables 1.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +222 -0
- package/esm2022/interfaces/column-config.interface.mjs +2 -0
- package/esm2022/lib/ngx-simple-datatable.component.mjs +483 -0
- package/esm2022/lib/ngx-simple-datatable.service.mjs +14 -0
- package/esm2022/ngx-simple-datatables.mjs +5 -0
- package/esm2022/public-api.mjs +6 -0
- package/fesm2022/ngx-simple-datatables.mjs +506 -0
- package/fesm2022/ngx-simple-datatables.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/interfaces/column-config.interface.d.ts +12 -0
- package/lib/ngx-simple-datatable.component.d.ts +78 -0
- package/lib/ngx-simple-datatable.service.d.ts +6 -0
- package/package.json +49 -0
- package/public-api.d.ts +2 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export class NgxSimpleDatatableService {
|
|
4
|
+
constructor() { }
|
|
5
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: NgxSimpleDatatableService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
6
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: NgxSimpleDatatableService, providedIn: 'root' }); }
|
|
7
|
+
}
|
|
8
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: NgxSimpleDatatableService, decorators: [{
|
|
9
|
+
type: Injectable,
|
|
10
|
+
args: [{
|
|
11
|
+
providedIn: 'root'
|
|
12
|
+
}]
|
|
13
|
+
}], ctorParameters: () => [] });
|
|
14
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmd4LXNpbXBsZS1kYXRhdGFibGUuc2VydmljZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3Byb2plY3RzL25neC1zaW1wbGUtZGF0YXRhYmxlL3NyYy9saWIvbmd4LXNpbXBsZS1kYXRhdGFibGUuc2VydmljZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sZUFBZSxDQUFDOztBQUszQyxNQUFNLE9BQU8seUJBQXlCO0lBRXBDLGdCQUFnQixDQUFDOytHQUZOLHlCQUF5QjttSEFBekIseUJBQXlCLGNBRnhCLE1BQU07OzRGQUVQLHlCQUF5QjtrQkFIckMsVUFBVTttQkFBQztvQkFDVixVQUFVLEVBQUUsTUFBTTtpQkFDbkIiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBJbmplY3RhYmxlIH0gZnJvbSAnQGFuZ3VsYXIvY29yZSc7XG5cbkBJbmplY3RhYmxlKHtcbiAgcHJvdmlkZWRJbjogJ3Jvb3QnXG59KVxuZXhwb3J0IGNsYXNzIE5neFNpbXBsZURhdGF0YWJsZVNlcnZpY2Uge1xuXG4gIGNvbnN0cnVjdG9yKCkgeyB9XG59XG4iXX0=
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated bundle index. Do not edit.
|
|
3
|
+
*/
|
|
4
|
+
export * from './public-api';
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmd4LXNpbXBsZS1kYXRhdGFibGVzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vcHJvamVjdHMvbmd4LXNpbXBsZS1kYXRhdGFibGUvc3JjL25neC1zaW1wbGUtZGF0YXRhYmxlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7R0FFRztBQUVILGNBQWMsY0FBYyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBHZW5lcmF0ZWQgYnVuZGxlIGluZGV4LiBEbyBub3QgZWRpdC5cbiAqL1xuXG5leHBvcnQgKiBmcm9tICcuL3B1YmxpYy1hcGknO1xuIl19
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Public API Surface of ngx-simple-datatable
|
|
3
|
+
*/
|
|
4
|
+
export * from './lib/ngx-simple-datatable.service';
|
|
5
|
+
export * from './lib/ngx-simple-datatable.component';
|
|
6
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljLWFwaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3Byb2plY3RzL25neC1zaW1wbGUtZGF0YXRhYmxlL3NyYy9wdWJsaWMtYXBpLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBRUgsY0FBYyxvQ0FBb0MsQ0FBQztBQUNuRCxjQUFjLHNDQUFzQyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLypcbiAqIFB1YmxpYyBBUEkgU3VyZmFjZSBvZiBuZ3gtc2ltcGxlLWRhdGF0YWJsZVxuICovXG5cbmV4cG9ydCAqIGZyb20gJy4vbGliL25neC1zaW1wbGUtZGF0YXRhYmxlLnNlcnZpY2UnO1xuZXhwb3J0ICogZnJvbSAnLi9saWIvbmd4LXNpbXBsZS1kYXRhdGFibGUuY29tcG9uZW50JztcbiJdfQ==
|
|
@@ -0,0 +1,506 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Injectable, PLATFORM_ID, ContentChild, ViewChild, Input, Inject, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
import * as i1 from '@angular/common';
|
|
4
|
+
import { isPlatformBrowser, CommonModule } from '@angular/common';
|
|
5
|
+
|
|
6
|
+
class NgxSimpleDatatableService {
|
|
7
|
+
constructor() { }
|
|
8
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: NgxSimpleDatatableService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
9
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: NgxSimpleDatatableService, providedIn: 'root' }); }
|
|
10
|
+
}
|
|
11
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: NgxSimpleDatatableService, decorators: [{
|
|
12
|
+
type: Injectable,
|
|
13
|
+
args: [{
|
|
14
|
+
providedIn: 'root'
|
|
15
|
+
}]
|
|
16
|
+
}], ctorParameters: () => [] });
|
|
17
|
+
|
|
18
|
+
class NgxSimpleDatatableComponent {
|
|
19
|
+
constructor(cdr, platformId, ngZone) {
|
|
20
|
+
this.cdr = cdr;
|
|
21
|
+
this.platformId = platformId;
|
|
22
|
+
this.ngZone = ngZone;
|
|
23
|
+
this.columns = [];
|
|
24
|
+
this.data = [];
|
|
25
|
+
this.rowHeight = 40;
|
|
26
|
+
this.headerHeight = 50;
|
|
27
|
+
this.bufferSize = 10;
|
|
28
|
+
// Virtualization properties
|
|
29
|
+
this.visibleStartIndex = 0;
|
|
30
|
+
this.visibleEndIndex = 0;
|
|
31
|
+
this.visibleRows = [];
|
|
32
|
+
this.totalHeight = 0;
|
|
33
|
+
this.offsetY = 0;
|
|
34
|
+
this.containerHeight = 0;
|
|
35
|
+
// Column properties
|
|
36
|
+
this.leftFrozenColumns = [];
|
|
37
|
+
this.centerColumns = [];
|
|
38
|
+
this.rightFrozenColumns = [];
|
|
39
|
+
this.columnWidths = {};
|
|
40
|
+
// Sorting
|
|
41
|
+
this.sortState = { field: "", direction: null };
|
|
42
|
+
// Resizing
|
|
43
|
+
this.isResizing = false;
|
|
44
|
+
this.resizingColumn = "";
|
|
45
|
+
this.startX = 0;
|
|
46
|
+
this.startWidth = 0;
|
|
47
|
+
// Scroll listeners
|
|
48
|
+
this.scrollListener = null;
|
|
49
|
+
this.resizeListener = null;
|
|
50
|
+
this.storageKey = "ngx-simple-datatable-column-widths";
|
|
51
|
+
this.scrollRequestId = null;
|
|
52
|
+
this.resizeTimer = null;
|
|
53
|
+
this.mouseMoveHandler = null;
|
|
54
|
+
this.mouseUpHandler = null;
|
|
55
|
+
// Track last scroll time to prevent feedback loops
|
|
56
|
+
this.lastScrollTime = 0;
|
|
57
|
+
this.SCROLL_DEBOUNCE = 10; // ms
|
|
58
|
+
// Track scroll position for header transform
|
|
59
|
+
this.headerTransform = "translateX(0)";
|
|
60
|
+
// TrackBy functions for performance
|
|
61
|
+
this.trackByRowIndex = (index) => this.visibleStartIndex + index;
|
|
62
|
+
this.trackByColumnField = (index, column) => column.field;
|
|
63
|
+
this.isBrowser = isPlatformBrowser(this.platformId);
|
|
64
|
+
}
|
|
65
|
+
ngOnInit() {
|
|
66
|
+
this.initializeColumns();
|
|
67
|
+
if (this.isBrowser) {
|
|
68
|
+
this.setupEventListeners();
|
|
69
|
+
}
|
|
70
|
+
this.calculateVirtualization();
|
|
71
|
+
}
|
|
72
|
+
ngOnDestroy() {
|
|
73
|
+
if (this.isBrowser) {
|
|
74
|
+
this.removeEventListeners();
|
|
75
|
+
// Clean up any pending animations or timeouts
|
|
76
|
+
if (this.scrollRequestId) {
|
|
77
|
+
cancelAnimationFrame(this.scrollRequestId);
|
|
78
|
+
}
|
|
79
|
+
if (this.resizeTimer) {
|
|
80
|
+
clearTimeout(this.resizeTimer);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
ngAfterContentInit() {
|
|
85
|
+
// if (!this.headerTemplate) {
|
|
86
|
+
// throw new Error("ngx-simple-datatable requires a headerTemplate.");
|
|
87
|
+
// }
|
|
88
|
+
// if (!this.cellTemplate) {
|
|
89
|
+
// throw new Error("ngx-simple-datatable requires a cellTemplate.");
|
|
90
|
+
// }
|
|
91
|
+
}
|
|
92
|
+
initializeColumns() {
|
|
93
|
+
this.leftFrozenColumns = this.columns.filter((col) => col.freeze === "left");
|
|
94
|
+
this.rightFrozenColumns = this.columns.filter((col) => col.freeze === "right");
|
|
95
|
+
this.centerColumns = this.columns.filter((col) => !col.freeze);
|
|
96
|
+
// Load saved column widths if available
|
|
97
|
+
const savedWidths = this.loadColumnWidths();
|
|
98
|
+
// Initialize column widths
|
|
99
|
+
this.columns.forEach((col) => {
|
|
100
|
+
if (col.width) {
|
|
101
|
+
this.columnWidths[col.field] = Number.parseInt(col.width.replace("px", ""));
|
|
102
|
+
}
|
|
103
|
+
else if (savedWidths && savedWidths[col.field]) {
|
|
104
|
+
this.columnWidths[col.field] = savedWidths[col.field];
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
this.columnWidths[col.field] = 150; // default width
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
setupEventListeners() {
|
|
112
|
+
// Store references for cleanup
|
|
113
|
+
this.scrollListener = (event) => this.onBodyScroll(event);
|
|
114
|
+
this.resizeListener = () => this.onResize();
|
|
115
|
+
this.mouseMoveHandler = (event) => this.onMouseMove(event);
|
|
116
|
+
this.mouseUpHandler = (event) => this.onMouseUp();
|
|
117
|
+
// Add event listeners
|
|
118
|
+
if (this.isBrowser) {
|
|
119
|
+
// For the header scroll (horizontal only)
|
|
120
|
+
if (this.headerRow?.nativeElement) {
|
|
121
|
+
this.headerRow.nativeElement.addEventListener("scroll", () => this.onHeaderScroll(null));
|
|
122
|
+
}
|
|
123
|
+
// For the body scroll (both vertical and horizontal)
|
|
124
|
+
if (this.tableBody?.nativeElement && this.scrollListener) {
|
|
125
|
+
this.tableBody.nativeElement.addEventListener("scroll", this.scrollListener);
|
|
126
|
+
}
|
|
127
|
+
// Window resize and mouse events
|
|
128
|
+
if (this.resizeListener) {
|
|
129
|
+
window.addEventListener("resize", this.resizeListener);
|
|
130
|
+
}
|
|
131
|
+
if (this.mouseMoveHandler) {
|
|
132
|
+
document.addEventListener("mousemove", this.mouseMoveHandler);
|
|
133
|
+
}
|
|
134
|
+
if (this.mouseUpHandler) {
|
|
135
|
+
document.addEventListener("mouseup", this.mouseUpHandler);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
removeEventListeners() {
|
|
140
|
+
if (this.isBrowser) {
|
|
141
|
+
// Clear any pending animations or timeouts
|
|
142
|
+
if (this.scrollRequestId) {
|
|
143
|
+
cancelAnimationFrame(this.scrollRequestId);
|
|
144
|
+
this.scrollRequestId = null;
|
|
145
|
+
}
|
|
146
|
+
if (this.resizeTimer) {
|
|
147
|
+
clearTimeout(this.resizeTimer);
|
|
148
|
+
this.resizeTimer = null;
|
|
149
|
+
}
|
|
150
|
+
// Reset all event listeners
|
|
151
|
+
this.scrollListener = null;
|
|
152
|
+
this.resizeListener = null;
|
|
153
|
+
this.mouseMoveHandler = null;
|
|
154
|
+
this.mouseUpHandler = null;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
calculateVirtualization() {
|
|
158
|
+
if (!this.tableContainer || !this.tableBody)
|
|
159
|
+
return;
|
|
160
|
+
// Update container height based on available space
|
|
161
|
+
const container = this.tableBody.nativeElement;
|
|
162
|
+
this.containerHeight = container.clientHeight - this.headerHeight;
|
|
163
|
+
this.totalHeight = this.data.length * this.rowHeight;
|
|
164
|
+
// Get scroll position
|
|
165
|
+
const scrollTop = container.scrollTop;
|
|
166
|
+
// Calculate visible rows
|
|
167
|
+
const visibleRowCount = Math.ceil(this.containerHeight / this.rowHeight) + 1;
|
|
168
|
+
// Calculate start and end indices with buffer
|
|
169
|
+
this.visibleStartIndex = Math.max(0, Math.floor(scrollTop / this.rowHeight) - this.bufferSize);
|
|
170
|
+
this.visibleEndIndex = Math.min(this.data.length - 1, this.visibleStartIndex + visibleRowCount + this.bufferSize * 2);
|
|
171
|
+
// Update visible rows
|
|
172
|
+
this.visibleRows = this.data.slice(this.visibleStartIndex, this.visibleEndIndex + 1);
|
|
173
|
+
console.log(scrollTop, this.visibleStartIndex, this.visibleEndIndex);
|
|
174
|
+
// Update vertical offset for virtual scrolling
|
|
175
|
+
this.offsetY = this.visibleStartIndex * this.rowHeight;
|
|
176
|
+
// Trigger change detection in the next tick to avoid ExpressionChangedAfterItHasBeenCheckedError
|
|
177
|
+
Promise.resolve().then(() => {
|
|
178
|
+
this.cdr.detectChanges();
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
// Handle body scroll events
|
|
182
|
+
onBodyScroll(event) {
|
|
183
|
+
if (!event)
|
|
184
|
+
return;
|
|
185
|
+
const now = Date.now();
|
|
186
|
+
if (now - this.lastScrollTime < this.SCROLL_DEBOUNCE)
|
|
187
|
+
return;
|
|
188
|
+
this.lastScrollTime = now;
|
|
189
|
+
const target = event.target;
|
|
190
|
+
// Sync header scroll with body (horizontally)
|
|
191
|
+
// if (this.headerRow?.nativeElement) {
|
|
192
|
+
// this.headerRow.nativeElement.scrollLeft = target.scrollLeft;
|
|
193
|
+
this.syncHorizontalScroll(target.scrollLeft);
|
|
194
|
+
// }
|
|
195
|
+
// Handle virtualization (vertical scrolling)
|
|
196
|
+
if (this.scrollRequestId) {
|
|
197
|
+
cancelAnimationFrame(this.scrollRequestId);
|
|
198
|
+
}
|
|
199
|
+
this.scrollRequestId = requestAnimationFrame(() => {
|
|
200
|
+
this.calculateVirtualization();
|
|
201
|
+
this.scrollRequestId = null;
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
// Handle header scroll events
|
|
205
|
+
onHeaderScroll(event) {
|
|
206
|
+
if (!event)
|
|
207
|
+
return;
|
|
208
|
+
const now = Date.now();
|
|
209
|
+
if (now - this.lastScrollTime < this.SCROLL_DEBOUNCE)
|
|
210
|
+
return;
|
|
211
|
+
this.lastScrollTime = now;
|
|
212
|
+
// Sync body scroll with header (horizontally)
|
|
213
|
+
const scrollLeft = event.target.scrollLeft;
|
|
214
|
+
if (this.tableBody?.nativeElement) {
|
|
215
|
+
this.tableBody.nativeElement.scrollLeft = scrollLeft;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
onResize() {
|
|
219
|
+
// Debounce resize events for better performance
|
|
220
|
+
if (this.resizeTimer) {
|
|
221
|
+
clearTimeout(this.resizeTimer);
|
|
222
|
+
}
|
|
223
|
+
this.resizeTimer = setTimeout(() => {
|
|
224
|
+
this.calculateVirtualization();
|
|
225
|
+
this.resizeTimer = null;
|
|
226
|
+
}, 50);
|
|
227
|
+
}
|
|
228
|
+
syncHorizontalScroll(scrollLeft) {
|
|
229
|
+
if (!this.tableContainer)
|
|
230
|
+
return;
|
|
231
|
+
// Update the transform value
|
|
232
|
+
this.headerTransform = `translateX(-${scrollLeft}px)`;
|
|
233
|
+
// Trigger change detection
|
|
234
|
+
this.cdr.detectChanges();
|
|
235
|
+
}
|
|
236
|
+
// Sorting functionality
|
|
237
|
+
onSort(column) {
|
|
238
|
+
if (!column.sortable)
|
|
239
|
+
return;
|
|
240
|
+
if (this.sortState.field === column.field) {
|
|
241
|
+
// Toggle sort direction
|
|
242
|
+
if (this.sortState.direction === "asc") {
|
|
243
|
+
this.sortState.direction = "desc";
|
|
244
|
+
}
|
|
245
|
+
else if (this.sortState.direction === "desc") {
|
|
246
|
+
this.sortState.direction = null;
|
|
247
|
+
this.sortState.field = "";
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
this.sortState.direction = "asc";
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
this.sortState.field = column.field;
|
|
255
|
+
this.sortState.direction = "asc";
|
|
256
|
+
}
|
|
257
|
+
this.applySorting();
|
|
258
|
+
}
|
|
259
|
+
applySorting() {
|
|
260
|
+
if (!this.sortState.direction || !this.sortState.field) {
|
|
261
|
+
// Reset to original order if no sorting
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
this.data.sort((a, b) => {
|
|
265
|
+
const aValue = a[this.sortState.field];
|
|
266
|
+
const bValue = b[this.sortState.field];
|
|
267
|
+
let comparison = 0;
|
|
268
|
+
if (aValue > bValue)
|
|
269
|
+
comparison = 1;
|
|
270
|
+
if (aValue < bValue)
|
|
271
|
+
comparison = -1;
|
|
272
|
+
return this.sortState.direction === "desc" ? -comparison : comparison;
|
|
273
|
+
});
|
|
274
|
+
this.calculateVirtualization();
|
|
275
|
+
}
|
|
276
|
+
getSortIcon(column) {
|
|
277
|
+
if (!column.sortable || this.sortState.field !== column.field)
|
|
278
|
+
return "";
|
|
279
|
+
if (this.sortState.direction === "asc")
|
|
280
|
+
return "▲";
|
|
281
|
+
if (this.sortState.direction === "desc")
|
|
282
|
+
return "▼";
|
|
283
|
+
return "";
|
|
284
|
+
}
|
|
285
|
+
// Column resizing functionality
|
|
286
|
+
onResizeStart(event, column) {
|
|
287
|
+
event.preventDefault();
|
|
288
|
+
this.isResizing = true;
|
|
289
|
+
this.resizingColumn = column.field;
|
|
290
|
+
this.startX = event.clientX;
|
|
291
|
+
this.startWidth = this.columnWidths[column.field];
|
|
292
|
+
if (this.isBrowser) {
|
|
293
|
+
document.body.style.cursor = "col-resize";
|
|
294
|
+
document.body.style.userSelect = "none";
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
onMouseMove(event) {
|
|
298
|
+
if (!this.isResizing || !this.resizingColumn)
|
|
299
|
+
return;
|
|
300
|
+
this.ngZone.runOutsideAngular(() => {
|
|
301
|
+
const deltaX = event.clientX - this.startX;
|
|
302
|
+
const newWidth = Math.max(50, this.startWidth + deltaX); // Minimum width of 50px
|
|
303
|
+
// Only update if width actually changed
|
|
304
|
+
if (this.columnWidths[this.resizingColumn] !== newWidth) {
|
|
305
|
+
this.columnWidths[this.resizingColumn] = newWidth;
|
|
306
|
+
this.cdr.detectChanges();
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
onMouseUp() {
|
|
311
|
+
if (this.isResizing) {
|
|
312
|
+
this.isResizing = false;
|
|
313
|
+
if (this.isBrowser) {
|
|
314
|
+
document.body.style.cursor = "";
|
|
315
|
+
document.body.style.userSelect = "";
|
|
316
|
+
// Save column widths when resizing is complete
|
|
317
|
+
this.saveColumnWidths();
|
|
318
|
+
}
|
|
319
|
+
this.resizingColumn = "";
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
// Utility methods
|
|
323
|
+
getColumnWidth(column) {
|
|
324
|
+
return `${this.columnWidths[column.field]}px`;
|
|
325
|
+
}
|
|
326
|
+
getCellValue(row, column) {
|
|
327
|
+
const value = row[column.field];
|
|
328
|
+
return column.formatter
|
|
329
|
+
? column.formatter(value, row)
|
|
330
|
+
: value?.toString() || "";
|
|
331
|
+
}
|
|
332
|
+
getLeftFrozenWidth() {
|
|
333
|
+
return this.leftFrozenColumns.reduce((sum, col) => sum + this.columnWidths[col.field], 0);
|
|
334
|
+
}
|
|
335
|
+
getRightFrozenWidth() {
|
|
336
|
+
return this.rightFrozenColumns.reduce((sum, col) => sum + this.columnWidths[col.field], 0);
|
|
337
|
+
}
|
|
338
|
+
// Accessibility methods
|
|
339
|
+
getAriaSort(column) {
|
|
340
|
+
if (this.sortState.field !== column.field || !column.sortable) {
|
|
341
|
+
return null;
|
|
342
|
+
}
|
|
343
|
+
return this.sortState.direction === "asc" ? "ascending" : "descending";
|
|
344
|
+
}
|
|
345
|
+
// Keyboard navigation
|
|
346
|
+
onKeydown(event) {
|
|
347
|
+
if (!this.tableContainer)
|
|
348
|
+
return;
|
|
349
|
+
const { key, ctrlKey, shiftKey } = event;
|
|
350
|
+
const scrollAmount = shiftKey ? 100 : 30; // Larger scroll with shift key
|
|
351
|
+
console.log(key);
|
|
352
|
+
switch (key) {
|
|
353
|
+
case "ArrowLeft":
|
|
354
|
+
this.tableContainer.nativeElement.scrollLeft -= scrollAmount;
|
|
355
|
+
break;
|
|
356
|
+
case "ArrowRight":
|
|
357
|
+
this.tableContainer.nativeElement.scrollLeft += scrollAmount;
|
|
358
|
+
break;
|
|
359
|
+
case "ArrowUp":
|
|
360
|
+
if (ctrlKey) {
|
|
361
|
+
this.tableContainer.nativeElement.scrollTo({
|
|
362
|
+
top: 0,
|
|
363
|
+
behavior: "smooth",
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
else {
|
|
367
|
+
this.tableContainer.nativeElement.scrollTop -= scrollAmount;
|
|
368
|
+
}
|
|
369
|
+
break;
|
|
370
|
+
case "ArrowDown":
|
|
371
|
+
if (ctrlKey) {
|
|
372
|
+
this.tableContainer.nativeElement.scrollTo({
|
|
373
|
+
top: this.tableContainer.nativeElement.scrollHeight,
|
|
374
|
+
behavior: "smooth",
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
else {
|
|
378
|
+
this.tableContainer.nativeElement.scrollTop += scrollAmount;
|
|
379
|
+
}
|
|
380
|
+
break;
|
|
381
|
+
case "1":
|
|
382
|
+
if (ctrlKey) {
|
|
383
|
+
this.tableContainer.nativeElement.scrollTo({
|
|
384
|
+
top: 0,
|
|
385
|
+
left: 0,
|
|
386
|
+
behavior: "smooth",
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
else {
|
|
390
|
+
this.tableContainer.nativeElement.scrollTo({
|
|
391
|
+
left: 0,
|
|
392
|
+
behavior: "smooth",
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
break;
|
|
396
|
+
case "0":
|
|
397
|
+
if (ctrlKey) {
|
|
398
|
+
this.tableContainer.nativeElement.scrollTo({
|
|
399
|
+
top: this.tableContainer.nativeElement.scrollHeight,
|
|
400
|
+
left: this.tableContainer.nativeElement.scrollWidth,
|
|
401
|
+
behavior: "smooth",
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
else {
|
|
405
|
+
this.tableContainer.nativeElement.scrollTo({
|
|
406
|
+
left: this.tableContainer.nativeElement.scrollWidth,
|
|
407
|
+
behavior: "smooth",
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
break;
|
|
411
|
+
default:
|
|
412
|
+
return; // Exit for other keys
|
|
413
|
+
}
|
|
414
|
+
event.preventDefault();
|
|
415
|
+
}
|
|
416
|
+
// Save column widths to localStorage
|
|
417
|
+
saveColumnWidths() {
|
|
418
|
+
if (this.isBrowser) {
|
|
419
|
+
try {
|
|
420
|
+
localStorage.setItem(this.storageKey, JSON.stringify(this.columnWidths));
|
|
421
|
+
}
|
|
422
|
+
catch (e) {
|
|
423
|
+
console.warn("Failed to save column widths to localStorage", e);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
// Load column widths from localStorage
|
|
428
|
+
loadColumnWidths() {
|
|
429
|
+
if (!this.isBrowser)
|
|
430
|
+
return null;
|
|
431
|
+
try {
|
|
432
|
+
const saved = localStorage.getItem(this.storageKey);
|
|
433
|
+
return saved ? JSON.parse(saved) : null;
|
|
434
|
+
}
|
|
435
|
+
catch (e) {
|
|
436
|
+
console.warn("Failed to load column widths from localStorage", e);
|
|
437
|
+
return null;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
// Clear saved column widths
|
|
441
|
+
clearSavedWidths() {
|
|
442
|
+
if (this.isBrowser) {
|
|
443
|
+
try {
|
|
444
|
+
localStorage.removeItem(this.storageKey);
|
|
445
|
+
// Reset to default widths
|
|
446
|
+
this.columns.forEach((col) => {
|
|
447
|
+
this.columnWidths[col.field] = col.width
|
|
448
|
+
? Number.parseInt(col.width.replace("px", ""))
|
|
449
|
+
: 150;
|
|
450
|
+
});
|
|
451
|
+
this.cdr.detectChanges();
|
|
452
|
+
}
|
|
453
|
+
catch (e) {
|
|
454
|
+
console.warn("Failed to clear saved column widths", e);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: NgxSimpleDatatableComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: PLATFORM_ID }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
459
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: NgxSimpleDatatableComponent, isStandalone: true, selector: "ngx-simple-datatable", inputs: { columns: "columns", data: "data", rowHeight: "rowHeight", headerHeight: "headerHeight", bufferSize: "bufferSize" }, queries: [{ propertyName: "headerTemplate", first: true, predicate: ["headerTemplate"], descendants: true, static: true }, { propertyName: "cellTemplate", first: true, predicate: ["cellTemplate"], descendants: true, static: true }], viewQueries: [{ propertyName: "tableContainer", first: true, predicate: ["tableContainer"], descendants: true, static: true }, { propertyName: "tableBody", first: true, predicate: ["tableBody"], descendants: true, static: true }, { propertyName: "headerRow", first: true, predicate: ["headerRow"], descendants: true, static: true }, { propertyName: "headeCenterRow", first: true, predicate: ["headeCenterRow"], descendants: true, static: true }], ngImport: i0, template: "<div class=\"dynamic-table-container\" #tableContainer>\n <!-- Sticky Header -->\n <div class=\"table-header\" [style.height.px]=\"headerHeight\">\n <div class=\"header-row\" #headerRow (scroll)=\"onHeaderScroll($event)\">\n <!-- Left Frozen Columns -->\n <div class=\"frozen-left\" [style.width.px]=\"getLeftFrozenWidth()\" *ngIf=\"leftFrozenColumns.length > 0\"\n role=\"presentation\">\n <div class=\"header-cell\"\n *ngFor=\"let column of leftFrozenColumns; trackBy: trackByColumnField; let colIndex = index\"\n [style.width]=\"getColumnWidth(column)\" [class.sortable]=\"column.sortable\"\n [class.sort-asc]=\"sortState.field === column.field && sortState.direction === 'asc'\"\n [class.sort-desc]=\"sortState.field === column.field && sortState.direction === 'desc'\"\n [attr.role]=\"'columnheader'\" [attr.aria-sort]=\"getAriaSort(column)\" [attr.aria-colindex]=\"colIndex + 1\"\n [attr.aria-label]=\"column.header + (column.sortable ? ' (click to sort)' : '')\" (click)=\"onSort(column)\"\n (keydown.enter)=\"onSort(column)\" (keydown.space)=\"onSort(column); $event.preventDefault()\"\n [tabindex]=\"column.sortable ? '0' : '-1'\" [attr.data-column-id]=\"column.field\">\n <ng-container *ngIf=\"!headerTemplate; else customHeader\">\n <span class=\"header-text\">{{ column.header }}</span>\n </ng-container>\n <ng-template #customHeader>\n <ng-container [ngTemplateOutlet]=\"headerTemplate\" [ngTemplateOutletContext]=\"{ column: column }\">\n </ng-container>\n\n </ng-template>\n <span class=\"sort-icon\" *ngIf=\"column.sortable\">{{ getSortIcon(column) }}</span>\n <div class=\"resize-handle\" (mousedown)=\"onResizeStart($event, column)\"></div>\n </div>\n </div>\n\n <!-- Center Scrollable Columns -->\n <div class=\"center-columns\" #headeCenterRow role=\"presentation\" [ngStyle]=\"{'transform': headerTransform}\">\n <div class=\"header-cell\" *ngFor=\"let column of centerColumns; trackBy: trackByColumnField; let colIndex = index\"\n [style.width]=\"getColumnWidth(column)\" [class.sortable]=\"column.sortable\"\n [class.sort-asc]=\"sortState.field === column.field && sortState.direction === 'asc'\"\n [class.sort-desc]=\"sortState.field === column.field && sortState.direction === 'desc'\"\n [attr.role]=\"'columnheader'\" [attr.aria-sort]=\"getAriaSort(column)\"\n [attr.aria-colindex]=\"leftFrozenColumns.length + colIndex + 1\"\n [attr.aria-label]=\"column.header + (column.sortable ? ' (click to sort)' : '')\" (click)=\"onSort(column)\"\n (keydown.enter)=\"onSort(column)\" (keydown.space)=\"onSort(column); $event.preventDefault()\"\n [tabindex]=\"column.sortable ? '0' : '-1'\" [attr.data-column-id]=\"column.field\">\n <ng-container *ngIf=\"!headerTemplate; else customHeader\">\n <span class=\"header-text\">{{ column.header }}</span>\n </ng-container>\n <ng-template #customHeader>\n <ng-container [ngTemplateOutlet]=\"headerTemplate\"\n [ngTemplateOutletContext]=\"{ column: column }\"></ng-container>\n </ng-template>\n <span class=\"sort-icon\" *ngIf=\"column.sortable\">{{ getSortIcon(column) }}</span>\n <div class=\"resize-handle\" (mousedown)=\"onResizeStart($event, column)\"></div>\n </div>\n </div>\n\n <!-- Right Frozen Columns -->\n <div class=\"frozen-right\" [style.width.px]=\"getRightFrozenWidth()\" *ngIf=\"rightFrozenColumns.length > 0\">\n <div class=\"header-cell\" *ngFor=\"let column of rightFrozenColumns; trackBy: trackByColumnField\"\n [style.width]=\"getColumnWidth(column)\" [class.sortable]=\"column.sortable\" (click)=\"onSort(column)\">\n <ng-container *ngIf=\"!headerTemplate; else customHeader\">\n <span class=\"header-text\">{{ column.header }}</span>\n </ng-container>\n <ng-template #customHeader>\n <ng-container [ngTemplateOutlet]=\"headerTemplate\"\n [ngTemplateOutletContext]=\"{ column: column }\"></ng-container>\n </ng-template>\n <span class=\"sort-icon\" *ngIf=\"column.sortable\">{{ getSortIcon(column) }}</span>\n <div class=\"resize-handle\" (mousedown)=\"onResizeStart($event, column)\"></div>\n </div>\n </div>\n </div>\n </div>\n\n <!-- Table Body with Virtual Scrolling -->\n <div class=\"table-body\" #tableBody [style.height]=\"'calc(100% - ' + headerHeight + 'px)'\"\n (scroll)=\"onBodyScroll($event)\">\n <!-- Virtual spacer for total height -->\n <div class=\"virtual-spacer\" [style.height.px]=\"totalHeight\"></div>\n\n <!-- Visible rows container -->\n <div class=\"visible-rows\" [style.transform]=\"'translateY(' + offsetY + 'px)'\">\n <div class=\"table-row\" *ngFor=\"let row of visibleRows; let i = index; trackBy: trackByRowIndex\"\n [style.height.px]=\"rowHeight\">\n\n <!-- Left Frozen Columns -->\n <div class=\"frozen-left\" [style.width.px]=\"getLeftFrozenWidth()\" *ngIf=\"leftFrozenColumns.length > 0\">\n <div class=\"table-cell\" *ngFor=\"let column of leftFrozenColumns; trackBy: trackByColumnField\"\n [style.width]=\"getColumnWidth(column)\">\n <ng-container *ngIf=\"!cellTemplate; else customCell\">\n {{ getCellValue(row, column) }}\n </ng-container>\n <ng-template #customCell>\n <ng-container [ngTemplateOutlet]=\"cellTemplate\"\n [ngTemplateOutletContext]=\"{ row: row, column: column }\"></ng-container>\n </ng-template>\n </div>\n </div>\n\n <!-- Center Scrollable Columns -->\n <div class=\"center-columns\">\n <div class=\"table-cell\" *ngFor=\"let column of centerColumns; trackBy: trackByColumnField\"\n [style.width]=\"getColumnWidth(column)\">\n <ng-container *ngIf=\"!cellTemplate; else customCell\">\n {{ getCellValue(row, column) }}\n </ng-container>\n <ng-template #customCell>\n <ng-container [ngTemplateOutlet]=\"cellTemplate\"\n [ngTemplateOutletContext]=\"{ row: row, column: column }\"></ng-container>\n </ng-template>\n </div>\n </div>\n\n <!-- Right Frozen Columns -->\n <div class=\"frozen-right\" [style.width.px]=\"getRightFrozenWidth()\" *ngIf=\"rightFrozenColumns.length > 0\">\n <div class=\"table-cell\" *ngFor=\"let column of rightFrozenColumns; trackBy: trackByColumnField\"\n [style.width]=\"getColumnWidth(column)\">\n <ng-container *ngIf=\"!cellTemplate; else customCell\">\n {{ getCellValue(row, column) }}\n </ng-container>\n <ng-template #customCell>\n <ng-container [ngTemplateOutlet]=\"cellTemplate\"\n [ngTemplateOutletContext]=\"{ row: row, column: column }\"></ng-container>\n </ng-template>\n </div>\n </div>\n </div>\n </div>\n </div>\n</div>", styles: [":root{--ngx-simple-dt-bg: #ffffff;--ngx-simple-dt-border: 1px solid #e0e0e0;--ngx-simple-dt-border-radius: 8px;--ngx-simple-dt-box-shadow: 0 2px 8px rgba(0, 0, 0, .1);--ngx-simple-dt-transition: all .2s ease-in-out;--ngx-simple-dt-header-bg: #f8f9fa;--ngx-simple-dt-header-hover-bg: #e9ecef;--ngx-simple-dt-header-border: 1px solid #e0e0e0;--ngx-simple-dt-header-text: #495057;--ngx-simple-dt-header-height: 98px;--ngx-simple-dt-header-font-weight: 600;--ngx-simple-dt-header-padding: 0 16px;--ngx-simple-dt-cell-hover-bg: #f1f3f5;--ngx-simple-dt-cell-active-bg: #e9ecef;--ngx-simple-dt-row-height: 48px;--ngx-simple-dt-cell-padding: 0 16px;--ngx-simple-dt-cell-border: 1px solid #e9ecef;--ngx-simple-dt-cell-font-size: .875rem;--ngx-simple-dt-cell-line-height: 1.5;--ngx-simple-dt-row-bg: #ffffff;--ngx-simple-dt-row-hover-bg: #f8f9fa;--ngx-simple-dt-row-stripe-bg: #f8f9fa;--ngx-simple-dt-row-active-bg: #e9ecef;--ngx-simple-dt-row-border: 1px solid #e9ecef}.dynamic-table-container{width:100%;height:100%;position:relative;display:flex;flex-direction:column;overflow:hidden;background:var(--ngx-simple-dt-bg);border:var(--ngx-simple-dt-border);border-radius:var(--ngx-simple-dt-border-radius);box-shadow:var(--ngx-simple-dt-box-shadow);transition:var(--ngx-simple-dt-transition)}.dynamic-table-container .table-header{position:sticky;top:0;z-index:10;background:var(--ngx-simple-dt-header-bg);border-bottom:var(--ngx-simple-dt-header-border);overflow:hidden;height:var(--ngx-simple-dt-header-height);color:var(--ngx-simple-dt-header-text)}.dynamic-table-container .table-header .header-row{display:flex;min-width:100%;position:relative;height:100%}.dynamic-table-container .table-header .header-row .frozen-left,.dynamic-table-container .table-header .header-row .frozen-right{position:sticky;z-index:12;background:var(--ngx-simple-dt-header-bg);display:flex;box-shadow:2px 0 8px #0000000d;transition:var(--ngx-simple-dt-transition)}.dynamic-table-container .table-header .header-row .frozen-left{left:0;border-right:var(--ngx-simple-dt-header-border)}.dynamic-table-container .table-header .header-row .center-columns{display:flex;flex:1}.dynamic-table-container .table-header .header-row .frozen-right{right:0;border-left:var(--ngx-simple-dt-header-border)}.dynamic-table-container .table-header .header-row .header-cell{display:flex;align-items:center;justify-content:space-between;padding:var(--ngx-simple-dt-cell-padding);border-right:var(--ngx-simple-dt-cell-border);background:inherit;font-weight:var(--ngx-simple-dt-header-font-weight);position:relative;min-width:0;font-size:var(--ngx-simple-dt-cell-font-size);line-height:var(--ngx-simple-dt-cell-line-height);color:inherit;transition:var(--ngx-simple-dt-transition)}.dynamic-table-container .table-header .header-row .header-cell.sortable{cursor:pointer;-webkit-user-select:none;user-select:none;transition:var(--ngx-simple-dt-transition)}.dynamic-table-container .table-header .header-row .header-cell.sortable:hover{background:var(--ngx-simple-dt-header-hover-bg)}.dynamic-table-container .table-header .header-row .header-cell.sortable:active{background:var(--ngx-simple-dt-cell-active-bg)}.dynamic-table-container .table-header .header-row .header-cell .header-text{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dynamic-table-container .table-header .header-row .header-cell .sort-icon{margin-left:8px;font-size:12px;color:#6c757d;transition:var(--ngx-simple-dt-transition)}.dynamic-table-container .table-header .header-row .header-cell .sort-icon.sort-asc,.dynamic-table-container .table-header .header-row .header-cell .sort-icon.sort-desc{color:#0d6efd}.dynamic-table-container .table-header .header-row .header-cell .resize-handle{position:absolute;right:0;top:0;bottom:0;width:4px;cursor:col-resize;background:transparent;transition:var(--ngx-simple-dt-transition)}.dynamic-table-container .table-header .header-row .header-cell .resize-handle:hover,.dynamic-table-container .table-header .header-row .header-cell .resize-handle:active{background:#0d6efd}.dynamic-table-container .table-body{position:relative;flex:1;overflow:auto;scrollbar-width:thin;scrollbar-color:#ced4da #f8f9fa;-webkit-overflow-scrolling:touch}.dynamic-table-container .table-body::-webkit-scrollbar{width:8px;height:8px}.dynamic-table-container .table-body::-webkit-scrollbar-track{background:#f8f9fa;scroll-margin-left:100px}.dynamic-table-container .table-body::-webkit-scrollbar-thumb{background-color:#ced4da;border-radius:4px}.dynamic-table-container .table-body::-webkit-scrollbar-thumb:hover{background-color:#adb5bd}.dynamic-table-container .table-body .virtual-spacer{position:absolute;top:0;left:0;width:1px;pointer-events:none}.dynamic-table-container .table-body .visible-rows{position:absolute;top:0;left:0;right:0;min-width:fit-content}.dynamic-table-container .table-body .visible-rows .table-row{display:flex;min-width:100%;border-bottom:var(--ngx-simple-dt-row-border);background:var(--ngx-simple-dt-row-bg);transition:var(--ngx-simple-dt-transition)}.dynamic-table-container .table-body .visible-rows .table-row:nth-child(2n){background:var(--ngx-simple-dt-row-stripe-bg)}.dynamic-table-container .table-body .visible-rows .table-row:hover{background:var(--ngx-simple-dt-row-hover-bg)}.dynamic-table-container .table-body .visible-rows .table-row:active{background:var(--ngx-simple-dt-row-active-bg)}.dynamic-table-container .table-body .visible-rows .table-row .frozen-left{position:sticky;left:0;z-index:5;background:#fff;border-right:2px solid #ccc;display:flex}.table-row:hover .dynamic-table-container .table-body .visible-rows .table-row .frozen-left{background:#f9f9f9}.dynamic-table-container .table-body .visible-rows .table-row .center-columns{display:flex;flex:0 0 auto}.dynamic-table-container .table-body .visible-rows .table-row .frozen-right{position:sticky;right:0;z-index:5;background:#fff;border-left:2px solid #ccc;display:flex}.table-row:hover .dynamic-table-container .table-body .visible-rows .table-row .frozen-right{background:#f9f9f9}.dynamic-table-container .table-body .visible-rows .table-row .table-cell{padding:var(--ngx-simple-dt-cell-padding);border-right:var(--ngx-simple-dt-cell-border);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:var(--ngx-simple-dt-cell-font-size);line-height:var(--ngx-simple-dt-cell-line-height);display:flex;align-items:center;transition:var(--ngx-simple-dt-transition);min-width:0}.dynamic-table-container .frozen-left .table-cell,.dynamic-table-container .frozen-right .table-cell{background:inherit;box-shadow:2px 0 8px #0000000d}@media (max-width: 768px){.dynamic-table-container{font-size:14px}.dynamic-table-container .header-cell,.dynamic-table-container .table-cell{padding:0 8px}}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
460
|
+
}
|
|
461
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: NgxSimpleDatatableComponent, decorators: [{
|
|
462
|
+
type: Component,
|
|
463
|
+
args: [{ selector: "ngx-simple-datatable", standalone: true, imports: [CommonModule], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"dynamic-table-container\" #tableContainer>\n <!-- Sticky Header -->\n <div class=\"table-header\" [style.height.px]=\"headerHeight\">\n <div class=\"header-row\" #headerRow (scroll)=\"onHeaderScroll($event)\">\n <!-- Left Frozen Columns -->\n <div class=\"frozen-left\" [style.width.px]=\"getLeftFrozenWidth()\" *ngIf=\"leftFrozenColumns.length > 0\"\n role=\"presentation\">\n <div class=\"header-cell\"\n *ngFor=\"let column of leftFrozenColumns; trackBy: trackByColumnField; let colIndex = index\"\n [style.width]=\"getColumnWidth(column)\" [class.sortable]=\"column.sortable\"\n [class.sort-asc]=\"sortState.field === column.field && sortState.direction === 'asc'\"\n [class.sort-desc]=\"sortState.field === column.field && sortState.direction === 'desc'\"\n [attr.role]=\"'columnheader'\" [attr.aria-sort]=\"getAriaSort(column)\" [attr.aria-colindex]=\"colIndex + 1\"\n [attr.aria-label]=\"column.header + (column.sortable ? ' (click to sort)' : '')\" (click)=\"onSort(column)\"\n (keydown.enter)=\"onSort(column)\" (keydown.space)=\"onSort(column); $event.preventDefault()\"\n [tabindex]=\"column.sortable ? '0' : '-1'\" [attr.data-column-id]=\"column.field\">\n <ng-container *ngIf=\"!headerTemplate; else customHeader\">\n <span class=\"header-text\">{{ column.header }}</span>\n </ng-container>\n <ng-template #customHeader>\n <ng-container [ngTemplateOutlet]=\"headerTemplate\" [ngTemplateOutletContext]=\"{ column: column }\">\n </ng-container>\n\n </ng-template>\n <span class=\"sort-icon\" *ngIf=\"column.sortable\">{{ getSortIcon(column) }}</span>\n <div class=\"resize-handle\" (mousedown)=\"onResizeStart($event, column)\"></div>\n </div>\n </div>\n\n <!-- Center Scrollable Columns -->\n <div class=\"center-columns\" #headeCenterRow role=\"presentation\" [ngStyle]=\"{'transform': headerTransform}\">\n <div class=\"header-cell\" *ngFor=\"let column of centerColumns; trackBy: trackByColumnField; let colIndex = index\"\n [style.width]=\"getColumnWidth(column)\" [class.sortable]=\"column.sortable\"\n [class.sort-asc]=\"sortState.field === column.field && sortState.direction === 'asc'\"\n [class.sort-desc]=\"sortState.field === column.field && sortState.direction === 'desc'\"\n [attr.role]=\"'columnheader'\" [attr.aria-sort]=\"getAriaSort(column)\"\n [attr.aria-colindex]=\"leftFrozenColumns.length + colIndex + 1\"\n [attr.aria-label]=\"column.header + (column.sortable ? ' (click to sort)' : '')\" (click)=\"onSort(column)\"\n (keydown.enter)=\"onSort(column)\" (keydown.space)=\"onSort(column); $event.preventDefault()\"\n [tabindex]=\"column.sortable ? '0' : '-1'\" [attr.data-column-id]=\"column.field\">\n <ng-container *ngIf=\"!headerTemplate; else customHeader\">\n <span class=\"header-text\">{{ column.header }}</span>\n </ng-container>\n <ng-template #customHeader>\n <ng-container [ngTemplateOutlet]=\"headerTemplate\"\n [ngTemplateOutletContext]=\"{ column: column }\"></ng-container>\n </ng-template>\n <span class=\"sort-icon\" *ngIf=\"column.sortable\">{{ getSortIcon(column) }}</span>\n <div class=\"resize-handle\" (mousedown)=\"onResizeStart($event, column)\"></div>\n </div>\n </div>\n\n <!-- Right Frozen Columns -->\n <div class=\"frozen-right\" [style.width.px]=\"getRightFrozenWidth()\" *ngIf=\"rightFrozenColumns.length > 0\">\n <div class=\"header-cell\" *ngFor=\"let column of rightFrozenColumns; trackBy: trackByColumnField\"\n [style.width]=\"getColumnWidth(column)\" [class.sortable]=\"column.sortable\" (click)=\"onSort(column)\">\n <ng-container *ngIf=\"!headerTemplate; else customHeader\">\n <span class=\"header-text\">{{ column.header }}</span>\n </ng-container>\n <ng-template #customHeader>\n <ng-container [ngTemplateOutlet]=\"headerTemplate\"\n [ngTemplateOutletContext]=\"{ column: column }\"></ng-container>\n </ng-template>\n <span class=\"sort-icon\" *ngIf=\"column.sortable\">{{ getSortIcon(column) }}</span>\n <div class=\"resize-handle\" (mousedown)=\"onResizeStart($event, column)\"></div>\n </div>\n </div>\n </div>\n </div>\n\n <!-- Table Body with Virtual Scrolling -->\n <div class=\"table-body\" #tableBody [style.height]=\"'calc(100% - ' + headerHeight + 'px)'\"\n (scroll)=\"onBodyScroll($event)\">\n <!-- Virtual spacer for total height -->\n <div class=\"virtual-spacer\" [style.height.px]=\"totalHeight\"></div>\n\n <!-- Visible rows container -->\n <div class=\"visible-rows\" [style.transform]=\"'translateY(' + offsetY + 'px)'\">\n <div class=\"table-row\" *ngFor=\"let row of visibleRows; let i = index; trackBy: trackByRowIndex\"\n [style.height.px]=\"rowHeight\">\n\n <!-- Left Frozen Columns -->\n <div class=\"frozen-left\" [style.width.px]=\"getLeftFrozenWidth()\" *ngIf=\"leftFrozenColumns.length > 0\">\n <div class=\"table-cell\" *ngFor=\"let column of leftFrozenColumns; trackBy: trackByColumnField\"\n [style.width]=\"getColumnWidth(column)\">\n <ng-container *ngIf=\"!cellTemplate; else customCell\">\n {{ getCellValue(row, column) }}\n </ng-container>\n <ng-template #customCell>\n <ng-container [ngTemplateOutlet]=\"cellTemplate\"\n [ngTemplateOutletContext]=\"{ row: row, column: column }\"></ng-container>\n </ng-template>\n </div>\n </div>\n\n <!-- Center Scrollable Columns -->\n <div class=\"center-columns\">\n <div class=\"table-cell\" *ngFor=\"let column of centerColumns; trackBy: trackByColumnField\"\n [style.width]=\"getColumnWidth(column)\">\n <ng-container *ngIf=\"!cellTemplate; else customCell\">\n {{ getCellValue(row, column) }}\n </ng-container>\n <ng-template #customCell>\n <ng-container [ngTemplateOutlet]=\"cellTemplate\"\n [ngTemplateOutletContext]=\"{ row: row, column: column }\"></ng-container>\n </ng-template>\n </div>\n </div>\n\n <!-- Right Frozen Columns -->\n <div class=\"frozen-right\" [style.width.px]=\"getRightFrozenWidth()\" *ngIf=\"rightFrozenColumns.length > 0\">\n <div class=\"table-cell\" *ngFor=\"let column of rightFrozenColumns; trackBy: trackByColumnField\"\n [style.width]=\"getColumnWidth(column)\">\n <ng-container *ngIf=\"!cellTemplate; else customCell\">\n {{ getCellValue(row, column) }}\n </ng-container>\n <ng-template #customCell>\n <ng-container [ngTemplateOutlet]=\"cellTemplate\"\n [ngTemplateOutletContext]=\"{ row: row, column: column }\"></ng-container>\n </ng-template>\n </div>\n </div>\n </div>\n </div>\n </div>\n</div>", styles: [":root{--ngx-simple-dt-bg: #ffffff;--ngx-simple-dt-border: 1px solid #e0e0e0;--ngx-simple-dt-border-radius: 8px;--ngx-simple-dt-box-shadow: 0 2px 8px rgba(0, 0, 0, .1);--ngx-simple-dt-transition: all .2s ease-in-out;--ngx-simple-dt-header-bg: #f8f9fa;--ngx-simple-dt-header-hover-bg: #e9ecef;--ngx-simple-dt-header-border: 1px solid #e0e0e0;--ngx-simple-dt-header-text: #495057;--ngx-simple-dt-header-height: 98px;--ngx-simple-dt-header-font-weight: 600;--ngx-simple-dt-header-padding: 0 16px;--ngx-simple-dt-cell-hover-bg: #f1f3f5;--ngx-simple-dt-cell-active-bg: #e9ecef;--ngx-simple-dt-row-height: 48px;--ngx-simple-dt-cell-padding: 0 16px;--ngx-simple-dt-cell-border: 1px solid #e9ecef;--ngx-simple-dt-cell-font-size: .875rem;--ngx-simple-dt-cell-line-height: 1.5;--ngx-simple-dt-row-bg: #ffffff;--ngx-simple-dt-row-hover-bg: #f8f9fa;--ngx-simple-dt-row-stripe-bg: #f8f9fa;--ngx-simple-dt-row-active-bg: #e9ecef;--ngx-simple-dt-row-border: 1px solid #e9ecef}.dynamic-table-container{width:100%;height:100%;position:relative;display:flex;flex-direction:column;overflow:hidden;background:var(--ngx-simple-dt-bg);border:var(--ngx-simple-dt-border);border-radius:var(--ngx-simple-dt-border-radius);box-shadow:var(--ngx-simple-dt-box-shadow);transition:var(--ngx-simple-dt-transition)}.dynamic-table-container .table-header{position:sticky;top:0;z-index:10;background:var(--ngx-simple-dt-header-bg);border-bottom:var(--ngx-simple-dt-header-border);overflow:hidden;height:var(--ngx-simple-dt-header-height);color:var(--ngx-simple-dt-header-text)}.dynamic-table-container .table-header .header-row{display:flex;min-width:100%;position:relative;height:100%}.dynamic-table-container .table-header .header-row .frozen-left,.dynamic-table-container .table-header .header-row .frozen-right{position:sticky;z-index:12;background:var(--ngx-simple-dt-header-bg);display:flex;box-shadow:2px 0 8px #0000000d;transition:var(--ngx-simple-dt-transition)}.dynamic-table-container .table-header .header-row .frozen-left{left:0;border-right:var(--ngx-simple-dt-header-border)}.dynamic-table-container .table-header .header-row .center-columns{display:flex;flex:1}.dynamic-table-container .table-header .header-row .frozen-right{right:0;border-left:var(--ngx-simple-dt-header-border)}.dynamic-table-container .table-header .header-row .header-cell{display:flex;align-items:center;justify-content:space-between;padding:var(--ngx-simple-dt-cell-padding);border-right:var(--ngx-simple-dt-cell-border);background:inherit;font-weight:var(--ngx-simple-dt-header-font-weight);position:relative;min-width:0;font-size:var(--ngx-simple-dt-cell-font-size);line-height:var(--ngx-simple-dt-cell-line-height);color:inherit;transition:var(--ngx-simple-dt-transition)}.dynamic-table-container .table-header .header-row .header-cell.sortable{cursor:pointer;-webkit-user-select:none;user-select:none;transition:var(--ngx-simple-dt-transition)}.dynamic-table-container .table-header .header-row .header-cell.sortable:hover{background:var(--ngx-simple-dt-header-hover-bg)}.dynamic-table-container .table-header .header-row .header-cell.sortable:active{background:var(--ngx-simple-dt-cell-active-bg)}.dynamic-table-container .table-header .header-row .header-cell .header-text{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dynamic-table-container .table-header .header-row .header-cell .sort-icon{margin-left:8px;font-size:12px;color:#6c757d;transition:var(--ngx-simple-dt-transition)}.dynamic-table-container .table-header .header-row .header-cell .sort-icon.sort-asc,.dynamic-table-container .table-header .header-row .header-cell .sort-icon.sort-desc{color:#0d6efd}.dynamic-table-container .table-header .header-row .header-cell .resize-handle{position:absolute;right:0;top:0;bottom:0;width:4px;cursor:col-resize;background:transparent;transition:var(--ngx-simple-dt-transition)}.dynamic-table-container .table-header .header-row .header-cell .resize-handle:hover,.dynamic-table-container .table-header .header-row .header-cell .resize-handle:active{background:#0d6efd}.dynamic-table-container .table-body{position:relative;flex:1;overflow:auto;scrollbar-width:thin;scrollbar-color:#ced4da #f8f9fa;-webkit-overflow-scrolling:touch}.dynamic-table-container .table-body::-webkit-scrollbar{width:8px;height:8px}.dynamic-table-container .table-body::-webkit-scrollbar-track{background:#f8f9fa;scroll-margin-left:100px}.dynamic-table-container .table-body::-webkit-scrollbar-thumb{background-color:#ced4da;border-radius:4px}.dynamic-table-container .table-body::-webkit-scrollbar-thumb:hover{background-color:#adb5bd}.dynamic-table-container .table-body .virtual-spacer{position:absolute;top:0;left:0;width:1px;pointer-events:none}.dynamic-table-container .table-body .visible-rows{position:absolute;top:0;left:0;right:0;min-width:fit-content}.dynamic-table-container .table-body .visible-rows .table-row{display:flex;min-width:100%;border-bottom:var(--ngx-simple-dt-row-border);background:var(--ngx-simple-dt-row-bg);transition:var(--ngx-simple-dt-transition)}.dynamic-table-container .table-body .visible-rows .table-row:nth-child(2n){background:var(--ngx-simple-dt-row-stripe-bg)}.dynamic-table-container .table-body .visible-rows .table-row:hover{background:var(--ngx-simple-dt-row-hover-bg)}.dynamic-table-container .table-body .visible-rows .table-row:active{background:var(--ngx-simple-dt-row-active-bg)}.dynamic-table-container .table-body .visible-rows .table-row .frozen-left{position:sticky;left:0;z-index:5;background:#fff;border-right:2px solid #ccc;display:flex}.table-row:hover .dynamic-table-container .table-body .visible-rows .table-row .frozen-left{background:#f9f9f9}.dynamic-table-container .table-body .visible-rows .table-row .center-columns{display:flex;flex:0 0 auto}.dynamic-table-container .table-body .visible-rows .table-row .frozen-right{position:sticky;right:0;z-index:5;background:#fff;border-left:2px solid #ccc;display:flex}.table-row:hover .dynamic-table-container .table-body .visible-rows .table-row .frozen-right{background:#f9f9f9}.dynamic-table-container .table-body .visible-rows .table-row .table-cell{padding:var(--ngx-simple-dt-cell-padding);border-right:var(--ngx-simple-dt-cell-border);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:var(--ngx-simple-dt-cell-font-size);line-height:var(--ngx-simple-dt-cell-line-height);display:flex;align-items:center;transition:var(--ngx-simple-dt-transition);min-width:0}.dynamic-table-container .frozen-left .table-cell,.dynamic-table-container .frozen-right .table-cell{background:inherit;box-shadow:2px 0 8px #0000000d}@media (max-width: 768px){.dynamic-table-container{font-size:14px}.dynamic-table-container .header-cell,.dynamic-table-container .table-cell{padding:0 8px}}\n"] }]
|
|
464
|
+
}], ctorParameters: () => [{ type: i0.ChangeDetectorRef }, { type: Object, decorators: [{
|
|
465
|
+
type: Inject,
|
|
466
|
+
args: [PLATFORM_ID]
|
|
467
|
+
}] }, { type: i0.NgZone }], propDecorators: { columns: [{
|
|
468
|
+
type: Input
|
|
469
|
+
}], data: [{
|
|
470
|
+
type: Input
|
|
471
|
+
}], rowHeight: [{
|
|
472
|
+
type: Input
|
|
473
|
+
}], headerHeight: [{
|
|
474
|
+
type: Input
|
|
475
|
+
}], bufferSize: [{
|
|
476
|
+
type: Input
|
|
477
|
+
}], tableContainer: [{
|
|
478
|
+
type: ViewChild,
|
|
479
|
+
args: ["tableContainer", { static: true }]
|
|
480
|
+
}], tableBody: [{
|
|
481
|
+
type: ViewChild,
|
|
482
|
+
args: ["tableBody", { static: true }]
|
|
483
|
+
}], headerRow: [{
|
|
484
|
+
type: ViewChild,
|
|
485
|
+
args: ["headerRow", { static: true }]
|
|
486
|
+
}], headeCenterRow: [{
|
|
487
|
+
type: ViewChild,
|
|
488
|
+
args: ["headeCenterRow", { static: true }]
|
|
489
|
+
}], headerTemplate: [{
|
|
490
|
+
type: ContentChild,
|
|
491
|
+
args: ["headerTemplate", { static: true }]
|
|
492
|
+
}], cellTemplate: [{
|
|
493
|
+
type: ContentChild,
|
|
494
|
+
args: ["cellTemplate", { static: true }]
|
|
495
|
+
}] } });
|
|
496
|
+
|
|
497
|
+
/*
|
|
498
|
+
* Public API Surface of ngx-simple-datatable
|
|
499
|
+
*/
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* Generated bundle index. Do not edit.
|
|
503
|
+
*/
|
|
504
|
+
|
|
505
|
+
export { NgxSimpleDatatableComponent, NgxSimpleDatatableService };
|
|
506
|
+
//# sourceMappingURL=ngx-simple-datatables.mjs.map
|