ngx-primeng-toolkit
Version:
A comprehensive TypeScript utility library for Angular component state management, PrimeNG table state management, ng-select helpers, data storage, and memoized HTTP caching. Compatible with Angular 19+ and PrimeNG 19+ (optimized for Angular 20+ and Prime
141 lines (110 loc) • 4.43 kB
Markdown
A comprehensive TypeScript utility library for Angular component state management, including PrimeNG table helpers, ng-select integration, data storage, and HTTP caching utilities with NgRx Signals. Compatible with **Angular 19+** and **PrimeNG 19+** (optimized for Angular 20+ and PrimeNG 20+).
- 🏗️ **Table State Management** - PrimeNG table helpers with lazy loading, filtering, and sorting
- 🎛️ **NgSelect Integration** - Complete ng-select lifecycle with search & pagination
- 💾 **Data Storage** - Memoized HTTP caching and component data management
- 🎛️ **Component State** - Reactive state management for UI components
- 🛠️ **Utility Functions** - Helper functions and TypeScript utility types
- 📦 **Tree-shakeable** - Import only what you need
- 🔒 **Type Safe** - Full TypeScript support with strict type checking
```bash
npm install ngx-primeng-toolkit
```
```bash
npm install @angular/common@^19.0.0 @angular/core@^19.0.0 @ngrx/signals@^19.0.0 rxjs@^7.0.0
npm install primeng@^19.0.0
npm install @ng-select/ng-select@^15.0.0
npm install zod@^3.0.0
```
```typescript
import { Component, inject } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { PrimeNgDynamicTableStateHelper } from 'ngx-primeng-toolkit';
interface User {
id: number;
name: string;
email: string;
}
@Component({
selector: 'app-user-table',
template: `
<p-table
[]="tableState.data()"
[]="true"
[]="tableState.isLoading()"
[]="tableState.totalRecords()"
[]="true"
[]="10"
(onLazyLoad)="tableState.onLazyLoad($event)">
<ng-template pTemplate="header">
<tr>
<th pSortableColumn="name">Name</th>
<th pSortableColumn="email">Email</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-user>
<tr>
<td>{{ user.name }}</td>
<td>{{ user.email }}</td>
</tr>
</ng-template>
</p-table>
`
})
export class UserTableComponent {
private httpClient = inject(HttpClient);
readonly tableState = PrimeNgDynamicTableStateHelper.create<User>({
url: '/api/users/query',
httpClient: this.httpClient
});
}
```
- **[Table State Management](./docs/table-state-management.md)** - PrimeNG table helpers with lazy loading, filtering, and sorting
- **[Data Storage](./docs/data-storage.md)** - Memoized HTTP caching and component data management
- **[Component State](./docs/component-state.md)** - Reactive state management for UI components
- **[NgSelect Integration](./docs/ng-select-integration.md)** - Complete ng-select lifecycle with search & pagination
- **[Utility Functions](./docs/utility-functions.md)** - Helper functions and TypeScript utility types
- **[Complete Examples](./docs/examples/)** - Comprehensive examples and integration patterns
- **[API Integration](./docs/table-state-management.md
- **[Best Practices](./docs/table-state-management.md
```typescript
interface ApiResponse<T> {
data: T[]; // Array of table row data
last_row: number; // Total number of records
}
```
The library maps PrimeNG filter types to backend operations:
- `contains` → `like`
- `equals` → `=`
- `startsWith` → `starts`
- `greaterThan` → `>`
- And many more...
Full generic typing for type-safe development:
```typescript
const tableState = PrimeNgDynamicTableStateHelper.create<User>({
url: '/api/users',
httpClient: this.httpClient
});
// tableState.data() is typed as Signal<User[]>
```
MIT License - see LICENSE file for details.
Contributions are welcome! Please read our contributing guidelines and submit pull requests to our GitHub repository.
For issues and questions, please use the GitHub issues page.