angular-smart-table-pro 0.0.0-stage → 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.
@@ -0,0 +1,269 @@
1
+ import * as _angular_core from '@angular/core';
2
+ import { TemplateRef, InjectionToken, EnvironmentProviders } from '@angular/core';
3
+
4
+ type SortDirection = 'asc' | 'desc';
5
+ type SelectionMode = 'none' | 'single' | 'multiple';
6
+ type ResponsiveMode = 'auto' | 'scroll' | 'cards';
7
+ type GridTheme = 'light' | 'dark' | 'auto';
8
+ type GridSize = 'compact' | 'md' | 'comfortable';
9
+ type CellAlign = 'start' | 'center' | 'end';
10
+ type ColumnType = 'text' | 'number' | 'date' | 'boolean' | 'badge';
11
+ type BadgeTone = 'neutral' | 'info' | 'success' | 'warning' | 'danger';
12
+ type TextDirection = 'auto' | 'ltr' | 'rtl';
13
+ type ExportFormat = 'csv' | 'excel';
14
+ interface SortState {
15
+ readonly key: string;
16
+ readonly direction: SortDirection;
17
+ }
18
+ interface DataGridColumn<T = Record<string, unknown>> {
19
+ readonly key: (keyof T & string) | (string & {});
20
+ readonly header: string;
21
+ readonly sortable?: boolean;
22
+ readonly filterable?: boolean;
23
+ readonly visible?: boolean;
24
+ readonly draggable?: boolean;
25
+ readonly exportable?: boolean;
26
+ readonly width?: string;
27
+ readonly minWidth?: string;
28
+ readonly align?: CellAlign;
29
+ readonly type?: ColumnType;
30
+ readonly format?: (value: unknown, row: T) => string;
31
+ readonly badgeTone?: (value: unknown, row: T) => BadgeTone;
32
+ readonly sortBy?: (a: T, b: T) => number;
33
+ }
34
+ interface GridQueryState {
35
+ readonly page: number;
36
+ readonly pageSize: number;
37
+ readonly search: string;
38
+ readonly filters: Readonly<Record<string, string>>;
39
+ readonly sort: SortState | null;
40
+ }
41
+ interface VirtualScrollWindow<T> {
42
+ readonly items: ReadonlyArray<T>;
43
+ readonly startIndex: number;
44
+ readonly endIndex: number;
45
+ readonly topSpacerPx: number;
46
+ readonly bottomSpacerPx: number;
47
+ readonly totalHeightPx: number;
48
+ }
49
+ interface PaginationSlice<T> {
50
+ readonly items: ReadonlyArray<T>;
51
+ readonly totalItems: number;
52
+ readonly totalPages: number;
53
+ readonly safePage: number;
54
+ readonly startItem: number;
55
+ readonly endItem: number;
56
+ }
57
+ interface ExportOptions {
58
+ readonly fileName?: string;
59
+ readonly sheetName?: string;
60
+ readonly onlySelected?: boolean;
61
+ readonly includeHiddenColumns?: boolean;
62
+ }
63
+ interface EasyDataGridConfig {
64
+ readonly theme?: GridTheme;
65
+ readonly size?: GridSize;
66
+ readonly responsive?: ResponsiveMode;
67
+ readonly dir?: TextDirection;
68
+ readonly locale?: string;
69
+ readonly pageSize?: number;
70
+ readonly pageSizeOptions?: ReadonlyArray<number>;
71
+ readonly showToolbar?: boolean;
72
+ readonly showSearch?: boolean;
73
+ readonly showColumnFilters?: boolean;
74
+ readonly showColumnChooser?: boolean;
75
+ readonly showExport?: boolean;
76
+ readonly exportFormats?: ReadonlyArray<ExportFormat>;
77
+ readonly sortable?: boolean;
78
+ readonly draggableColumns?: boolean;
79
+ readonly stickyHeader?: boolean;
80
+ readonly striped?: boolean;
81
+ readonly accentColor?: string | null;
82
+ }
83
+
84
+ interface TableCellTemplateContext<T = Record<string, unknown>> {
85
+ readonly $implicit: T;
86
+ readonly row: T;
87
+ readonly value: unknown;
88
+ readonly index: number;
89
+ }
90
+ /**
91
+ * Marks a custom `<ng-template ngxTableCell="columnKey" let-row let-value="value">` for a column.
92
+ */
93
+ declare class NgxTableCellDirective<T = Record<string, unknown>> {
94
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgxTableCellDirective<any>, never>;
95
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgxTableCellDirective<any>, "ng-template[ngxTableCell]", never, { "ngxTableCell": { readonly alias: "ngxTableCell"; readonly required: true; }; }, {}, never, never, true, never>;
96
+ readonly ngxTableCell: _angular_core.InputSignal<string>;
97
+ readonly template: TemplateRef<any>;
98
+ }
99
+
100
+ declare class NgxSmartTableComponent<T = Record<string, unknown>> {
101
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgxSmartTableComponent<any>, never>;
102
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<NgxSmartTableComponent<any>, "ngx-smart-table", ["ngxSmartTable"], { "data": { readonly alias: "data"; readonly required: true; }; "columns": { readonly alias: "columns"; readonly required: true; }; "rowKey": { readonly alias: "rowKey"; readonly required: false; }; "serverSide": { readonly alias: "serverSide"; readonly required: false; }; "totalItems": { readonly alias: "totalItems"; readonly required: false; }; "loading": { readonly alias: "loading"; readonly required: false; }; "pageable": { readonly alias: "pageable"; readonly required: false; }; "page": { readonly alias: "page"; readonly required: false; }; "pageSize": { readonly alias: "pageSize"; readonly required: false; }; "pageSizeOptions": { readonly alias: "pageSizeOptions"; readonly required: false; }; "selectionMode": { readonly alias: "selectionMode"; readonly required: false; }; "selectedRows": { readonly alias: "selectedRows"; readonly required: false; }; "virtualScroll": { readonly alias: "virtualScroll"; readonly required: false; }; "rowHeight": { readonly alias: "rowHeight"; readonly required: false; }; "viewportHeight": { readonly alias: "viewportHeight"; readonly required: false; }; "overscan": { readonly alias: "overscan"; readonly required: false; }; "showToolbar": { readonly alias: "showToolbar"; readonly required: false; }; "showSearch": { readonly alias: "showSearch"; readonly required: false; }; "showColumnFilters": { readonly alias: "showColumnFilters"; readonly required: false; }; "showColumnChooser": { readonly alias: "showColumnChooser"; readonly required: false; }; "showExport": { readonly alias: "showExport"; readonly required: false; }; "exportFormats": { readonly alias: "exportFormats"; readonly required: false; }; "sortable": { readonly alias: "sortable"; readonly required: false; }; "draggableColumns": { readonly alias: "draggableColumns"; readonly required: false; }; "stickyHeader": { readonly alias: "stickyHeader"; readonly required: false; }; "striped": { readonly alias: "striped"; readonly required: false; }; "exportFileName": { readonly alias: "exportFileName"; readonly required: false; }; "emptyText": { readonly alias: "emptyText"; readonly required: false; }; "theme": { readonly alias: "theme"; readonly required: false; }; "size": { readonly alias: "size"; readonly required: false; }; "responsive": { readonly alias: "responsive"; readonly required: false; }; "dir": { readonly alias: "dir"; readonly required: false; }; "locale": { readonly alias: "locale"; readonly required: false; }; "accentColor": { readonly alias: "accentColor"; readonly required: false; }; "search": { readonly alias: "search"; readonly required: false; }; "columnFilters": { readonly alias: "columnFilters"; readonly required: false; }; "sort": { readonly alias: "sort"; readonly required: false; } }, { "pageChange": "pageChange"; "pageSizeChange": "pageSizeChange"; "selectedRowsChange": "selectedRowsChange"; "searchChange": "searchChange"; "columnFiltersChange": "columnFiltersChange"; "sortChange": "sortChange"; "queryChange": "queryChange"; "rowClick": "rowClick"; "columnsChange": "columnsChange" }, ["cellTemplates"], never, true, never>;
103
+ private readonly destroyRef;
104
+ private readonly platformId;
105
+ private readonly doc;
106
+ private readonly injectedConfig;
107
+ private readonly isBrowser;
108
+ private readonly cellTemplates;
109
+ readonly data: _angular_core.InputSignal<readonly T[]>;
110
+ readonly columns: _angular_core.InputSignal<readonly DataGridColumn<T>[]>;
111
+ readonly rowKey: _angular_core.InputSignal<string>;
112
+ readonly serverSide: _angular_core.InputSignal<boolean>;
113
+ readonly totalItems: _angular_core.InputSignal<number | null>;
114
+ readonly loading: _angular_core.InputSignal<boolean>;
115
+ readonly pageable: _angular_core.InputSignal<boolean>;
116
+ readonly page: _angular_core.ModelSignal<number>;
117
+ readonly pageSize: _angular_core.ModelSignal<number>;
118
+ readonly pageSizeOptions: _angular_core.InputSignal<readonly number[] | undefined>;
119
+ readonly selectionMode: _angular_core.InputSignal<SelectionMode>;
120
+ readonly selectedRows: _angular_core.ModelSignal<readonly T[]>;
121
+ readonly virtualScroll: _angular_core.InputSignal<boolean>;
122
+ readonly rowHeight: _angular_core.InputSignal<number>;
123
+ readonly viewportHeight: _angular_core.InputSignal<number>;
124
+ readonly overscan: _angular_core.InputSignal<number>;
125
+ readonly showToolbar: _angular_core.InputSignal<boolean | undefined>;
126
+ readonly showSearch: _angular_core.InputSignal<boolean | undefined>;
127
+ readonly showColumnFilters: _angular_core.InputSignal<boolean | undefined>;
128
+ readonly showColumnChooser: _angular_core.InputSignal<boolean | undefined>;
129
+ readonly showExport: _angular_core.InputSignal<boolean | undefined>;
130
+ readonly exportFormats: _angular_core.InputSignal<readonly ExportFormat[] | undefined>;
131
+ readonly sortable: _angular_core.InputSignal<boolean | undefined>;
132
+ readonly draggableColumns: _angular_core.InputSignal<boolean | undefined>;
133
+ readonly stickyHeader: _angular_core.InputSignal<boolean | undefined>;
134
+ readonly striped: _angular_core.InputSignal<boolean | undefined>;
135
+ readonly exportFileName: _angular_core.InputSignal<string>;
136
+ readonly emptyText: _angular_core.InputSignal<string>;
137
+ readonly theme: _angular_core.InputSignal<GridTheme | undefined>;
138
+ readonly size: _angular_core.InputSignal<GridSize | undefined>;
139
+ readonly responsive: _angular_core.InputSignal<ResponsiveMode | undefined>;
140
+ readonly dir: _angular_core.InputSignal<TextDirection | undefined>;
141
+ readonly locale: _angular_core.InputSignal<string | undefined>;
142
+ readonly accentColor: _angular_core.InputSignal<string | null | undefined>;
143
+ readonly queryChange: _angular_core.OutputEmitterRef<GridQueryState>;
144
+ readonly rowClick: _angular_core.OutputEmitterRef<T>;
145
+ readonly columnsChange: _angular_core.OutputEmitterRef<readonly DataGridColumn<T>[]>;
146
+ readonly search: _angular_core.ModelSignal<string>;
147
+ readonly columnFilters: _angular_core.ModelSignal<Readonly<Record<string, string>>>;
148
+ readonly sort: _angular_core.ModelSignal<SortState | null>;
149
+ readonly columnOrder: _angular_core.WritableSignal<readonly DataGridColumn<T>[]>;
150
+ readonly hiddenColumnKeys: _angular_core.WritableSignal<ReadonlySet<string>>;
151
+ readonly columnChooserOpen: _angular_core.WritableSignal<boolean>;
152
+ readonly draggedColumnKey: _angular_core.WritableSignal<string | null>;
153
+ readonly dragOverColumnKey: _angular_core.WritableSignal<string | null>;
154
+ readonly scrollTop: _angular_core.WritableSignal<number>;
155
+ readonly resolvedTheme: _angular_core.Signal<GridTheme>;
156
+ readonly resolvedSize: _angular_core.Signal<GridSize>;
157
+ readonly resolvedResponsive: _angular_core.Signal<ResponsiveMode>;
158
+ readonly resolvedLocale: _angular_core.Signal<string>;
159
+ readonly isPersianUi: _angular_core.Signal<boolean>;
160
+ readonly resolvedDir: _angular_core.Signal<"ltr" | "rtl">;
161
+ readonly resolvedAccentColor: _angular_core.Signal<string | null>;
162
+ readonly resolvedShowToolbar: _angular_core.Signal<boolean>;
163
+ readonly resolvedShowSearch: _angular_core.Signal<boolean>;
164
+ readonly resolvedShowColumnFilters: _angular_core.Signal<boolean>;
165
+ readonly resolvedShowColumnChooser: _angular_core.Signal<boolean>;
166
+ readonly resolvedShowExport: _angular_core.Signal<boolean>;
167
+ readonly resolvedExportFormats: _angular_core.Signal<readonly ExportFormat[]>;
168
+ readonly resolvedSortable: _angular_core.Signal<boolean>;
169
+ readonly resolvedDraggableColumns: _angular_core.Signal<boolean>;
170
+ readonly resolvedStickyHeader: _angular_core.Signal<boolean>;
171
+ readonly resolvedStriped: _angular_core.Signal<boolean>;
172
+ readonly resolvedPageSizeOptions: _angular_core.Signal<readonly number[]>;
173
+ readonly searchPlaceholder: _angular_core.Signal<string>;
174
+ readonly orderedColumns: _angular_core.Signal<readonly DataGridColumn<T>[]>;
175
+ readonly visibleColumns: _angular_core.Signal<readonly DataGridColumn<T>[]>;
176
+ readonly totalColumnSpan: _angular_core.Signal<number>;
177
+ readonly processedRows: _angular_core.Signal<readonly T[]>;
178
+ readonly paginationInfo: _angular_core.Signal<PaginationSlice<T>>;
179
+ readonly virtualWindow: _angular_core.Signal<VirtualScrollWindow<T>>;
180
+ readonly renderedRows: _angular_core.Signal<readonly T[]>;
181
+ readonly visiblePageNumbers: _angular_core.Signal<readonly number[]>;
182
+ readonly allVisibleSelected: _angular_core.Signal<boolean>;
183
+ readonly someVisibleSelected: _angular_core.Signal<boolean>;
184
+ constructor();
185
+ getCellTemplate(key: string): TemplateRef<TableCellTemplateContext<T>> | null;
186
+ getRawCellValue(row: T, key: string): unknown;
187
+ formatCell(row: T, col: DataGridColumn<T>): string;
188
+ getBadgeTone(row: T, col: DataGridColumn<T>): BadgeTone;
189
+ trackRow(index: number, row: T): unknown;
190
+ isColumnVisible(key: string): boolean;
191
+ isColumnSortable(col: DataGridColumn<T>): boolean;
192
+ canExportFormat(format: ExportFormat): boolean;
193
+ toggleColumnChooser(event: Event): void;
194
+ toggleColumnVisibility(key: string): void;
195
+ resetColumns(): void;
196
+ onSearchInput(event: Event): void;
197
+ onColumnFilterInput(key: string, event: Event): void;
198
+ onSortClick(col: DataGridColumn<T>): void;
199
+ onColumnDragStart(event: DragEvent, key: string): void;
200
+ onColumnDragOver(event: DragEvent, key: string): void;
201
+ onColumnDrop(event: DragEvent, targetKey: string): void;
202
+ onColumnDragEnd(): void;
203
+ isRowSelected(row: T): boolean;
204
+ toggleRowSelection(row: T): void;
205
+ toggleSelectAll(): void;
206
+ onRowClicked(row: T): void;
207
+ goToPage(targetPage: number): void;
208
+ onPageSizeChange(event: Event): void;
209
+ onVirtualScroll(event: Event): void;
210
+ exportCsv(options?: ExportOptions): string;
211
+ exportExcel(options?: ExportOptions): string;
212
+ private emitQuery;
213
+ }
214
+
215
+ declare const DEFAULT_DATAGRID_CONFIG: Required<EasyDataGridConfig>;
216
+ declare const NGX_DATAGRID_CONFIG: InjectionToken<EasyDataGridConfig>;
217
+ /**
218
+ * Registers global defaults for all `<ngx-smart-table>` instances in an Angular application.
219
+ */
220
+ declare function provideEasyDataGrid(config: EasyDataGridConfig): EnvironmentProviders;
221
+
222
+ /**
223
+ * Generates UTF-8 BOM-prefixed RFC 4180 CSV text (safe for Excel Persian & Unicode characters).
224
+ */
225
+ declare function buildCsvContent<T>(rows: ReadonlyArray<T>, columns: ReadonlyArray<DataGridColumn<T>>, options?: ExportOptions): string;
226
+ /**
227
+ * Generates an Excel-compatible SpreadsheetML (.xls) XML workbook with styled header row and typed cells.
228
+ */
229
+ declare function buildExcelXmlContent<T>(rows: ReadonlyArray<T>, columns: ReadonlyArray<DataGridColumn<T>>, options?: ExportOptions): string;
230
+ /**
231
+ * Triggers a file download in browser environments safely (no-op in SSR).
232
+ */
233
+ declare function triggerBrowserDownload(content: string, fileName: string, mimeType: string, doc?: Document | null): void;
234
+
235
+ /**
236
+ * Resolves a top-level key or dot-separated nested path (e.g. 'profile.email') from a row object.
237
+ */
238
+ declare function resolveCellValue<T>(row: T, key: string): unknown;
239
+ /**
240
+ * Formats a cell value into a human-readable string using column formatter or smart type defaults.
241
+ */
242
+ declare function formatCellDisplay<T>(row: T, col: DataGridColumn<T>): string;
243
+ /**
244
+ * Filters rows by global search query and per-column filter terms.
245
+ */
246
+ declare function filterRows<T>(rows: ReadonlyArray<T>, columns: ReadonlyArray<DataGridColumn<T>>, search: string, columnFilters: Readonly<Record<string, string>>): T[];
247
+ /**
248
+ * Returns a new sorted array of rows according to the active SortState.
249
+ */
250
+ declare function sortRows<T>(rows: ReadonlyArray<T>, columns: ReadonlyArray<DataGridColumn<T>>, sort: SortState | null): T[];
251
+ /**
252
+ * Slices a row array into a 1-based page window with clamped bounds.
253
+ */
254
+ declare function paginateRows<T>(rows: ReadonlyArray<T>, page: number, pageSize: number): PaginationSlice<T>;
255
+ /**
256
+ * Reorders columns immutably by moving `fromKey` to the position of `toKey`.
257
+ */
258
+ declare function reorderColumns<T>(columns: ReadonlyArray<DataGridColumn<T>>, fromKey: string, toKey: string): DataGridColumn<T>[];
259
+ /**
260
+ * Computes O(1) virtual scroll slice and top/bottom spacer heights for large datasets.
261
+ */
262
+ declare function computeVirtualWindow<T>(rows: ReadonlyArray<T>, options: {
263
+ readonly scrollTop: number;
264
+ readonly viewportHeight: number;
265
+ readonly rowHeight: number;
266
+ readonly overscan?: number;
267
+ }): VirtualScrollWindow<T>;
268
+
269
+ export { type BadgeTone, type CellAlign, type ColumnType, DEFAULT_DATAGRID_CONFIG, type DataGridColumn, type EasyDataGridConfig, type ExportFormat, type ExportOptions, type GridQueryState, type GridSize, type GridTheme, NGX_DATAGRID_CONFIG, NgxSmartTableComponent, NgxTableCellDirective, type PaginationSlice, type ResponsiveMode, type SelectionMode, type SortDirection, type SortState, type TableCellTemplateContext, type TextDirection, type VirtualScrollWindow, buildCsvContent, buildExcelXmlContent, computeVirtualWindow, filterRows, formatCellDisplay, paginateRows, provideEasyDataGrid, reorderColumns, resolveCellValue, sortRows, triggerBrowserDownload };