tangrid 0.1.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.
Files changed (38) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +124 -0
  3. package/config/index.d.ts +5 -0
  4. package/config/ngs-config.d.ts +16 -0
  5. package/config/public-api.d.ts +1 -0
  6. package/esm2022/config/ngs-config.mjs +24 -0
  7. package/esm2022/config/public-api.mjs +2 -0
  8. package/esm2022/config/tangrid-config.mjs +5 -0
  9. package/esm2022/index.mjs +17 -0
  10. package/esm2022/table/public-api.mjs +4 -0
  11. package/esm2022/table/table.component.mjs +1433 -0
  12. package/esm2022/table/table.module.mjs +19 -0
  13. package/esm2022/table/table.types.mjs +2 -0
  14. package/esm2022/table/tangrid-table.mjs +5 -0
  15. package/esm2022/table/virtual-provider.mjs +165 -0
  16. package/esm2022/tangrid.mjs +5 -0
  17. package/esm2022/theme/ngs-theme.service.mjs +83 -0
  18. package/esm2022/theme/public-api.mjs +2 -0
  19. package/esm2022/theme/tangrid-theme.mjs +5 -0
  20. package/fesm2022/tangrid-config.mjs +31 -0
  21. package/fesm2022/tangrid-config.mjs.map +1 -0
  22. package/fesm2022/tangrid-table.mjs +1618 -0
  23. package/fesm2022/tangrid-table.mjs.map +1 -0
  24. package/fesm2022/tangrid-theme.mjs +90 -0
  25. package/fesm2022/tangrid-theme.mjs.map +1 -0
  26. package/fesm2022/tangrid.mjs +1732 -0
  27. package/fesm2022/tangrid.mjs.map +1 -0
  28. package/index.d.ts +10 -0
  29. package/package.json +78 -0
  30. package/table/index.d.ts +5 -0
  31. package/table/public-api.d.ts +3 -0
  32. package/table/table.component.d.ts +542 -0
  33. package/table/table.module.d.ts +10 -0
  34. package/table/table.types.d.ts +202 -0
  35. package/table/virtual-provider.d.ts +9 -0
  36. package/theme/index.d.ts +5 -0
  37. package/theme/ngs-theme.service.d.ts +34 -0
  38. package/theme/public-api.d.ts +1 -0
