@avoraui/av-data-table 0.0.4 → 0.0.6

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/CHANGELOG.md ADDED
@@ -0,0 +1,12 @@
1
+ ## [0.0.4] - 2025-07-24
2
+ ### Changed
3
+ - Component selector updated from `aur-data-table` to `av-data-table`
4
+
5
+ ### ⚠️ BREAKING CHANGES
6
+ - Please update your component usage:
7
+ ```html
8
+ <!-- OLD -->
9
+ <aur-data-table></aur-data-table>
10
+
11
+ <!-- NEW -->
12
+ <av-data-table></av-data-table>
package/README.md CHANGED
@@ -1,125 +1,42 @@
1
1
  # AvDataTable Component (AvoraUI)
2
2
 
3
- A powerful, customizable Angular data table component with built-in pagination, event-driven actions, and reactive forms support. This component provides flexibility for users to implement custom business logic through event handlers rather than predefined CRUD operations.
3
+ `AvDataTable` is a powerful, customizable standalone Angular component that provides a feature-rich data table interface with advanced pagination, dynamic column rendering, and interactive row actions. It offers a flexible solution for displaying and managing tabular data with support for nested object properties, custom styling, and seamless integration with Angular Reactive Forms.
4
4
 
5
5
  ## Features
6
6
 
7
- - ✅ **Pagination** - Built-in pagination with customizable page sizes
8
- - ✅ **Event-Driven Actions** - Customizable add, modify, and delete event handlers
9
- - ✅ **Reactive Forms Integration** - Implements `ControlValueAccessor`
10
- - ✅ **Flexible Column Configuration** - Support for nested object properties
11
- - ✅ **Customizable Styling** - Configurable alignment and colors
12
- - ✅ **Action Events** - Optional action buttons with customizable event handlers
13
- - ✅ **User-Controlled Operations** - Flexible event system for custom business logic
14
- - ✅ **Responsive Grid Layout** - CSS Grid-based responsive design
15
- - ✅ **Data Synchronization** - Automatic sync between internal and external data sources
7
+ - ✅ **Advanced Pagination** - Configurable page sizes and options.
8
+ - ✅ **Dynamic Grid Layout** - Automatic grid template generation based on column count.
9
+ - ✅ **Nested Property Access** - Support for dot notation (e.g., `user.address.city`).
10
+ - ✅ **Array Handling** - Automatic formatting and joining of array values.
11
+ - ✅ **Interactive Actions** - Configurable modify and delete buttons with customizable event handlers.
12
+ - ✅ **Action Control** - Individual control over button visibility and disabled states.
13
+ - ✅ **Customizable Alignment** - Left, center, or right alignment for headers and data.
14
+ - ✅ **Dynamic Styling** - Custom color support for table cells.
15
+ - ✅ **Event-Driven Architecture** - Emits events for modify, add, and remove operations.
16
+ - ✅ **Auto-Adjustment** - Automatic page recalculation when data changes or items are removed.
17
+ - ✅ **Bidirectional Data Sync** - Intelligent synchronization between internal and external data sources.
18
+ - ✅ **Form Integration** - Implements `ControlValueAccessor` for Reactive Forms compatibility.
19
+ - ✅ **Material Premium UI** - Integration with Angular Material components for a professional look.
20
+ - ✅ **Change Detection Optimized** - Efficient data reference updates to prevent unnecessary re-rendering.
21
+ - ✅ **Null Safety** - Graceful handling of null or undefined values with fallback display.
16
22
 
17
23
  ## Dependencies
18
24
 
19
- This component requires the following Angular Material modules:
20
-
21
- ```typescript
22
- import { MatCard } from "@angular/material/card";
23
- import { MatButton } from "@angular/material/button";
24
- import { MatIcon } from '@angular/material/icon';
25
- ```
26
- ```markdown
27
- 🚨 Version 0.0.4 introduces a breaking change:
28
- Component selector has changed from `aur-data-table` to `av-data-table`.
29
- Please update your templates accordingly.
30
- ```
25
+ The component requires Angular Material. Ensure the following are available in your environment:
26
+ - `@angular/material/card`
27
+ - `@angular/material/button`
28
+ - `@angular/material/icon`
29
+ - `@angular/material/paginator`
30
+ - `@angular/material/menu`
31
31
 
32
32
  ## Installation
33
33
 
34
- 1. Copy the component files to your Angular project
35
- 2. Import the component in your module or standalone component
36
- 3. Ensure you have Angular Material (for pagination) installed:
37
-
38
- ```bash
39
- ng add @angular/material
40
- ```
41
-
42
- ## Basic Usage
43
-
44
- ### 1. Import and Configure
45
-
46
- ```typescript
47
- import { AvDataTable } from './path/to/av-data-table';
48
-
49
- @Component({
50
- selector: 'app-example',
51
- template: `
52
- <av-data-table
53
- [TableHeaders]="headers"
54
- [TableColumns]="columns"
55
- [Data]="tableData"
56
- [PageSize]="10"
57
- [PageSizeOptions]="[5, 10, 25, 50]"
58
- [EnableActionColumn]="true"
59
- [EnableButtonDelete]="true"
60
- [EnableButtonModify]="true"
61
- (onModify)="handleModify($event)"
62
- (onItemRemoved)="handleRemove($event)"
63
- (onNewItemAdded)="handleAdd($event)">
64
- </av-data-table>
65
- `
66
- })
67
- export class ExampleComponent {
68
- // Component implementation
69
- }
70
- ```
71
-
72
- ### 2. Define Headers and Columns
73
-
74
- ```typescript
75
- export interface Headers {
76
- label: string;
77
- align?: 'left' | 'center' | 'right';
78
- }
79
-
80
- export interface Columns {
81
- field: string;
82
- align?: 'left' | 'center' | 'right';
83
- color?: string;
84
- }
85
- export class ExampleComponent {
86
- headers: Headers[] = [
87
- { label: 'Name', align: 'left' },
88
- { label: 'Email', align: 'left' },
89
- { label: 'Department', align: 'left' },
90
- { label: 'Action', align: 'center' }
91
- ];
92
-
93
- columns: Columns[] = [
94
- { field: 'name', align: 'left', color: '#3182ce' },
95
- { field: 'email', align: 'left' },
96
- { field: 'department.name', align: 'left' }, // Nested property
97
- ];
98
-
99
- tableData = [
100
- {
101
- name: 'Kasun Perera',
102
- email: 'kasun.perera@company.lk',
103
- department: { name: 'Information Technology', code: 'IT' }
104
- },
105
- {
106
- name: 'Nimali Fernando',
107
- email: 'nimali.fernando@company.lk',
108
- department: { name: 'Human Resources', code: 'HR' }
109
- },
110
- {
111
- name: 'Rajitha Silva',
112
- email: 'rajitha.silva@company.lk',
113
- department: { name: 'Finance & Accounting', code: 'FIN' }
114
- },
115
- {
116
- name: 'Chaminda Jayawardena',
117
- email: 'chaminda.j@company.lk',
118
- department: { name: 'Marketing & Sales', code: 'MKT' }
119
- }
120
- ];
121
- }
122
- ```
34
+ 1. Copy the component files into your project.
35
+ 2. Import `AvDataTable` in your standalone component or module.
36
+ 3. Add Angular Material if not already present:
37
+ ```bash
38
+ ng add @angular/material
39
+ ```
123
40
 
124
41
  ## API Reference
125
42
 
@@ -127,191 +44,69 @@ export class ExampleComponent {
127
44
 
128
45
  | Property | Type | Default | Description |
129
46
  |----------|------|---------|-------------|
130
- | `TableHeaders` | `Headers[]` | `[]` | Array of header configurations |
131
- | `TableColumns` | `Columns[]` | `[]` | Array of column configurations |
132
- | `Data` | `any[]` | `[]` | Data source for the table |
133
- | `PageSize` | `number` | `5` | Number of items per page |
134
- | `PageSizeOptions` | `number[]` | `[]` | Available page size options |
135
- | `currentPage` | `number` | `0` | Current active page index |
136
- | `EnableActionColumn` | `boolean` | `false` | Show/hide action column |
137
- | `EnableButtonDelete` | `boolean` | `false` | Enable delete button in actions |
138
- | `EnableButtonModify` | `boolean` | `false` | Enable modify button in actions |
139
- | `DisableRemove` | `boolean` | `false` | Disable remove functionality |
140
- | `DisableModify` | `boolean` | `false` | Disable modify functionality |
47
+ | `TableHeaders` | `Headers[]` | `[]` | Array of header configurations with labels and alignment. |
48
+ | `TableColumns` | `Columns[]` | `[]` | Array of column definitions with fields, alignment, and colors. |
49
+ | `Data` | `any[]` | `[]` | Data source for the table. |
50
+ | `PageSize` | `number` | `5` | Initial number of rows per page. |
51
+ | `PageSizeOptions` | `number[]` | `[]` | Available page size choices for the paginator. |
52
+ | `currentPage` | `number` | `0` | Active page index. |
53
+ | `EnableActionColumn` | `boolean` | `false` | Toggles the visibility of the action column. |
54
+ | `EnableButtonDelete` | `boolean` | `false` | Toggles the delete action button. |
55
+ | `EnableButtonModify` | `boolean` | `false` | Toggles the modify action button. |
56
+ | `DisableRemove` | `boolean` | `false` | Prevents local item removal while still emitting events. |
57
+ | `DisableModify` | `boolean` | `false` | Disables the modify button while still emitting events. |
141
58
 
142
59
  ### Output Events
143
60
 
144
- | Event | Type | Description |
145
- |-------|------|-------------|
146
- | `onModify` | `EventEmitter<{index: number, modifiedItem: any, disabled: boolean}>` | Emitted when modify button is clicked - allows custom handling like opening edit forms, viewing details, etc. |
147
- | `onItemRemoved` | `EventEmitter<{index: number, dataSize: number, removedItem: any, disabled: boolean}>` | Emitted when delete button is clicked - allows custom removal logic, confirmations, API calls, etc. |
148
- | `onNewItemAdded` | `EventEmitter<{index: number, dataSize: number, removedItem: any}>` | Emitted when new item events occur - allows custom add item logic |
61
+ | Event | Payload Type | Description |
62
+ |-------|--------------|-------------|
63
+ | `onModify` | `{index: number, modifiedItem: any, disabled: boolean}` | Emits when the modify button is clicked. |
64
+ | `onItemRemoved` | `{index: number, dataSize: number, removedItem: any, disabled: boolean}` | Emits when an item is removed via the delete button. |
65
+ | `onNewItemAdded` | `{index: number, dataSize: number}` | Emitted when internal data size changes (e.g., via sync). |
149
66
 
150
- ### Interfaces
67
+ ## Technical Implementation
151
68
 
152
- ```typescript
153
- interface Headers {
154
- label: string;
155
- align?: 'left' | 'center' | 'right';
156
- }
69
+ - **CSS Grid:** Uses a dynamically calculated `grid-template-columns` for responsive row structure.
70
+ - **Nested Property Resolution:** Recursively traverses objects using dot notation for display.
71
+ - **Data Sync:** Uses efficient reference and length verification for performance and stability.
72
+ - **Form Control:** Implements `NG_VALUE_ACCESSOR` for seamless integration with `ngModel` and `[formControl]`.
157
73
 
