ngx-simple-datatables 1.17.0 → 2.0.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 +86 -52
- package/esm2022/interfaces/column-config.interface.mjs +1 -1
- package/esm2022/lib/ngx-simple-datatables.component.mjs +483 -0
- package/esm2022/lib/ngx-simple-datatables.module.mjs +20 -0
- package/esm2022/lib/ngx-simple-datatables.service.mjs +14 -0
- package/esm2022/ngx-simple-datatables.mjs +1 -1
- package/esm2022/public-api.mjs +5 -4
- package/fesm2022/ngx-simple-datatables.mjs +32 -16
- package/fesm2022/ngx-simple-datatables.mjs.map +1 -1
- package/lib/{ngx-simple-datatable.component.d.ts → ngx-simple-datatables.component.d.ts} +3 -3
- package/lib/ngx-simple-datatables.module.d.ts +8 -0
- package/lib/ngx-simple-datatables.service.d.ts +6 -0
- package/package.json +6 -6
- package/public-api.d.ts +3 -2
- package/esm2022/lib/ngx-simple-datatable.component.mjs +0 -483
- package/esm2022/lib/ngx-simple-datatable.service.mjs +0 -14
- package/lib/ngx-simple-datatable.service.d.ts +0 -6
package/README.md
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
#
|
|
1
|
+
# NgxSimpleDatatables
|
|
2
2
|
|
|
3
3
|
A lightweight, high-performance Angular data table component with features like virtual scrolling, column freezing, and customizable templates.
|
|
4
4
|
|
|
5
|
+

