ngx-lite-form 1.4.1 → 1.4.3

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 CHANGED
@@ -62,7 +62,7 @@ Lite Form provides 15+ form and UI components. Click on any component below for
62
62
  - **[LiteFile](docs/lite-file.md)** - File upload with drag & drop and camera capture
63
63
 
64
64
  ### Data Display & Navigation
65
- - **[LiteTable](docs/lite-table.md)** - Flexible data table with pagination and row actions
65
+ - **[LiteTable](docs/lite-table.md)** - Flexible data table with sorting, pagination, row selection, and row actions
66
66
  - **[LitePaginator](docs/lite-paginator.md)** - Standalone pagination component
67
67
 
68
68
  ### UI Components
@@ -198,12 +198,13 @@ export class AppComponent {
198
198
  showPreview: true
199
199
  });
200
200
 
201
- // Table with custom columns
201
+ // Table with custom columns, sorting, and row selection
202
202
  employeeTable = new TableFieldDto(
203
203
  [
204
- { key: 'name', label: 'Name', flex: '1' },
205
- { key: 'department', label: 'Department', flex: '0 0 150px' },
206
- { key: 'salary', label: 'Salary', flex: '0 0 120px', cellTemplate: (value) => `$${value?.toLocaleString() || '0'}` }
204
+ { key: '__select__', label: '', flex: '0 0 36px', type: 'select' },
205
+ { key: 'name', label: 'Name', flex: '1', sortable: true },
206
+ { key: 'department', label: 'Department', flex: '0 0 150px', sortable: true },
207
+ { key: 'salary', label: 'Salary', flex: '0 0 120px', sortable: true, cellTemplate: (value) => `$${value?.toLocaleString() || '0'}` }
207
208
  ],
208
209
  [
209
210
  { name: 'John Smith', department: 'Engineering', salary: 75000 },
@@ -211,17 +212,31 @@ export class AppComponent {
211
212
  ]
212
213
  );
213
214
 
214
- // Paginated table
215
+ // Paginated table with sorting
215
216
  userTable = new TableFieldDto(
216
217
  [
217
- { key: 'name', label: 'Name', flex: '1' },
218
- { key: 'email', label: 'Email', flex: '1' },
219
- { key: 'location.country', label: 'Country', flex: '0 0 120px' }
218
+ { key: 'name', label: 'Name', flex: '1', sortable: true },
219
+ { key: 'email', label: 'Email', flex: '1', sortable: true },
220
+ { key: 'location.country', label: 'Country', flex: '0 0 120px', sortable: true }
220
221
  ],
221
222
  [], // Will be populated by API
222
223
  true, // Enable pagination
223
224
  new PaginatorFieldDto(1, 100, 10) // Page 1, 100 total items, 10 per page
224
225
  );
226
+
227
+ // Handle sort changes
228
+ onTableSort(event: { column: string; direction: 'asc' | 'desc' | null }) {
229
+ this.userTable = {
230
+ ...this.userTable,
231
+ sortState: { column: event.column, direction: event.direction }
232
+ };
233
+ }
234
+
235
+ // Handle selection changes
236
+ onSelectionChange(selectedRows: any[]) {
237
+ console.log('Selected rows:', selectedRows);
238
+ // Enable bulk actions, update UI, etc.
239
+ }
225
240
 
226
241
  // Standalone paginator
227
242
  paginator = new PaginatorFieldDto(1, 500, 25);
@@ -262,16 +277,23 @@ export class AppComponent {
262
277
  <lite-file [control]="fileField"></lite-file>
263
278
  </form>
264
279
 
265
- <!-- Data Table -->
266
- <lite-table [table]="employeeTable"></lite-table>
280
+ <!-- Data Table with Sorting and Selection -->
281
+ <lite-table
282
+ [table]="employeeTable"
283
+ (sortChange)="onTableSort($event)"
284
+ (selectionChange)="onSelectionChange($event)">
285
+ </lite-table>
267
286
 
268
- <!-- Paginated Table -->
287
+ <!-- Paginated Table with Sorting -->
269
288
  <lite-table
270
289
  [table]="userTable"
271
290
  (pageChange)="onPageChange($event)"
272
- (itemsPerPageChange)="onItemsPerPageChange($event)">
291
+ (itemsPerPageChange)="onItemsPerPageChange($event)"
292
+ (sortChange)="onTableSort($event)">
273
293
  </lite-table>
274
294
 
295
+ > Sorting behavior: LiteTable performs client-side, page-level sorting. Only the currently visible page is sorted. Disable pagination to sort the full visible dataset, or sort on the server before passing data to the table if you need whole-dataset sorting across pages.
296
+
275
297
  <!-- Standalone Paginator -->
276
298
  <lite-paginator
277
299
  [paginator]="paginator"
@@ -420,20 +442,28 @@ class FileFieldDto {
420
442
  Table configuration for the LiteTable component.
421
443
 
422
444
  ```typescript
445
+ type SortDirection = 'asc' | 'desc' | null;
446
+
447
+ interface SortState {
448
+ column: string;
449
+ direction: SortDirection;
450
+ }
451
+
423
452
  class TableFieldDto<T = any> {
424
453
  columns: TableColumn[];
425
454
  data: T[];
426
455
  showPaginator?: boolean;
427
456
  paginatorConfig: PaginatorFieldDto;
457
+ sortState?: SortState; // Current sort state
428
458
  }
429
459
 
430
460
  interface TableColumn {
431
461
  key: string; // Data property key (supports dot notation)
432
462
  label: string; // Column header text
433
463
  flex?: string; // CSS flex property (e.g., '0 0 100px', '1')
434
- sortable?: boolean; // Show sorting indicator
464
+ sortable?: boolean; // Enable sorting for this column
435
465
  cellTemplate?: (value: any, row: any) => string; // Custom HTML template
436
- type?: 'text' | 'menu'; // Optional column type (default: 'text')
466
+ type?: 'text' | 'menu' | 'select'; // Optional column type (default: 'text')
437
467
  menuItems?: Array<{ label: string; value: string; variant?: 'danger' | 'default' }>; // For 'menu' type columns
438
468
  }
439
469
  ```
@@ -511,4 +541,4 @@ This project is licensed under the MIT License - see the [LICENSE](https://githu
511
541
 
512
542
  ---
513
543
  ## Changelog
514
- - See [docs/CHANGELOG.md](https://github.com/liangk/lite-form/blob/main/docs/CHANGELOG.md) for the full historical record, including the latest `v1.4.1` release with LiteDateTime selection state fix.
544
+ - See [docs/CHANGELOG.md](https://github.com/liangk/lite-form/blob/main/docs/CHANGELOG.md) for the full historical record, including the latest `v1.4.3` release with LiteTable row selection feature.