158
- interface Columns {
159
- field: string;
160
- align?: 'left' | 'center' | 'right';
161
- color?: string;
162
- }
163
- ```
164
-
165
- ## Advanced Usage
166
-
167
- ### Nested Object Properties
168
-
169
- The component supports accessing nested object properties using dot notation:
74
+ ## Usage Example
170
75
 
171
76
  ```typescript
172
- columns: Columns[] = [
173
- { field: 'employee.profile.firstName' },
174
- { field: 'employee.contact.address.city' },
175
- { field: 'employee.roles.name' }, // Will join array values with commas
176
- { field: 'department.name' } // Access nested department name
77
+ // Component
78
+ headers: Headers[] = [
79
+ { label: 'Name', align: 'left' },
80
+ { label: 'Role', align: 'center' }
177
81
  ];
178
- ```
179
82
 
180
- ### Reactive Forms Integration
181
-
182
- The component implements `ControlValueAccessor`, making it compatible with Angular Reactive Forms:
183
-
184
- ```typescript
185
- import { FormBuilder, FormGroup } from '@angular/forms';
186
-
187
- export class ExampleComponent {
188
- form: FormGroup;
189
-
190
- constructor(private fb: FormBuilder) {
191
- this.form = this.fb.group({
192
- tableData: [[]] // Initial empty array
193
- });
194
- }
195
- }
196
- ```
197
-
198
- ```html
199
- <form [formGroup]="form">
200
- <av-data-table
201
- formControlName="tableData"
202
- [TableHeaders]="headers"
203
- [TableColumns]="columns">
204
- </av-data-table>
205
- </form>
206
- ```
207
-
208
- ### Event Handling
209
-
210
- The component provides flexible event handlers that allow you to implement custom business logic:
211
-
212
- ```typescript
213
- handleModify(event: {index: number, modifiedItem: any, disabled: boolean}) {
214
- if (event.disabled) {
215
- console.log('Modify action is disabled');
216
- return;
217
- }
218
-
219
- // Example: Open edit dialog with the selected row data
220
- console.log('Modifying employee:', event.modifiedItem.name);
221
- console.log('Employee data:', event.modifiedItem);
222
-
223
- // You can:
224
- // - Open a modal/dialog for editing
225
- // - Navigate to an edit page
226
- // - Show detailed view
227
- // - Perform any custom logic with the row data
228
- this.openEditDialog(event.modifiedItem, event.index);
229
- }
230
-
231
- handleRemove(event: {index: number, dataSize: number, removedItem: any, disabled: boolean}) {
232
- if (event.disabled) {
233
- console.log('Remove action is disabled');
234
- return;
235
- }
236
-
237
- // Example: Custom confirmation and API call
238
- const employee = event.removedItem;
239
- const confirmed = confirm(`Are you sure you want to remove ${employee.name}?`);
240
-
241
- if (confirmed) {
242
- // You can:
243
- // - Make API calls to delete from server
244
- // - Update other related data
245
- // - Show success/error messages
246
- // - Perform cleanup operations
247
- console.log(`${employee.name} removed from ${employee.department.name}`);
248
- console.log('Remaining employees:', event.dataSize);
249
-
250
- // Example API call
251
- this.employeeService.deleteEmployee(employee.id).subscribe({
252
- next: () => console.log('Successfully deleted from server'),
253
- error: (err) => console.error('Deletion failed:', err)
254
- });
255
- }
256
- }
257
-
258
- handleAdd(event: {index: number, dataSize: number}) {
259
- // Example: Trigger add new employee flow
260
- console.log('Adding new employee...');
261
-
262
- // You can:
263
- // - Open add employee dialog
264
- // - Navigate to create page
265
- // - Show form modal
266
- // - Perform any custom add logic
267
- this.openAddEmployeeDialog();
268
- }
269
- ```
270
-
271
- ### Custom Styling
272
-
273
- The component uses CSS classes that you can override:
274
-
275
- ```css
276
- /* Header alignment */
277
- .header-text-left { text-align: left; }
278
- .header-text-center { text-align: center; }
279
- .header-text-right { text-align: right; }
83
+ columns: Columns[] = [
84
+ { field: 'profile.name', align: 'left', color: '#4361ee' },
85
+ { field: 'role', align: 'center' }
86
+ ];
280
87
 
281
- /* Data cell alignment */
282
- .text-left { text-align: left; }
283
- .text-center { text-align: center; }
284
- .text-right { text-align: right; }
88
+ data = [
89
+ { profile: { name: 'Dileesha' }, role: 'Developer' }
90
+ ];
285
91
 
286
- /* Grid layout customization */
287
- .table-grid {
288
- display: grid;
289
- gap: 1rem;
290
- /* grid-template-columns is set dynamically */
291
- }
92
+ // Template
93
+ <av-data-table
94
+ [TableHeaders]="headers"
95
+ [TableColumns]="columns"
96
+ [Data]="data"
97
+ [EnableActionColumn]="true"
98
+ (onModify)="handleModify($event)">
99
+ </av-data-table>
292
100
  ```
293
101
 
294
- ## Requirements
295
-
296
- - Angular 17+
297
- - Angular Material (for pagination component)
298
- - Modern browser with CSS Grid support
102
+ ## Authorship
299
103
 
300
- ## Browser Support
301
-
302
- - Chrome/Edge 57+
303
- - Firefox 52+
304
- - Safari 10.1+
104
+ - **Author**: Dileesha Ekanayake
105
+ - **Email**: dileesha.r.ekanayake@gmail.com
106
+ - **Created**: 2024
107
+ - **Version**: 0.0.6
108
+ - **Responsibility**: Design, implementation, and documentation of the data table component with Angular Material integration.
305
109
 
306
110
  ## License
307
111
 
308
- This project is licensed under the MIT License - see the LICENSE file for details.
309
-
310
- ## Changelog
311
-
312
- ### v0.0.4
313
- - Initial release
314
- - Basic table functionality with pagination
315
- - CRUD operations support
316
- - Reactive forms integration
317
- - Nested object property access
112
+ This project is licensed under the MIT License.
@@ -0,0 +1,10 @@
1
+ {
2
+ "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3
+ "dest": "../../dist/av-data-table",
4
+ "lib": {
5
+ "entryFile": "src/public-api.ts"
6
+ },
7
+ "allowedNonPeerDependencies": [
8
+ "@angular/material"
9
+ ]
10
+ }
package/package.json CHANGED
@@ -1,35 +1,23 @@
1
- {
2
- "name": "@avoraui/av-data-table",
3
- "version": "0.0.4",
4
- "description": "A customizable Angular Data Table component",
5
- "keywords": [
6
- "angular",
7
- "table",
8
- "data-table"
9
- ],
10
- "author": "Dileesha Ekanayake",
11
- "license": "MIT",
12
- "peerDependencies": {
13
- "@angular/common": "^20.1.0",
14
- "@angular/core": "^20.1.0"
15
- },
16
- "dependencies": {
17
- "@angular/material": "^20.1.2",
18
- "tslib": "^2.3.0"
19
- },
20
- "sideEffects": false,
21
- "publishConfig": {
22
- "access": "public"
23
- },
24
- "module": "fesm2022/avoraui-av-data-table.mjs",
25
- "typings": "index.d.ts",
26
- "exports": {
27
- "./package.json": {
28
- "default": "./package.json"
29
- },
30
- ".": {
31
- "types": "./index.d.ts",
32
- "default": "./fesm2022/avoraui-av-data-table.mjs"
33
- }
34
- }
1
+ {
2
+ "name": "@avoraui/av-data-table",
3
+ "version": "0.0.6",
4
+ "description": "A customizable Angular Data Table component",
5
+ "keywords": [
6
+ "angular",
7
+ "table",
8
+ "data-table"
9
+ ],
10
+ "author": "Dileesha Ekanayake",
11
+ "license": "MIT",
12
+ "peerDependencies": {
13
+ "@angular/common": "^20.1.0",
14
+ "@angular/core": "^20.1.0"
15
+ },
16
+ "dependencies": {
17
+ "@angular/material": "^20.1.2"
18
+ },
19
+ "sideEffects": false,
20
+ "publishConfig": {
21
+ "access": "public"
22
+ }
35
23
  }