|
|
6
|
+
|
|
5
7
|
## Features
|
|
6
8
|
|
|
7
9
|
- 📊 Virtual scrolling for smooth performance with large datasets
|
|
@@ -15,7 +17,7 @@ A lightweight, high-performance Angular data table component with features like
|
|
|
15
17
|
## Installation
|
|
16
18
|
|
|
17
19
|
```bash
|
|
18
|
-
npm install ngx-simple-
|
|
20
|
+
npm install ngx-simple-datatables --save
|
|
19
21
|
```
|
|
20
22
|
|
|
21
23
|
## Basic Usage
|
|
@@ -23,12 +25,12 @@ npm install ngx-simple-datatable --save
|
|
|
23
25
|
1. Import the module in your `app.module.ts`:
|
|
24
26
|
|
|
25
27
|
```typescript
|
|
26
|
-
import {
|
|
28
|
+
import { NgxSimpleDatatablesModule } from "ngx-simple-datatables";
|
|
27
29
|
|
|
28
30
|
@NgModule({
|
|
29
31
|
imports: [
|
|
30
32
|
// ... other imports
|
|
31
|
-
|
|
33
|
+
NgxSimpleDatatablesModule,
|
|
32
34
|
],
|
|
33
35
|
})
|
|
34
36
|
export class AppModule {}
|
|
@@ -37,20 +39,20 @@ export class AppModule {}
|
|
|
37
39
|
2. Use the component in your template:
|
|
38
40
|
|
|
39
41
|
```html
|
|
40
|
-
<ngx-simple-
|
|
42
|
+
<ngx-simple-datatables
|
|
41
43
|
[columns]="columns"
|
|
42
44
|
[data]="data"
|
|
43
|
-
[rowHeight]="
|
|
44
|
-
[headerHeight]="
|
|
45
|
+
[rowHeight]="26"
|
|
46
|
+
[headerHeight]="26"
|
|
45
47
|
>
|
|
46
|
-
</ngx-simple-
|
|
48
|
+
</ngx-simple-datatables>
|
|
47
49
|
```
|
|
48
50
|
|
|
49
51
|
3. Define your columns and data in your component:
|
|
50
52
|
|
|
51
53
|
```typescript
|
|
52
54
|
import { Component } from "@angular/core";
|
|
53
|
-
import { ColumnConfig } from "ngx-simple-
|
|
55
|
+
import { ColumnConfig } from "ngx-simple-datatables";
|
|
54
56
|
|
|
55
57
|
interface UserData {
|
|
56
58
|
id: number;
|
|
@@ -85,6 +87,33 @@ export class AppComponent {
|
|
|
85
87
|
}
|
|
86
88
|
```
|
|
87
89
|
|
|
90
|
+
4. add styles in your `styles.css`:
|
|
91
|
+
|
|
92
|
+
```css
|
|
93
|
+
:root {
|
|
94
|
+
--ngx-simple-dt-bg: #efefef;
|
|
95
|
+
--ngx-simple-dt-border: 1px solid #e0e0e0;
|
|
96
|
+
--ngx-simple-dt-border-radius: 8px;
|
|
97
|
+
--ngx-simple-dt-box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
98
|
+
--ngx-simple-dt-transition: all 0.2s ease-in-out;
|
|
99
|
+
|
|
100
|
+
--ngx-simple-dt-header-bg: #98ccff;
|
|
101
|
+
--ngx-simple-dt-header-hover-bg: #e9ecef;
|
|
102
|
+
--ngx-simple-dt-header-border: 1px solid #e0e0e0;
|
|
103
|
+
--ngx-simple-dt-header-text: #495057;
|
|
104
|
+
--ngx-simple-dt-header-height: 48px;
|
|
105
|
+
--ngx-simple-dt-header-font-weight: 600;
|
|
106
|
+
--ngx-simple-dt-header-padding: 0 16px;
|
|
107
|
+
|
|
108
|
+
--ngx-simple-dt-cell-padding: 0 16px;
|
|
109
|
+
--ngx-simple-dt-cell-border: 1px solid #e9ecef;
|
|
110
|
+
--ngx-simple-dt-cell-hover-bg: #f1f3f5;
|
|
111
|
+
--ngx-simple-dt-cell-active-bg: #e9ecef;
|
|
112
|
+
--ngx-simple-dt-cell-font-size: 0.875rem;
|
|
113
|
+
--ngx-simple-dt-cell-line-height: 1.5;
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
88
117
|
## Advanced Features
|
|
89
118
|
|
|
90
119
|
### Column Freezing
|
|
@@ -105,7 +134,7 @@ columns: ColumnConfig[] = [
|
|
|
105
134
|
Use Angular templates to customize cell content:
|
|
106
135
|
|
|
107
136
|
```html
|
|
108
|
-
<ngx-simple-
|
|
137
|
+
<ngx-simple-datatables [columns]="columns" [data]="data">
|
|
109
138
|
<ng-template #cellTemplate let-row="row" let-column="column">
|
|
110
139
|
<ng-container [ngSwitch]="column.field">
|
|
111
140
|
<ng-container *ngSwitchCase="'status'">
|
|
@@ -121,7 +150,7 @@ Use Angular templates to customize cell content:
|
|
|
121
150
|
<ng-container *ngSwitchDefault> {{ row[column.field] }} </ng-container>
|
|
122
151
|
</ng-container>
|
|
123
152
|
</ng-template>
|
|
124
|
-
</ngx-simple-
|
|
153
|
+
</ngx-simple-datatables>
|
|
125
154
|
```
|
|
126
155
|
|
|
127
156
|
### Custom Header Templates
|
|
@@ -129,7 +158,7 @@ Use Angular templates to customize cell content:
|
|
|
129
158
|
Customize header appearance and behavior:
|
|
130
159
|
|
|
131
160
|
```html
|
|
132
|
-
<ngx-simple-
|
|
161
|
+
<ngx-simple-datatables [columns]="columns" [data]="data">
|
|
133
162
|
<ng-template #headerTemplate let-column="column">
|
|
134
163
|
<div class="custom-header">
|
|
135
164
|
<i class="fas fa-info-circle" [title]="column.header"></i>
|
|
@@ -137,7 +166,7 @@ Customize header appearance and behavior:
|
|
|
137
166
|
<i class="fas fa-sort" *ngIf="column.sortable"></i>
|
|
138
167
|
</div>
|
|
139
168
|
</ng-template>
|
|
140
|
-
</ngx-simple-
|
|
169
|
+
</ngx-simple-datatables>
|
|
141
170
|
```
|
|
142
171
|
|
|
143
172
|
### Theming
|
|
@@ -147,12 +176,41 @@ Customize the table appearance using CSS custom properties:
|
|
|
147
176
|
```css
|
|
148
177
|
/* styles.css */
|
|
149
178
|
:root {
|
|
150
|
-
--ngx-simple-dt-
|
|
151
|
-
--ngx-simple-dt-
|
|
152
|
-
--ngx-simple-dt-
|
|
179
|
+
--ngx-simple-dt-bg: #efefef;
|
|
180
|
+
--ngx-simple-dt-border: 1px solid #e0e0e0;
|
|
181
|
+
--ngx-simple-dt-border-radius: 8px;
|
|
182
|
+
--ngx-simple-dt-box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
183
|
+
--ngx-simple-dt-transition: all 0.2s ease-in-out;
|
|
184
|
+
|
|
185
|
+
--ngx-simple-dt-header-bg: #98ccff;
|
|
186
|
+
--ngx-simple-dt-header-hover-bg: #e9ecef;
|
|
187
|
+
--ngx-simple-dt-header-border: 1px solid #e0e0e0;
|
|
188
|
+
--ngx-simple-dt-header-text: #495057;
|
|
189
|
+
--ngx-simple-dt-header-height: 48px;
|
|
190
|
+
--ngx-simple-dt-header-font-weight: 600;
|
|
191
|
+
--ngx-simple-dt-header-padding: 0 16px;
|
|
192
|
+
|
|
193
|
+
--ngx-simple-dt-cell-padding: 0 16px;
|
|
194
|
+
--ngx-simple-dt-cell-border: 1px solid #e9ecef;
|
|
195
|
+
--ngx-simple-dt-cell-hover-bg: #f1f3f5;
|
|
196
|
+
--ngx-simple-dt-cell-active-bg: #e9ecef;
|
|
197
|
+
--ngx-simple-dt-cell-font-size: 0.875rem;
|
|
198
|
+
--ngx-simple-dt-cell-line-height: 1.5;
|
|
199
|
+
|
|
200
|
+
--ngx-simple-dt-row-height: 48px;
|
|
201
|
+
--ngx-simple-dt-row-hover-bg: #f8f9fa;
|
|
153
202
|
--ngx-simple-dt-row-stripe-bg: #f8f9fa;
|
|
203
|
+
--ngx-simple-dt-row-active-bg: #e9ecef;
|
|
154
204
|
--ngx-simple-dt-cell-padding: 0 16px;
|
|
155
205
|
--ngx-simple-dt-cell-border: 1px solid #e9ecef;
|
|
206
|
+
--ngx-simple-dt-cell-font-size: 0.875rem;
|
|
207
|
+
--ngx-simple-dt-cell-line-height: 1.5;
|
|
208
|
+
|
|
209
|
+
--ngx-simple-dt-row-bg: #ffffff;
|
|
210
|
+
--ngx-simple-dt-row-hover-bg: #f8f9fa;
|
|
211
|
+
--ngx-simple-dt-row-stripe-bg: #f8f9fa;
|
|
212
|
+
--ngx-simple-dt-row-active-bg: #e9ecef;
|
|
213
|
+
--ngx-simple-dt-row-border: 1px solid #e9ecef;
|
|
156
214
|
}
|
|
157
215
|
```
|
|
158
216
|
|
|
@@ -170,52 +228,28 @@ Customize the table appearance using CSS custom properties:
|
|
|
170
228
|
|
|
171
229
|
### Column Configuration
|
|
172
230
|
|
|
173
|
-
| Property | Type | Description |
|
|
174
|
-
| ---------- | ---------------------------- | -------------------------------- |
|
|
175
|
-
| `field` | `string` | Property name in the data object |
|
|
176
|
-
| `header` | `string` | Column header text |
|
|
177
|
-
| `width` | `string
|
|
178
|
-
| `freeze` | `'left'
|
|
179
|
-
| `sortable` | `boolean` | Whether the column is sortable |
|
|
180
|
-
| `sortFn` | `(a: any, b: any) => number` | Custom sort function |
|
|
181
|
-
|
|
182
|
-
## Styling
|
|
183
|
-
|
|
184
|
-
You can customize the table appearance by overriding the following CSS custom properties:
|
|
185
|
-
|
|
186
|
-
```css
|
|
187
|
-
.dynamic-table-container {
|
|
188
|
-
--ngx-simple-dt-bg: #ffffff;
|
|
189
|
-
--ngx-simple-dt-border: 1px solid #e0e0e0;
|
|
190
|
-
--ngx-simple-dt-border-radius: 8px;
|
|
191
|
-
--ngx-simple-dt-box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
192
|
-
--ngx-simple-dt-transition: all 0.2s ease-in-out;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
.table-header {
|
|
196
|
-
--ngx-simple-dt-header-bg: #f8f9fa;
|
|
197
|
-
--ngx-simple-dt-header-hover-bg: #e9ecef;
|
|
198
|
-
--ngx-simple-dt-header-border: 1px solid #e0e0e0;
|
|
199
|
-
--ngx-simple-dt-header-text: #495057;
|
|
200
|
-
--ngx-simple-dt-header-height: 48px;
|
|
201
|
-
--ngx-simple-dt-header-font-weight: 600;
|
|
202
|
-
--ngx-simple-dt-header-padding: 0 16px;
|
|
203
|
-
}
|
|
204
|
-
```
|
|
231
|
+
| Property | Type | Description | details |
|
|
232
|
+
| ---------- | ---------------------------- | -------------------------------- | ------------ |
|
|
233
|
+
| `field` | `string` | Property name in the data object | string |
|
|
234
|
+
| `header` | `string` | Column header text | string |
|
|
235
|
+
| `width` | `string \| number` | Column width (px or %) | |
|
|
236
|
+
| `freeze` | `'left' \| 'right'` | Freeze column position | |
|
|
237
|
+
| `sortable` | `boolean` | Whether the column is sortable | true / false |
|
|
238
|
+
| `sortFn` | `(a: any, b: any) => number` | Custom sort function | function |
|
|
205
239
|
|
|
206
240
|
## Development
|
|
207
241
|
|
|
208
|
-
Run `ng build ngx-simple-
|
|
242
|
+
Run `ng build ngx-simple-datatables` to build the library. The build artifacts will be stored in the `dist/` directory.
|
|
209
243
|
|
|
210
244
|
## Publishing
|
|
211
245
|
|
|
212
|
-
After building your library with `ng build ngx-simple-
|
|
246
|
+
After building your library with `ng build ngx-simple-datatables`, go to the dist folder `cd dist/ngx-simple-datatables` and run `npm publish`.
|
|
213
247
|
|
|
214
|
-
After building your library with `ng build ngx-simple-
|
|
248
|
+
After building your library with `ng build ngx-simple-datatables`, go to the dist folder `cd dist/ngx-simple-datatables` and run `npm publish`.
|
|
215
249
|
|
|
216
250
|
## Running unit tests
|
|
217
251
|
|
|
218
|
-
Run `ng test ngx-simple-
|
|
252
|
+
Run `ng test ngx-simple-datatables` to execute the unit tests via [Karma](https://karma-runner.github.io).
|
|
219
253
|
|
|
220
254
|
## Further help
|
|
221
255
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export {};
|
|
2
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29sdW1uLWNvbmZpZy5pbnRlcmZhY2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9wcm9qZWN0cy9uZ3gtc2ltcGxlLWRhdGF0YWJsZXMvc3JjL2ludGVyZmFjZXMvY29sdW1uLWNvbmZpZy5pbnRlcmZhY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBpbnRlcmZhY2UgQ29sdW1uQ29uZmlnIHtcbiAgZmllbGQ6IHN0cmluZztcbiAgaGVhZGVyOiBzdHJpbmc7XG4gIHdpZHRoPzogc3RyaW5nO1xuICBmcmVlemU/OiBcImxlZnRcIiB8IFwicmlnaHRcIjtcbiAgc29ydGFibGU/OiBib29sZWFuO1xuICBmb3JtYXR0ZXI/OiAodmFsdWU6IGFueSwgcm93OiBhbnkpID0+IHN0cmluZztcbn1cblxuZXhwb3J0IGludGVyZmFjZSBTb3J0U3RhdGUge1xuICBmaWVsZDogc3RyaW5nO1xuICBkaXJlY3Rpb246IFwiYXNjXCIgfCBcImRlc2NcIiB8IG51bGw7XG59XG4iXX0=
|