@@ -0,0 +1,542 @@
1
+ import { ChangeDetectorRef, EventEmitter, NgZone, OnChanges, OnInit, SimpleChanges, TemplateRef, AfterViewInit, ElementRef, OnDestroy } from '@angular/core';
2
+ import { type Row, type RowSelectionState } from '@tanstack/angular-table';
3
+ import type { Table, ColumnDef } from '@tanstack/table-core';
4
+ import { TanGridColumn, TanGridSort, TanGridPagination, TanGridFilter, TanGridSelectionMode, TanGridCellEdit, TanGridExportFormat, TanGridExportOptions, TanGridTheme } from './table.types';
5
+ import * as i0 from "@angular/core";
6
+ /**
7
+ * Data table component with sorting, filtering, pagination, and selection.
8
+ * Wraps TanStack Table for Angular.
9
+ */
10
+ export declare class TanGrid<T = any> implements OnInit, OnChanges, AfterViewInit, OnDestroy {
11
+ private ngZone;
12
+ private cdr;
13
+ /**
14
+ * Table data array
15
+ */
16
+ data: T[];
17
+ /**
18
+ * Column definitions
19
+ */
20
+ columns: TanGridColumn<T>[];
21
+ /**
22
+ * Whether table is in loading state
23
+ * @default false
24
+ */
25
+ loading: boolean;
26
+ /**
27
+ * Whether table is striped
28
+ * @default false
29
+ */
30
+ striped: boolean;
31
+ /**
32
+ * Whether table has borders
33
+ * @default true
34
+ */
35
+ bordered: boolean;
36
+ /**
37
+ * Whether table is hoverable
38
+ * @default true
39
+ */
40
+ hoverable: boolean;
41
+ /**
42
+ * Whether table is compact
43
+ * @default true
44
+ */
45
+ compact: boolean;
46
+ /**
47
+ * Table theme
48
+ * @default 'default'
49
+ */
50
+ theme: TanGridTheme;
51
+ /**
52
+ * Selection mode
53
+ * @default 'none'
54
+ */
55
+ selectionMode: TanGridSelectionMode;
56
+ /**
57
+ * Selected row IDs
58
+ */
59
+ selectedRowIds: string[];
60
+ /**
61
+ * Row ID accessor function
62
+ */
63
+ rowIdFn: (row: T, index: number) => string;
64
+ /**
65
+ * Pagination enabled
66
+ * @default true
67
+ */
68
+ pagination: boolean;
69
+ /**
70
+ * Initial page size
71
+ * @default 10
72
+ */
73
+ pageSize: number;
74
+ /**
75
+ * Page size options
76
+ * @default [10, 20, 50, 100]
77
+ */
78
+ pageSizeOptions: number[];
79
+ /**
80
+ * Pagination mode: 'client' | 'server'
81
+ * - 'client': Pagination is handled by TanStack Table (default)
82
+ * - 'server': Pagination is handled by the server, emits paginationChange event
83
+ * @default 'client'
84
+ */
85
+ paginationMode: 'client' | 'server';
86
+ /**
87
+ * Total items (required for server-side pagination)
88
+ * @default 0
89
+ */
90
+ totalItems: number;
91
+ /**
92
+ * Sorting enabled
93
+ * @default true
94
+ */
95
+ sorting: boolean;
96
+ /**
97
+ * Sorting mode: 'client' | 'server'
98
+ * - 'client': Sorting is handled by TanStack Table (default)
99
+ * - 'server': Sorting is handled by the server, emits sortChange event
100
+ * @default 'client'
101
+ */
102
+ sortingMode: 'client' | 'server';
103
+ /**
104
+ * Filtering enabled
105
+ * @default true
106
+ */
107
+ filtering: boolean;
108
+ /**
109
+ * Filtering mode: 'client' | 'server'
110
+ * - 'client': Filtering is handled by TanStack Table (default)
111
+ * - 'server': Filtering is handled by the server, emits filterChange event
112
+ * @default 'client'
113
+ */
114
+ filteringMode: 'client' | 'server';
115
+ /**
116
+ * Global search enabled
117
+ * @default false
118
+ */
119
+ globalSearch: boolean;
120
+ /**
121
+ * Show global search input
122
+ * @default true
123
+ */
124
+ showGlobalSearchInput: boolean;
125
+ /**
126
+ * Global filter value
127
+ */
128
+ globalFilter: string;
129
+ /**
130
+ * Empty state message
131
+ * @default 'No data available'
132
+ */
133
+ emptyMessage: string;
134
+ /**
135
+ * Loading message
136
+ * @default 'Loading...'
137
+ */
138
+ loadingMessage: string;
139
+ /**
140
+ * Loading type: 'spinner' | 'placeholder' | 'template'
141
+ * @default 'spinner'
142
+ */
143
+ loadingType: 'spinner' | 'placeholder' | 'template';
144
+ /**
145
+ * Number of placeholder rows to show when loadingType is 'placeholder'
146
+ * @default 5
147
+ */
148
+ placeholderRows: number;
149
+ /**
150
+ * Enable virtual scrolling for large datasets
151
+ * Requires @angular/cdk to be installed
152
+ * @default false
153
+ */
154
+ virtualScroll: boolean;
155
+ /**
156
+ * Height of each row in pixels when virtual scrolling is enabled
157
+ * @default 48
158
+ */
159
+ rowHeight: number;
160
+ /**
161
+ * Number of buffer rows to render outside the viewport
162
+ * Higher values provide smoother scrolling but use more memory
163
+ * @default 3
164
+ */
165
+ virtualScrollBufferSize: number;
166
+ /**
167
+ * Maximum height of the virtual scroll viewport
168
+ * If not set, viewport will use available space
169
+ */
170
+ virtualScrollViewportHeight?: number;
171
+ /**
172
+ * Column IDs to pin to the left side
173
+ * These columns will remain visible when scrolling horizontally
174
+ */
175
+ pinnedLeft: string[];
176
+ /**
177
+ * Column IDs to pin to the right side
178
+ * These columns will remain visible when scrolling horizontally
179
+ */
180
+ pinnedRight: string[];
181
+ /**
182
+ * Whether to show column pinning UI (icons in headers)
183
+ * @default false
184
+ */
185
+ enablePinning: boolean;
186
+ /**
187
+ * Enable column reordering via drag-and-drop on headers
188
+ * @default false
189
+ */
190
+ reorderable: boolean;
191
+ /**
192
+ * Custom empty state template
193
+ */
194
+ emptyTemplate?: TemplateRef<any>;
195
+ /**
196
+ * Custom loading template (used when loadingType is 'template')
197
+ */
198
+ loadingTemplate?: TemplateRef<any>;
199
+ /**
200
+ * Whether rows can be expanded
201
+ * @default false
202
+ */
203
+ expandable: boolean;
204
+ /**
205
+ * Template for expanded row content
206
+ * Receives the row data as context: { $implicit: T; row: T }
207
+ */
208
+ expandedRowTemplate?: TemplateRef<{
209
+ $implicit: T;
210
+ row: T;
211
+ }>;
212
+ /**
213
+ * Pre-expanded row IDs
214
+ */
215
+ expandedRowIds: string[];
216
+ /**
217
+ * Whether inline editing is enabled
218
+ * @default false
219
+ */
220
+ editable: boolean;
221
+ /**
222
+ * Whether export functionality is enabled
223
+ * @default false
224
+ */
225
+ exportable: boolean;
226
+ /**
227
+ * Available export formats
228
+ * @default ['csv']
229
+ */
230
+ exportFormats: TanGridExportFormat[];
231
+ /**
232
+ * Event emitted when row is clicked
233
+ */
234
+ rowClick: EventEmitter<{
235
+ row: T;
236
+ index: number;
237
+ }>;
238
+ rowDblClick: EventEmitter<{
239
+ row: T;
240
+ index: number;
241
+ }>;
242
+ /**
243
+ * Event emitted when selection changes
244
+ */
245
+ selectionChange: EventEmitter<T[]>;
246
+ /**
247
+ * Event emitted when sorting changes
248
+ */
249
+ sortChange: EventEmitter<TanGridSort>;
250
+ /**
251
+ * Event emitted when pagination changes
252
+ */
253
+ paginationChange: EventEmitter<TanGridPagination>;
254
+ /**
255
+ * Event emitted when filter changes
256
+ */
257
+ filterChange: EventEmitter<TanGridFilter[]>;
258
+ /**
259
+ * Event emitted when row expansion changes
260
+ */
261
+ expansionChange: EventEmitter<{
262
+ rowId: string;
263
+ expanded: boolean;
264
+ }>;
265
+ /**
266
+ * Event emitted when column pinning changes
267
+ */
268
+ pinChange: EventEmitter<{
269
+ columnId: string;
270
+ position: 'left' | 'right' | 'none';
271
+ }>;
272
+ /**
273
+ * Event emitted when a cell is edited
274
+ */
275
+ cellEditChange: EventEmitter<TanGridCellEdit<T>>;
276
+ /**
277
+ * Event emitted when column order changes
278
+ */
279
+ columnOrderChange: EventEmitter<string[]>;
280
+ protected dataSignal: import("@angular/core").WritableSignal<T[]>;
281
+ protected columnsSignal: import("@angular/core").WritableSignal<ColumnDef<T, any>[]>;
282
+ protected globalFilterSignal: import("@angular/core").WritableSignal<string>;
283
+ protected sortingSignal: import("@angular/core").WritableSignal<any[]>;
284
+ protected rowSelectionSignal: import("@angular/core").WritableSignal<RowSelectionState>;
285
+ protected columnSizingSignal: import("@angular/core").WritableSignal<Record<string, number>>;
286
+ protected rowExpansionSignal: import("@angular/core").WritableSignal<Record<string, boolean>>;
287
+ protected editingCellSignal: import("@angular/core").WritableSignal<{
288
+ rowId: string;
289
+ columnId: string;
290
+ } | null>;
291
+ protected editingValueSignal: import("@angular/core").WritableSignal<any>;
292
+ protected columnOrderSignal: import("@angular/core").WritableSignal<string[]>;
293
+ protected hasHorizontalScroll: import("@angular/core").WritableSignal<boolean>;
294
+ protected table: Table<T>;
295
+ protected pageIndex: import("@angular/core").WritableSignal<number>;
296
+ protected pageSizeSignal: import("@angular/core").WritableSignal<number>;
297
+ private resizeAnimationFrame;
298
+ private resizeObserver;
299
+ tableContainer: ElementRef<HTMLElement>;
300
+ protected scrollElementSignal: import("@angular/core").WritableSignal<HTMLElement | null>;
301
+ set virtualScrollViewport(el: ElementRef<HTMLElement>);
302
+ private _headerRowContainer;
303
+ private _sortable;
304
+ set headerRowContainer(el: ElementRef<HTMLElement>);
305
+ get headerRowContainer(): ElementRef<HTMLElement>;
306
+ /**
307
+ * Virtualizer for row rendering
308
+ */
309
+ readonly virtualizer: import("@tanstack/angular-virtual").AngularVirtualizer<HTMLElement, Element>;
310
+ constructor(ngZone: NgZone, cdr: ChangeDetectorRef);
311
+ ngOnInit(): void;
312
+ ngOnChanges(changes: SimpleChanges): void;
313
+ /**
314
+ * Get selected rows
315
+ */
316
+ getSelectedRows(): T[];
317
+ /**
318
+ * Clear selection
319
+ */
320
+ clearSelection(): void;
321
+ /**
322
+ * Select all rows
323
+ */
324
+ selectAll(): void;
325
+ /**
326
+ * Toggle row selection
327
+ */
328
+ toggleRowSelection(rowId: string): void;
329
+ /**
330
+ * Check if row is selected
331
+ */
332
+ isRowSelected(rowId: string): boolean;
333
+ /**
334
+ * Handle global search
335
+ */
336
+ onGlobalSearch(value: string): void;
337
+ /**
338
+ * Handle column filter change
339
+ */
340
+ onColumnFilterChange(column: any, value: any): void;
341
+ /**
342
+ * Get filter placeholder text
343
+ */
344
+ getFilterPlaceholder(column: any): string;
345
+ /**
346
+ * Handle resize start
347
+ */
348
+ onResizeStart(event: MouseEvent, header: any): void;
349
+ /**
350
+ * Track by function for virtual scrolling
351
+ */
352
+ trackByRowId(index: number, row: Row<T>): string;
353
+ /**
354
+ * Get row index for virtual scrolling
355
+ */
356
+ getRowIndex(row: Row<T>): number;
357
+ /**
358
+ * Check if a column is pinned to the left
359
+ */
360
+ isPinnedLeft(columnId: string): boolean;
361
+ /**
362
+ * Check if a column is pinned to the right
363
+ */
364
+ isPinnedRight(columnId: string): boolean;
365
+ /**
366
+ * Check if a column is in the left half of the visible columns
367
+ */
368
+ isColumnOnLeft(columnId: string): boolean;
369
+ /**
370
+ * Get the left offset for a pinned column
371
+ */
372
+ getPinnedLeftOffset(columnId: string): number;
373
+ /**
374
+ * Get the right offset for a pinned column
375
+ */
376
+ getPinnedRightOffset(columnId: string): number;
377
+ /**
378
+ * Check if a row is expanded
379
+ */
380
+ isRowExpanded(rowId: string): boolean;
381
+ /**
382
+ * Toggle row expansion
383
+ */
384
+ toggleRowExpansion(row: Row<T>): void;
385
+ /**
386
+ * Check if a cell is currently being edited
387
+ */
388
+ isEditing(rowId: string, columnId: string): boolean;
389
+ /**
390
+ * Start editing a cell
391
+ */
392
+ startEdit(row: Row<T>, columnId: string): void;
393
+ /**
394
+ * Save the edited cell value
395
+ */
396
+ saveEdit(row: Row<T>, columnId: string): void;
397
+ /**
398
+ * Cancel editing a cell
399
+ */
400
+ cancelEdit(): void;
401
+ /**
402
+ * Get cell value for editing
403
+ */
404
+ getEditingValue(): any;
405
+ /**
406
+ * Update editing value
407
+ */
408
+ updateEditingValue(value: any): void;
409
+ /**
410
+ * Get cell value from row data
411
+ */
412
+ private _getCellValue;
413
+ /**
414
+ * Set cell value in row data
415
+ */
416
+ private _setCellValue;
417
+ /**
418
+ * Check if a column is editable
419
+ */
420
+ getColumnEditable(columnId: string): boolean;
421
+ /**
422
+ * Get input type for editable column
423
+ */
424
+ getColumnEditType(columnId: string): string;
425
+ /**
426
+ * Export to CSV (Public API)
427
+ * Allows triggering CSV export programmatically or from custom UI
428
+ */
429
+ exportToCsv(options?: Partial<TanGridExportOptions>): void;
430
+ /**
431
+ * Export to Excel (Public API)
432
+ * Allows triggering Excel export programmatically or from custom UI
433
+ */
434
+ exportToExcel(options?: Partial<TanGridExportOptions>): void;
435
+ /**
436
+ * Export to PDF (Public API)
437
+ * Allows triggering PDF export programmatically or from custom UI
438
+ */
439
+ exportToPdf(options?: Partial<TanGridExportOptions>): void;
440
+ /**
441
+ * Export table data
442
+ */
443
+ exportData(options: TanGridExportOptions): void;
444
+ /**
445
+ * Toggle pin state for a column
446
+ */
447
+ togglePin(column: any): void;
448
+ /**
449
+ * Export to CSV
450
+ */
451
+ private _exportToCSV;
452
+ /**
453
+ * Export to Excel (XLSX)
454
+ * Note: Requires xlsx library to be installed
455
+ */
456
+ private _exportToExcel;
457
+ /**
458
+ * Export to PDF
459
+ * Note: Requires jspdf library to be installed
460
+ */
461
+ private _exportToPDF;
462
+ /**
463
+ * Escape CSV value
464
+ */
465
+ private _escapeCSV;
466
+ /**
467
+ * Download file
468
+ */
469
+ private _downloadFile;
470
+ /**
471
+ * Emit filter change event
472
+ */
473
+ private _emitFilterChange;
474
+ /**
475
+ * Check if value is a TemplateRef
476
+ */
477
+ isTemplateRef(value: any): boolean;
478
+ /**
479
+ * Handle page change
480
+ */
481
+ onPageChange(page: number): void;
482
+ /**
483
+ * Handle page size change
484
+ */
485
+ onPageSizeChange(size: number): void;
486
+ /**
487
+ * Handle row click
488
+ */
489
+ onRowClick(row: Row<T>, index: number): void;
490
+ /**
491
+ * Handle row double click
492
+ */
493
+ onRowDblClick(row: Row<T>, index: number): void;
494
+ onPinChange(columnId: string, position: 'left' | 'right' | 'none'): void;
495
+ ngAfterViewInit(): void;
496
+ ngOnDestroy(): void;
497
+ checkScroll(): void;
498
+ canPinLeft(columnId: string): boolean;
499
+ canPinRight(columnId: string): boolean;
500
+ /**
501
+ * Get total pages
502
+ */
503
+ getTotalPages(): number;
504
+ /**
505
+ * Get current page (1-indexed)
506
+ */
507
+ getCurrentPage(): number;
508
+ /**
509
+ * Get total items
510
+ */
511
+ getTotalItems(): number;
512
+ /**
513
+ * Get displayed items range
514
+ */
515
+ getDisplayedRange(): {
516
+ start: number;
517
+ end: number;
518
+ };
519
+ /**
520
+ * Get pagination page numbers to display
521
+ */
522
+ getPaginationPages(): (number | 'ellipsis')[];
523
+ /**
524
+ * Go to specific page
525
+ */
526
+ goToPage(page: number): void;
527
+ /**
528
+ * Get placeholder width for skeleton loader (Facebook-style)
529
+ */
530
+ getPlaceholderWidth(index: number): number;
531
+ private _convertColumns;
532
+ private _createTable;
533
+ private _emitSelectionChange;
534
+ private _emitPaginationChange;
535
+ private _initSortable;
536
+ /**
537
+ * Determine if there are any columns that can be filtered
538
+ */
539
+ hasFilterableColumns(): boolean;
540
+ static ɵfac: i0.ɵɵFactoryDeclaration<TanGrid<any>, never>;
541
+ static ɵcmp: i0.ɵɵComponentDeclaration<TanGrid<any>, "tan-grid", never, { "data": { "alias": "data"; "required": false; }; "columns": { "alias": "columns"; "required": false; }; "loading": { "alias": "loading"; "required": false; }; "striped": { "alias": "striped"; "required": false; }; "bordered": { "alias": "bordered"; "required": false; }; "hoverable": { "alias": "hoverable"; "required": false; }; "compact": { "alias": "compact"; "required": false; }; "theme": { "alias": "theme"; "required": false; }; "selectionMode": { "alias": "selectionMode"; "required": false; }; "selectedRowIds": { "alias": "selectedRowIds"; "required": false; }; "rowIdFn": { "alias": "rowIdFn"; "required": false; }; "pagination": { "alias": "pagination"; "required": false; }; "pageSize": { "alias": "pageSize"; "required": false; }; "pageSizeOptions": { "alias": "pageSizeOptions"; "required": false; }; "paginationMode": { "alias": "paginationMode"; "required": false; }; "totalItems": { "alias": "totalItems"; "required": false; }; "sorting": { "alias": "sorting"; "required": false; }; "sortingMode": { "alias": "sortingMode"; "required": false; }; "filtering": { "alias": "filtering"; "required": false; }; "filteringMode": { "alias": "filteringMode"; "required": false; }; "globalSearch": { "alias": "globalSearch"; "required": false; }; "showGlobalSearchInput": { "alias": "showGlobalSearchInput"; "required": false; }; "globalFilter": { "alias": "globalFilter"; "required": false; }; "emptyMessage": { "alias": "emptyMessage"; "required": false; }; "loadingMessage": { "alias": "loadingMessage"; "required": false; }; "loadingType": { "alias": "loadingType"; "required": false; }; "placeholderRows": { "alias": "placeholderRows"; "required": false; }; "virtualScroll": { "alias": "virtualScroll"; "required": false; }; "rowHeight": { "alias": "rowHeight"; "required": false; }; "virtualScrollBufferSize": { "alias": "virtualScrollBufferSize"; "required": false; }; "virtualScrollViewportHeight": { "alias": "virtualScrollViewportHeight"; "required": false; }; "pinnedLeft": { "alias": "pinnedLeft"; "required": false; }; "pinnedRight": { "alias": "pinnedRight"; "required": false; }; "enablePinning": { "alias": "enablePinning"; "required": false; }; "reorderable": { "alias": "reorderable"; "required": false; }; "emptyTemplate": { "alias": "emptyTemplate"; "required": false; }; "loadingTemplate": { "alias": "loadingTemplate"; "required": false; }; "expandable": { "alias": "expandable"; "required": false; }; "expandedRowTemplate": { "alias": "expandedRowTemplate"; "required": false; }; "expandedRowIds": { "alias": "expandedRowIds"; "required": false; }; "editable": { "alias": "editable"; "required": false; }; "exportable": { "alias": "exportable"; "required": false; }; "exportFormats": { "alias": "exportFormats"; "required": false; }; }, { "rowClick": "rowClick"; "rowDblClick": "rowDblClick"; "selectionChange": "selectionChange"; "sortChange": "sortChange"; "paginationChange": "paginationChange"; "filterChange": "filterChange"; "expansionChange": "expansionChange"; "pinChange": "pinChange"; "cellEditChange": "cellEditChange"; "columnOrderChange": "columnOrderChange"; }, never, never, true, never>;
542
+ }
@@ -0,0 +1,10 @@
1
+ import * as i0 from "@angular/core";
2
+ import * as i1 from "./table.component";
3
+ /**
4
+ * Table module
5
+ */
6
+ export declare class TanGridModule {
7
+ static ɵfac: i0.ɵɵFactoryDeclaration<TanGridModule, never>;
8
+ static ɵmod: i0.ɵɵNgModuleDeclaration<TanGridModule, never, [typeof i1.TanGrid], [typeof i1.TanGrid]>;
9
+ static ɵinj: i0.ɵɵInjectorDeclaration<TanGridModule>;
10
+ }