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.
- package/LICENSE +21 -0
- package/README.md +256 -2
- package/dist/index.cjs +1682 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +269 -0
- package/dist/index.d.ts +269 -0
- package/dist/index.js +1668 -0
- package/dist/index.js.map +1 -0
- package/package.json +78 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Reza Salehi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,257 @@
|
|
|
1
|
-
#
|
|
1
|
+
# angular-smart-table-pro
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/angular-smart-table-pro)
|
|
4
|
+
[](./LICENSE)
|
|
5
|
+
[](https://angular.dev/)
|
|
6
|
+
[](#features)
|
|
7
|
+
[](https://www.typescriptlang.org/)
|
|
8
|
+
|
|
9
|
+
**A professional, extensible Angular Smart Table & DataGrid in 2 lines of code.**
|
|
10
|
+
Built from the ground up with **Angular Signals**, **Zoneless & SSR** safety, and **zero external runtime dependencies** (no `@angular/material`, no `@angular/cdk`, no `xlsx` bloat).
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Screenshots
|
|
15
|
+
|
|
16
|
+
### 1. Desktop Smart Table (Filters, Drag & Drop, Selection, Column Chooser, Excel/CSV)
|
|
17
|
+

|
|
18
|
+
|
|
19
|
+
### 2. Virtual Scrolling (10,000+ Rows), Dark Mode & Responsive Mobile Cards
|
|
20
|
+

|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Features
|
|
25
|
+
|
|
26
|
+
| Feature | Included Out of the Box |
|
|
27
|
+
| :--- | :--- |
|
|
28
|
+
| **Server-Side Pagination, Sort & Filter** | `[serverSide]="true"`, `[totalItems]`, `[loading]`, `(queryChange)` |
|
|
29
|
+
| **Sorting & Filtering** | Single-click ascending/descending/reset + global search + `[showColumnFilters]="true"` |
|
|
30
|
+
| **Column Visibility** | Built-in toolbar **Columns** chooser popover + Reset button |
|
|
31
|
+
| **Drag & Drop Columns** | Native HTML5 column reordering (`[draggableColumns]="true"`, `(columnsChange)`) |
|
|
32
|
+
| **Row Selection** | `selectionMode="multiple" \| "single" \| "none"` + `[(selectedRows)]` Signal model |
|
|
33
|
+
| **Export to Excel & CSV** | Built-in UTF-8 BOM CSV (Persian/Unicode safe) + styled Excel `.xls` workbook |
|
|
34
|
+
| **Virtual Scrolling** | `[virtualScroll]="true"` O(1) windowing for 10,000+ rows at 60fps |
|
|
35
|
+
| **Responsive Design** | Automatic mobile stacked cards (`responsive="auto" \| "cards" \| "scroll"`) |
|
|
36
|
+
| **Custom Cell Templates** | `<ng-template ngxTableCell="status" let-row let-value="value">` |
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Installation
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npm install angular-smart-table-pro
|
|
44
|
+
# or
|
|
45
|
+
pnpm add angular-smart-table-pro
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Requires Angular `>=17.2.0` (`@angular/core`, `@angular/common`).
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Quick Start (2 Lines)
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
import { Component, signal } from '@angular/core';
|
|
56
|
+
import { NgxSmartTableComponent, type DataGridColumn } from 'angular-smart-table-pro';
|
|
57
|
+
|
|
58
|
+
interface User {
|
|
59
|
+
id: number;
|
|
60
|
+
name: string;
|
|
61
|
+
role: string;
|
|
62
|
+
salary: number;
|
|
63
|
+
status: 'Active' | 'Pending';
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@Component({
|
|
67
|
+
selector: 'app-users',
|
|
68
|
+
standalone: true,
|
|
69
|
+
imports: [NgxSmartTableComponent],
|
|
70
|
+
template: `
|
|
71
|
+
<ngx-smart-table
|
|
72
|
+
[data]="users()"
|
|
73
|
+
[columns]="columns"
|
|
74
|
+
selectionMode="multiple"
|
|
75
|
+
[(selectedRows)]="selected"
|
|
76
|
+
[showColumnFilters]="true"
|
|
77
|
+
/>
|
|
78
|
+
`,
|
|
79
|
+
})
|
|
80
|
+
export class UsersComponent {
|
|
81
|
+
readonly selected = signal<readonly User[]>([]);
|
|
82
|
+
|
|
83
|
+
readonly columns: DataGridColumn<User>[] = [
|
|
84
|
+
{ key: 'name', header: 'Member' },
|
|
85
|
+
{ key: 'role', header: 'Role' },
|
|
86
|
+
{ key: 'salary', header: 'Salary', type: 'number', align: 'end', format: (v) => `$${v}` },
|
|
87
|
+
{
|
|
88
|
+
key: 'status',
|
|
89
|
+
header: 'Status',
|
|
90
|
+
type: 'badge',
|
|
91
|
+
badgeTone: (v) => (v === 'Active' ? 'success' : 'warning'),
|
|
92
|
+
},
|
|
93
|
+
];
|
|
94
|
+
|
|
95
|
+
readonly users = signal<User[]>([
|
|
96
|
+
{ id: 1, name: 'Sara Ahmadi', role: 'Admin', salary: 4850, status: 'Active' },
|
|
97
|
+
{ id: 2, name: 'Reza Salehi', role: 'Architect', salary: 5400, status: 'Active' },
|
|
98
|
+
{ id: 3, name: 'Nima Karimi', role: 'Editor', salary: 3600, status: 'Pending' },
|
|
99
|
+
]);
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## Feature Guides & Examples
|
|
106
|
+
|
|
107
|
+
### 1. Server-Side Pagination, Sorting & Filtering
|
|
108
|
+
|
|
109
|
+
```html
|
|
110
|
+
<ngx-smart-table
|
|
111
|
+
[data]="rows()"
|
|
112
|
+
[columns]="columns"
|
|
113
|
+
[serverSide]="true"
|
|
114
|
+
[totalItems]="totalCount()"
|
|
115
|
+
[loading]="isLoading()"
|
|
116
|
+
[(page)]="page"
|
|
117
|
+
[(pageSize)]="pageSize"
|
|
118
|
+
(queryChange)="fetchFromApi($event)"
|
|
119
|
+
/>
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
fetchFromApi(query: GridQueryState): void {
|
|
124
|
+
// query = { page: 2, pageSize: 10, search: 'ali', filters: { role: 'Admin' }, sort: { key: 'salary', direction: 'desc' } }
|
|
125
|
+
this.api.getUsers(query).subscribe((res) => {
|
|
126
|
+
this.rows.set(res.items);
|
|
127
|
+
this.totalCount.set(res.total);
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### 2. Custom Cell Templates (`ngxTableCell`)
|
|
133
|
+
|
|
134
|
+
```html
|
|
135
|
+
<ngx-smart-table [data]="users()" [columns]="columns">
|
|
136
|
+
<ng-template ngxTableCell="name" let-row>
|
|
137
|
+
<div class="user-cell">
|
|
138
|
+
<img [src]="row.avatar" width="28" height="28" />
|
|
139
|
+
<span>{{ row.name }}</span>
|
|
140
|
+
</div>
|
|
141
|
+
</ng-template>
|
|
142
|
+
</ngx-smart-table>
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### 3. Virtual Scrolling (10,000+ Rows)
|
|
146
|
+
|
|
147
|
+
```html
|
|
148
|
+
<ngx-smart-table
|
|
149
|
+
[data]="massiveDataset()"
|
|
150
|
+
[columns]="columns"
|
|
151
|
+
[virtualScroll]="true"
|
|
152
|
+
[rowHeight]="44"
|
|
153
|
+
[viewportHeight]="440"
|
|
154
|
+
/>
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### 4. Global App Defaults (`provideEasyDataGrid`)
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
import { ApplicationConfig } from '@angular/core';
|
|
161
|
+
import { provideEasyDataGrid } from 'angular-smart-table-pro';
|
|
162
|
+
|
|
163
|
+
export const appConfig: ApplicationConfig = {
|
|
164
|
+
providers: [
|
|
165
|
+
provideEasyDataGrid({
|
|
166
|
+
theme: 'auto',
|
|
167
|
+
size: 'md',
|
|
168
|
+
responsive: 'auto',
|
|
169
|
+
pageSize: 25,
|
|
170
|
+
accentColor: '#10b981',
|
|
171
|
+
striped: true,
|
|
172
|
+
}),
|
|
173
|
+
],
|
|
174
|
+
};
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## Documentation Guides
|
|
180
|
+
|
|
181
|
+
- [**Getting Started & Custom Cells**](./docs/getting-started.md) — Setup, nested dot-path keys (`profile.email`), `ngxTableCell`, `provideEasyDataGrid`
|
|
182
|
+
- [**Server-Side Pagination, Sort & Filter**](./docs/server-side-pagination.md) — `queryChange` payload, `loading` state, and Angular `HttpClient` integration
|
|
183
|
+
- [**Virtual Scroll, Drag-Drop & Excel/CSV Export**](./docs/virtual-scroll-and-export.md) — Handling 10k+ rows, exporting selected rows, and column visibility
|
|
184
|
+
- [**Responsive Cards & Custom Themes**](./docs/theming-and-responsive.md) — Mobile card mode, Dark/Auto themes, `accentColor`, and `--nst-*` CSS variables
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## API Reference
|
|
189
|
+
|
|
190
|
+
### Inputs (`NgxSmartTableComponent`)
|
|
191
|
+
|
|
192
|
+
| Input | Type | Default | Description |
|
|
193
|
+
| :--- | :--- | :--- | :--- |
|
|
194
|
+
| `data` *(required)* | `ReadonlyArray<T>` | — | Array of row objects |
|
|
195
|
+
| `columns` *(required)* | `ReadonlyArray<DataGridColumn<T>>` | — | Column definitions |
|
|
196
|
+
| `rowKey` | `string` | `'id'` | Unique key property for selection & tracking |
|
|
197
|
+
| `serverSide` | `boolean` | `false` | Delegate sorting/filtering/paging to backend via `queryChange` |
|
|
198
|
+
| `totalItems` | `number \| null` | `null` | Total server row count when `serverSide` is `true` |
|
|
199
|
+
| `loading` | `boolean` | `false` | Show top animated loading bar |
|
|
200
|
+
| `pageable` | `boolean` | `true` | Enable pagination bar |
|
|
201
|
+
| `page` (model) | `number` | `1` | Current 1-based page (`[(page)]`) |
|
|
202
|
+
| `pageSize` (model) | `number` | `10` | Rows per page (`[(pageSize)]`) |
|
|
203
|
+
| `pageSizeOptions` | `number[]` | `[5, 10, 25, 50, 100]` | Page size selector options |
|
|
204
|
+
| `selectionMode` | `'none' \| 'single' \| 'multiple'` | `'none'` | Row selection mode |
|
|
205
|
+
| `selectedRows` (model) | `ReadonlyArray<T>` | `[]` | Selected rows Signal model (`[(selectedRows)]`) |
|
|
206
|
+
| `virtualScroll` | `boolean` | `false` | Enable O(1) virtual row windowing |
|
|
207
|
+
| `rowHeight` | `number` | `46` | Fixed row height (px) for virtual scrolling |
|
|
208
|
+
| `viewportHeight` | `number` | `420` | Scroll container height (px) for virtual scrolling |
|
|
209
|
+
| `overscan` | `number` | `4` | Extra rows rendered above/below virtual viewport |
|
|
210
|
+
| `sortable` | `boolean` | `true` | Enable or disable column sorting table-wide |
|
|
211
|
+
| `sort` (model) | `SortState \| null` | `null` | Active sort state (`[(sort)]`) |
|
|
212
|
+
| `search` (model) | `string` | `''` | Global search term (`[(search)]`) |
|
|
213
|
+
| `columnFilters` (model) | `Record<string, string>` | `{}` | Per-column filter values (`[(columnFilters)]`) |
|
|
214
|
+
| `showToolbar` | `boolean` | `true` | Show search, column chooser, and export toolbar |
|
|
215
|
+
| `showSearch` | `boolean` | `true` | Show global search input inside toolbar |
|
|
216
|
+
| `showColumnFilters` | `boolean` | `false` | Show per-column filter inputs under headers |
|
|
217
|
+
| `showColumnChooser` | `boolean` | `true` | Show column visibility dropdown |
|
|
218
|
+
| `showExport` | `boolean` | `true` | Show export buttons in toolbar |
|
|
219
|
+
| `exportFormats` | `Array<'csv' \| 'excel'>` | `['csv', 'excel']` | Control which export buttons are displayed |
|
|
220
|
+
| `exportFileName` | `string` | `'table-export'` | Base filename for downloaded CSV/Excel files |
|
|
221
|
+
| `draggableColumns` | `boolean` | `true` | Allow drag-and-drop column reordering |
|
|
222
|
+
| `stickyHeader` | `boolean` | `true` | Stick table header when scrolling |
|
|
223
|
+
| `striped` | `boolean` | `false` | Alternating row shading |
|
|
224
|
+
| `emptyText` | `string` | `''` | Custom message shown when no rows match |
|
|
225
|
+
| `theme` | `'light' \| 'dark' \| 'auto'` | `'light'` | Visual color scheme |
|
|
226
|
+
| `size` | `'compact' \| 'md' \| 'comfortable'` | `'md'` | Cell density |
|
|
227
|
+
| `responsive` | `'auto' \| 'scroll' \| 'cards'` | `'auto'` | Mobile card stacking vs horizontal scroll |
|
|
228
|
+
| `accentColor` | `string \| null` | `null` | Custom brand accent color |
|
|
229
|
+
| `locale` / `dir` | `string` / `'auto' \| 'ltr' \| 'rtl'` | `'en-US'` / `'auto'` | Localization & RTL support (supports `'fa-IR'`) |
|
|
230
|
+
|
|
231
|
+
### Outputs
|
|
232
|
+
|
|
233
|
+
| Output | Payload | Description |
|
|
234
|
+
| :--- | :--- | :--- |
|
|
235
|
+
| `queryChange` | `GridQueryState` | Fires on page, pageSize, search, column filter, or sort changes |
|
|
236
|
+
| `sortChange` | `SortState \| null` | Fires when `sort` model changes |
|
|
237
|
+
| `searchChange` | `string` | Fires when `search` model changes |
|
|
238
|
+
| `columnFiltersChange` | `Record<string, string>` | Fires when `columnFilters` model changes |
|
|
239
|
+
| `rowClick` | `T` | Fires when a user clicks a row |
|
|
240
|
+
| `columnsChange` | `DataGridColumn<T>[]` | Fires when columns are reordered or reset |
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## Development & Testing
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
pnpm install
|
|
248
|
+
pnpm run typecheck
|
|
249
|
+
pnpm test
|
|
250
|
+
pnpm run build
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
## License
|
|
256
|
+
|
|
257
|
+
MIT © [Reza Salehi](./LICENSE)
|