@den4ik92/ng2-smart-table 19.1.5 → 19.2.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.
Files changed (50) hide show
  1. package/fesm2022/den4ik92-ng2-smart-table.mjs +751 -1279
  2. package/fesm2022/den4ik92-ng2-smart-table.mjs.map +1 -1
  3. package/lib/components/cell/cell-edit-mode/build-in-editor.component.d.ts +8 -0
  4. package/lib/components/cell/cell-edit-mode/custom-edit.component.d.ts +2 -2
  5. package/lib/components/cell/cell-edit-mode/edit-cell.component.d.ts +2 -2
  6. package/lib/components/cell/cell-editors/base-editor.component.d.ts +13 -0
  7. package/lib/components/cell/cell-editors/checkbox-editor.component.d.ts +2 -2
  8. package/lib/components/cell/cell-editors/input-editor.component.d.ts +2 -3
  9. package/lib/components/cell/cell-editors/select-editor.component.d.ts +2 -3
  10. package/lib/components/cell/cell-editors/textarea-editor.component.d.ts +2 -3
  11. package/lib/components/filter/build-in-filter.component.d.ts +11 -0
  12. package/lib/components/filter/custom-filter.component.d.ts +13 -6
  13. package/lib/components/filter/filter-types/base-filter.component.d.ts +31 -0
  14. package/lib/components/filter/filter-types/checkbox-filter.component.d.ts +7 -6
  15. package/lib/components/filter/filter-types/input-filter.component.d.ts +2 -8
  16. package/lib/components/filter/filter-types/select-filter.component.d.ts +2 -7
  17. package/lib/components/filter/filter.component.d.ts +12 -7
  18. package/lib/components/pager/pager.component.d.ts +17 -32
  19. package/lib/components/table-columns-editor/column-editor.directive.d.ts +1 -1
  20. package/lib/components/tbody/cells/custom.component.d.ts +2 -2
  21. package/lib/components/tbody/cells/edit-delete.component.d.ts +2 -2
  22. package/lib/components/tbody/tbody.component.d.ts +2 -4
  23. package/lib/components/thead/cells/actions-title.component.d.ts +1 -1
  24. package/lib/components/thead/cells/actions.component.d.ts +2 -2
  25. package/lib/components/thead/cells/add-button.component.d.ts +2 -2
  26. package/lib/components/thead/cells/column-title.component.d.ts +3 -4
  27. package/lib/components/thead/cells/title/title.component.d.ts +11 -15
  28. package/lib/components/thead/rows/thead-filters-row.component.d.ts +4 -7
  29. package/lib/components/thead/rows/thead-titles-row.component.d.ts +4 -7
  30. package/lib/components/thead/thead.component.d.ts +4 -6
  31. package/lib/lib/data-set/cell.d.ts +1 -1
  32. package/lib/lib/data-set/column.d.ts +6 -12
  33. package/lib/lib/data-set/data-set.d.ts +8 -7
  34. package/lib/lib/data-set/row.d.ts +7 -8
  35. package/lib/lib/data-source/data-source.d.ts +26 -30
  36. package/lib/lib/data-source/local/local.data-source.d.ts +8 -45
  37. package/lib/lib/data-source/local/local.filter.d.ts +2 -4
  38. package/lib/lib/data-source/local/local.pager.d.ts +1 -3
  39. package/lib/lib/data-source/server/server.data-source.d.ts +25 -0
  40. package/lib/lib/grid.d.ts +12 -21
  41. package/lib/lib/interfaces/smart-table.models.d.ts +42 -27
  42. package/lib/ng2-smart-table.component.d.ts +15 -17
  43. package/package.json +1 -1
  44. package/public-api.d.ts +12 -11
  45. package/lib/components/cell/cell-edit-mode/default-edit.component.d.ts +0 -9
  46. package/lib/components/cell/cell-edit-mode/edit-cell-default.d.ts +0 -8
  47. package/lib/components/cell/cell-editors/default-editor.d.ts +0 -13
  48. package/lib/components/filter/default-filter.component.d.ts +0 -6
  49. package/lib/components/filter/filter-default.d.ts +0 -13
  50. package/lib/components/filter/filter-types/default-filter.d.ts +0 -27
@@ -1,53 +1,66 @@
1
1
  import * as i0 from '@angular/core';
2
- import { input, Component, output, Input, signal, effect, computed, inject, ElementRef, Directive, ViewContainerRef, ViewChild, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core';
2
+ import { input, Component, output, signal, effect, computed, inject, ElementRef, Directive, ViewContainerRef, ViewChild, ChangeDetectionStrategy, Input, ChangeDetectorRef, DestroyRef } from '@angular/core';
3
+ import * as i1 from '@angular/forms';
4
+ import { UntypedFormControl, FormsModule, ReactiveFormsModule } from '@angular/forms';
5
+ import { distinctUntilChanged, debounceTime, takeUntil, switchMap, map } from 'rxjs/operators';
3
6
  import { Overlay, OverlayConfig } from '@angular/cdk/overlay';
4
7
  import { ComponentPortal } from '@angular/cdk/portal';
5
8
  import { Subject } from 'rxjs';
6
- import { takeUntil, debounceTime, distinctUntilChanged, skip } from 'rxjs/operators';
7
9
  import { moveItemInArray, CdkDropList, CdkDrag, CdkDragPlaceholder } from '@angular/cdk/drag-drop';
8
- import * as i1 from '@angular/forms';
9
- import { FormsModule, UntypedFormControl, ReactiveFormsModule, NgControl } from '@angular/forms';
10
+ import { SmartTableOnChangedEventName as SmartTableOnChangedEventName$1, BaseEditorComponent as BaseEditorComponent$1 } from 'ng2-smart-table';
10
11
  import { NgComponentOutlet, NgTemplateOutlet } from '@angular/common';
12
+ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
11
13
 
12
- class DefaultEditor {
14
+ class BaseEditorComponent {
13
15
  constructor() {
14
16
  this.cell = input.required();
15
- this.inputClass = input("");
17
+ this.inputClass = input('');
16
18
  }
17
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: DefaultEditor, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
18
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.0.3", type: DefaultEditor, isStandalone: true, selector: "ng2-default-editor-base-component", inputs: { cell: { classPropertyName: "cell", publicName: "cell", isSignal: true, isRequired: true, transformFunction: null }, inputClass: { classPropertyName: "inputClass", publicName: "inputClass", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "", isInline: true }); }
19
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: BaseEditorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
20
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.0.3", type: BaseEditorComponent, isStandalone: true, selector: "ng2-editor-base-component", inputs: { cell: { classPropertyName: "cell", publicName: "cell", isSignal: true, isRequired: true, transformFunction: null }, inputClass: { classPropertyName: "inputClass", publicName: "inputClass", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: '', isInline: true }); }
19
21
  }
20
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: DefaultEditor, decorators: [{
22
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: BaseEditorComponent, decorators: [{
21
23
  type: Component,
22
- args: [{ template: "", selector: 'ng2-default-editor-base-component' }]
24
+ args: [{ template: '', selector: 'ng2-editor-base-component' }]
23
25
  }] });
24
26
 
25
- class DefaultFilter {
27
+ class BaseFilterComponent {
26
28
  constructor() {
27
29
  this.delay = 300;
28
- this.query = '';
30
+ this.query = input('');
29
31
  this.inputClass = input('');
30
32
  this.source = input.required();
31
33
  this.column = input.required();
32
34
  this.filter = output();
35
+ this.inputControl = new UntypedFormControl();
33
36
  }
34
37
  ngOnDestroy() {
35
38
  if (this.changesSubscription) {
36
39
  this.changesSubscription.unsubscribe();
37
40
  }
38
41
  }
39
- setFilter() {
40
- this.filter.emit(this.query);
42
+ ngOnInit() {
43
+ this.changesSubscription = this.inputControl.valueChanges
44
+ .pipe(distinctUntilChanged(), debounceTime(this.delay))
45
+ .subscribe((value) => {
46
+ this.setFilter(value);
47
+ });
48
+ }
49
+ ngOnChanges({ query }) {
50
+ if (query) {
51
+ this.inputControl.setValue(query.currentValue, { emitEvent: false });
52
+ }
53
+ }
54
+ setFilter(query) {
55
+ this.filter.emit(query);
41
56
  }
42
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: DefaultFilter, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
43
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.0.3", type: DefaultFilter, isStandalone: true, selector: "ng2-default-base-filter-component", inputs: { query: { classPropertyName: "query", publicName: "query", isSignal: false, isRequired: false, transformFunction: null }, inputClass: { classPropertyName: "inputClass", publicName: "inputClass", isSignal: true, isRequired: false, transformFunction: null }, source: { classPropertyName: "source", publicName: "source", isSignal: true, isRequired: true, transformFunction: null }, column: { classPropertyName: "column", publicName: "column", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { filter: "filter" }, ngImport: i0, template: '', isInline: true }); }
57
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: BaseFilterComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
58
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.0.3", type: BaseFilterComponent, isStandalone: true, selector: "ng2-base-filter-component", inputs: { query: { classPropertyName: "query", publicName: "query", isSignal: true, isRequired: false, transformFunction: null }, inputClass: { classPropertyName: "inputClass", publicName: "inputClass", isSignal: true, isRequired: false, transformFunction: null }, source: { classPropertyName: "source", publicName: "source", isSignal: true, isRequired: true, transformFunction: null }, column: { classPropertyName: "column", publicName: "column", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { filter: "filter" }, usesOnChanges: true, ngImport: i0, template: '', isInline: true }); }
44
59
  }
45
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: DefaultFilter, decorators: [{
60
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: BaseFilterComponent, decorators: [{
46
61
  type: Component,
47
- args: [{ template: '', selector: 'ng2-default-base-filter-component' }]
48
- }], propDecorators: { query: [{
49
- type: Input
50
- }] } });
62
+ args: [{ template: '', selector: 'ng2-base-filter-component' }]
63
+ }] });
51
64
 
52
65
  /**
53
66
  * Extending object that entered in first argument.
@@ -316,7 +329,7 @@ class Cell {
316
329
  return this.row;
317
330
  }
318
331
  getValue() {
319
- const prepare = this.column.getValuePrepareFunction() || this.prepareValue;
332
+ const prepare = this.column.valuePrepareFunction || this.prepareValue;
320
333
  return prepare.call(null, this.value, this.row.getData(), this);
321
334
  }
322
335
  getNotPrepareValue() {
@@ -356,36 +369,8 @@ class Column {
356
369
  this.isAddable = true;
357
370
  this.isFilterable = false;
358
371
  this.sortDirection = 'asc';
359
- this.defaultSortDirection = false;
360
372
  this.editor = false;
361
373
  this.filter = false;
362
- this.process(this.settings);
363
- }
364
- getCompareFunction() {
365
- return this.compareFunction;
366
- }
367
- getValuePrepareFunction() {
368
- return this.valuePrepareFunction;
369
- }
370
- getFilterFunction() {
371
- return this.filterFunction;
372
- }
373
- getConfig() {
374
- if (this.editor && (this.editor.type === 'checkbox' || this.editor.type === 'custom' || this.editor.type === 'list')) {
375
- return this.editor?.config;
376
- }
377
- return false;
378
- }
379
- getFilterType() {
380
- return this.filter && this.filter.type;
381
- }
382
- getFilterConfig() {
383
- if (this.filter && (this.filter.type === 'checkbox' || this.filter.type === 'custom' || this.filter.type === 'list')) {
384
- return this.filter?.config;
385
- }
386
- return false;
387
- }
388
- process(settings) {
389
374
  this.title = settings.title;
390
375
  this.class = settings.class || '';
391
376
  this.width = settings.width || '';
@@ -401,17 +386,28 @@ class Column {
401
386
  this.renderComponent = settings.renderComponent;
402
387
  }
403
388
  this.isFilterable = typeof settings.filter === 'undefined' ? true : !!settings['filter'];
404
- this.defaultSortDirection = settings?.sortDirection || false;
405
- this.isSortable = typeof settings.sort === 'undefined' ? true : settings.sort;
406
- this.isEditable = typeof settings.editable === 'undefined' ? true : settings.editable;
407
- this.isAddable = typeof settings.addable === 'undefined' ? true : settings.addable;
408
- this.sortDirection = this.prepareSortDirection();
389
+ this.isSortable = settings.sort ?? true;
390
+ this.isEditable = settings.editable ?? true;
391
+ this.isAddable = settings.addable ?? false;
392
+ this.sortDirection = settings.sortDirection || 'asc';
409
393
  this.compareFunction = settings.compareFunction;
410
394
  this.valuePrepareFunction = settings.valuePrepareFunction;
411
395
  this.filterFunction = settings.filterFunction;
412
396
  }
413
- prepareSortDirection() {
414
- return this.defaultSortDirection === 'desc' ? 'desc' : 'asc';
397
+ getEditorConfig() {
398
+ if (this.editor) {
399
+ return this.editor?.config;
400
+ }
401
+ return false;
402
+ }
403
+ getFilterType() {
404
+ return this.filter && this.filter.type;
405
+ }
406
+ getFilterConfig() {
407
+ if (this.filter) {
408
+ return this.filter?.config;
409
+ }
410
+ return false;
415
411
  }
416
412
  }
417
413
 
@@ -421,26 +417,21 @@ class Row {
421
417
  this.data = data;
422
418
  this._dataSet = _dataSet;
423
419
  this.pending = signal(false);
424
- this.isSelected = false;
425
- this.isInEditing = false;
426
- this.cells = [];
420
+ this.isSelected = signal(false);
421
+ this.isInEditing = signal(false);
422
+ this.cells = signal([]);
423
+ this.visibleCells = computed(() => this.cells().filter((cell) => !cell.getColumn().hide));
427
424
  this.process();
428
425
  }
429
426
  getCell(column) {
430
- return this.cells.find(el => el.getColumn() === column);
431
- }
432
- getCells() {
433
- return this.cells;
427
+ return this.cells().find((el) => el.getColumn() === column);
434
428
  }
435
429
  getData() {
436
430
  return this.data;
437
431
  }
438
- getIsSelected() {
439
- return this.isSelected;
440
- }
441
432
  getNewData() {
442
433
  const values = Object.assign({}, this.data);
443
- this.getCells().forEach((cell) => values[cell.getColumn().id] = cell.newValue);
434
+ this.cells().forEach((cell) => (values[cell.getColumn().id] = cell.newValue));
444
435
  return values;
445
436
  }
446
437
  setData(data) {
@@ -448,15 +439,15 @@ class Row {
448
439
  this.process();
449
440
  }
450
441
  process() {
451
- this.cells = [];
452
- this._dataSet.getColumns().forEach((column) => {
453
- const cell = this.createCell(column);
454
- this.cells.push(cell);
455
- });
442
+ const cells = this._dataSet
443
+ .getColumns()
444
+ .map((column) => this.createCell(column));
445
+ this.cells.set(cells);
456
446
  }
457
447
  createCell(column) {
458
- const defValue = column.settings.defaultValue ? column.settings.defaultValue : '';
459
- const value = typeof this.data[column.id] === 'undefined' ? defValue : this.data[column.id];
448
+ const value = typeof this.data[column.id] === "undefined"
449
+ ? ""
450
+ : this.data[column.id];
460
451
  return new Cell(value, this, column, this._dataSet);
461
452
  }
462
453
  }
@@ -473,117 +464,161 @@ var SmartTableOnChangedEventName;
473
464
  SmartTableOnChangedEventName["add"] = "add";
474
465
  SmartTableOnChangedEventName["remove"] = "remove";
475
466
  SmartTableOnChangedEventName["append"] = "append";
467
+ SmartTableOnChangedEventName["appendMany"] = "appendMany";
476
468
  SmartTableOnChangedEventName["prepend"] = "prepend";
477
469
  SmartTableOnChangedEventName["refresh"] = "refresh";
470
+ SmartTableOnChangedEventName["columnRefresh"] = "columnRefresh";
478
471
  })(SmartTableOnChangedEventName || (SmartTableOnChangedEventName = {}));
479
472
 
480
473
  class DataSource {
481
474
  constructor() {
482
475
  this.onChangedSource = new Subject();
483
- this.onAddedSource = new Subject();
484
- this.onUpdatedSource = new Subject();
485
- this.onRemovedSource = new Subject();
476
+ this.sortConf = { field: '', direction: 'asc' };
477
+ this.filters = [];
478
+ this.pagingConf = signal({
479
+ page: 1,
480
+ perPage: 100,
481
+ total: 0,
482
+ display: false,
483
+ perPageSelect: [],
484
+ });
485
+ this.data = [];
486
486
  }
487
487
  refresh() {
488
- this.emitOnChanged(SmartTableOnChangedEventName.refresh);
488
+ this.emitOnChanged({ action: SmartTableOnChangedEventName.refresh });
489
489
  }
490
- loadEmit() {
491
- this.emitOnChanged(SmartTableOnChangedEventName.load);
492
- return Promise.resolve(true);
490
+ columnRefresh() {
491
+ this.emitOnChanged({ action: SmartTableOnChangedEventName.columnRefresh });
493
492
  }
494
493
  onChanged() {
495
494
  return this.onChangedSource.asObservable();
496
495
  }
497
- onAdded() {
498
- return this.onAddedSource.asObservable();
499
- }
500
- onUpdated() {
501
- return this.onUpdatedSource.asObservable();
502
- }
503
- onRemoved() {
504
- return this.onRemovedSource.asObservable();
505
- }
506
- prependEmit(element) {
507
- this.emitOnAdded(element);
508
- this.emitOnChanged(SmartTableOnChangedEventName.prepend);
496
+ prepend(element) {
497
+ this.data.unshift(element);
498
+ this.emitOnChanged({ action: SmartTableOnChangedEventName.prepend, newItems: [element] });
509
499
  return Promise.resolve(true);
510
500
  }
511
- appendEmit(element) {
512
- this.emitOnAdded(element);
513
- this.emitOnChanged(SmartTableOnChangedEventName.append);
501
+ appendMany(elements) {
502
+ this.data = [...this.data, ...elements];
503
+ this.emitOnChanged({ action: SmartTableOnChangedEventName.appendMany, newItems: elements }, this.data);
514
504
  return Promise.resolve(true);
515
505
  }
516
- addEmit(element) {
517
- this.emitOnAdded(element);
518
- this.emitOnChanged(SmartTableOnChangedEventName.add);
506
+ append(element) {
507
+ this.data.push(element);
508
+ this.emitOnChanged({ action: SmartTableOnChangedEventName.append, newItems: [element] });
519
509
  return Promise.resolve(true);
520
510
  }
521
- removeEmit(element) {
522
- this.emitOnRemoved(element);
523
- this.emitOnChanged(SmartTableOnChangedEventName.remove);
511
+ add(element) {
512
+ this.data.push(element);
513
+ this.emitOnChanged({ action: SmartTableOnChangedEventName.add, newItems: [element] });
524
514
  return Promise.resolve(true);
525
515
  }
526
- updateEmit(element) {
527
- this.emitOnUpdated(element);
528
- this.emitOnChanged(SmartTableOnChangedEventName.update);
516
+ remove(element) {
517
+ this.data = this.data.filter((el) => el !== element);
518
+ this.emitOnChanged({ action: SmartTableOnChangedEventName.remove, item: element }, this.data);
529
519
  return Promise.resolve(true);
530
520
  }
531
- emptyEmit() {
532
- this.emitOnChanged(SmartTableOnChangedEventName.empty);
521
+ update(oldItem, newItem) {
522
+ this.emitOnChanged({ action: SmartTableOnChangedEventName.update, oldItem, newItem });
533
523
  return Promise.resolve(true);
534
524
  }
535
- setSortEmit() {
536
- this.emitOnChanged(SmartTableOnChangedEventName.sort);
537
- }
538
- setFilterEmit() {
539
- this.emitOnChanged(SmartTableOnChangedEventName.filter);
540
- }
541
- addFilterEmit() {
542
- this.emitOnChanged(SmartTableOnChangedEventName.filter);
543
- }
544
- setPagingEmit() {
545
- this.emitOnChanged(SmartTableOnChangedEventName.paging);
525
+ empty() {
526
+ this.data = [];
527
+ this.emitOnChanged({ action: SmartTableOnChangedEventName.empty });
528
+ return Promise.resolve(true);
546
529
  }
547
- setPageEmit() {
548
- this.emitOnChanged(SmartTableOnChangedEventName.page);
530
+ setSort(conf, doEmit = true) {
531
+ this.sortConf = conf;
532
+ this.pagingConf.update((old) => ({ ...old, page: 1 }));
533
+ if (doEmit) {
534
+ this.emitOnChanged({ action: SmartTableOnChangedEventName.sort });
535
+ }
549
536
  }
550
- emitOnRemoved(element) {
551
- this.onRemovedSource.next(element);
537
+ addFilter(newFilter, doEmit = true) {
538
+ if (!newFilter.field) {
539
+ return;
540
+ }
541
+ const foundIndex = this.filters.findIndex((filter) => filter.field === newFilter.field);
542
+ if (foundIndex === -1) {
543
+ if (newFilter.search) {
544
+ this.filters.push(newFilter);
545
+ }
546
+ }
547
+ else {
548
+ if (newFilter.search) {
549
+ this.filters[foundIndex].search = newFilter.search;
550
+ }
551
+ else {
552
+ this.filters.splice(foundIndex, 1);
553
+ }
554
+ }
555
+ this.pagingConf.update((old) => ({ ...old, page: 1 }));
556
+ if (doEmit) {
557
+ this.emitOnChanged({ action: SmartTableOnChangedEventName.filter });
558
+ }
552
559
  }
553
- emitOnUpdated(element) {
554
- this.onUpdatedSource.next(element);
560
+ setFilters(newFilters, doEmit = true) {
561
+ this.filters = [...newFilters];
562
+ this.pagingConf.update((old) => ({ ...old, page: 1 }));
563
+ if (doEmit) {
564
+ this.emitOnChanged({ action: SmartTableOnChangedEventName.filter });
565
+ }
555
566
  }
556
- emitOnAdded(element) {
557
- this.onAddedSource.next(element);
567
+ setPaging(page = 1, perPage, doEmit = true) {
568
+ this.pagingConf.update((old) => ({ ...old, page: page, perPage: perPage }));
569
+ if (doEmit) {
570
+ this.emitOnChanged({ action: SmartTableOnChangedEventName.paging });
571
+ }
558
572
  }
559
- emitOnChanged(action) {
560
- this.getElements().then((elements) => this.onChangedSource.next({
561
- action: action,
562
- elements: elements,
563
- paging: this.getPaging(),
564
- filter: this.getFilter(),
565
- sort: this.getSort(),
566
- }));
573
+ setPage(page, doEmit = true) {
574
+ this.pagingConf.update((old) => ({ ...old, page: page }));
575
+ if (doEmit) {
576
+ this.emitOnChanged({ action: SmartTableOnChangedEventName.page });
577
+ }
578
+ }
579
+ emitOnChanged(eventData, newElements) {
580
+ const actionData = () => {
581
+ const elements = newElements || this.data;
582
+ const emitData = {
583
+ ...eventData,
584
+ elements,
585
+ paging: this.pagingConf(),
586
+ filters: this.getFilters(),
587
+ sort: this.getSort(),
588
+ };
589
+ if (eventData.action === SmartTableOnChangedEventName.remove) {
590
+ return {
591
+ ...emitData,
592
+ elements: elements.filter((el) => el !== eventData.item),
593
+ };
594
+ }
595
+ return emitData;
596
+ };
597
+ this.onChangedSource.next(actionData());
567
598
  }
568
599
  }
569
600
 
570
601
  function filterValues(value, search) {
571
602
  return value.toString().toLowerCase().includes(search.toString().toLowerCase());
572
603
  }
573
- class LocalFilter {
574
- static filter(data, field, search, customFilter) {
575
- const filter = customFilter ? customFilter : filterValues;
576
- return data.filter((el) => {
577
- const value = typeof el[field] === 'undefined' || el[field] === null ? '' : el[field];
578
- return filter.call(null, value, search);
579
- });
580
- }
604
+ function isElementSatisfied(element, filters) {
605
+ return filters.every((filter) => {
606
+ if (!filter.search?.length) {
607
+ return true;
608
+ }
609
+ const filterFunction = filter.filter || filterValues;
610
+ try {
611
+ const value = element[filter.field];
612
+ return filterFunction(value, filter.search);
613
+ }
614
+ catch {
615
+ return false;
616
+ }
617
+ });
581
618
  }
582
619
 
583
- class LocalPager {
584
- static paginate(data, page, perPage) {
585
- return data.slice(perPage * (page - 1), perPage * page);
586
- }
620
+ function paginateList(data, page, perPage) {
621
+ return [...data].slice(perPage * (page - 1), perPage * page);
587
622
  }
588
623
 
589
624
  function compareValues(direction, a, b) {
@@ -608,66 +643,26 @@ class LocalSorter {
608
643
  class LocalDataSource extends DataSource {
609
644
  constructor(data = []) {
610
645
  super();
611
- this.data = [];
612
- this.filteredAndSorted = [];
613
- this.sortConf = [];
614
- this.filterConf = {
615
- filters: [],
616
- andOperator: true,
617
- };
618
- this.pagingConf = false;
646
+ this.filteredAndSorted = signal([]);
647
+ this.count = computed(() => this.filteredAndSorted().length);
619
648
  this.data = data;
620
649
  }
621
650
  load(data) {
622
651
  this.data = data;
623
- return super.loadEmit();
652
+ this.emitOnChanged({ action: SmartTableOnChangedEventName.load });
653
+ return Promise.resolve(true);
624
654
  }
625
655
  prepend(element) {
626
656
  this.reset(true);
627
- this.data.unshift(element);
628
- return super.prependEmit(element);
657
+ return super.prepend(element);
629
658
  }
630
659
  appendMany(elements) {
631
660
  this.reset(true);
632
- this.data = [...this.data, ...elements];
633
- return super.loadEmit();
661
+ return super.appendMany(elements);
634
662
  }
635
663
  append(element) {
636
664
  this.reset(true);
637
- this.data.push(element);
638
- return super.appendEmit(element);
639
- }
640
- add(element) {
641
- this.data.push(element);
642
- return super.addEmit(element);
643
- }
644
- remove(element) {
645
- this.data = this.data.filter(el => el !== element);
646
- return super.removeEmit(element);
647
- }
648
- update(element, values) {
649
- return new Promise((resolve, reject) => {
650
- this.find(element).then((found) => {
651
- found = deepExtend(found, values);
652
- super.updateEmit(found).then(resolve).catch(reject);
653
- }).catch(reject);
654
- });
655
- }
656
- find(element) {
657
- const found = this.data.find(el => el === element);
658
- if (found) {
659
- return Promise.resolve(found);
660
- }
661
- return Promise.reject(new Error('Element was not found in the dataset'));
662
- }
663
- getElements() {
664
- const data = this.data.slice(0);
665
- return Promise.resolve(this.prepareData(data));
666
- }
667
- getFilteredAndSorted() {
668
- const data = this.data.slice(0);
669
- this.prepareData(data);
670
- return Promise.resolve(this.filteredAndSorted);
665
+ return super.append(element);
671
666
  }
672
667
  getAll() {
673
668
  const data = this.data.slice(0);
@@ -675,552 +670,183 @@ class LocalDataSource extends DataSource {
675
670
  }
676
671
  reset(silent = false) {
677
672
  if (silent) {
678
- this.filterConf = {
679
- filters: [],
680
- andOperator: true,
681
- };
682
- this.sortConf = [];
683
- if (this.pagingConf) {
684
- this.pagingConf.page = 1;
685
- }
673
+ this.filters = [];
674
+ this.sortConf = { field: '', direction: 'asc' };
675
+ this.pagingConf.update((old) => ({ ...old, page: 1 }));
686
676
  }
687
677
  else {
688
- this.setFilter([], true, false);
689
- this.setSort([], false);
690
- if (this.pagingConf) {
678
+ this.setFilters([], false);
679
+ this.setSort({ field: '', direction: 'asc' }, false);
680
+ if (this.pagingConf().display) {
691
681
  this.setPage(1);
692
682
  }
693
683
  }
694
684
  }
695
- empty() {
696
- this.data = [];
697
- return super.emptyEmit();
698
- }
699
- count() {
700
- return this.filteredAndSorted.length;
701
- }
702
- /**
703
- *
704
- * Array of conf objects
705
- * [
706
- * {field: string, direction: asc|desc|null, compare: Function|null},
707
- * ]
708
- * @param conf
709
- * @param doEmit
710
- * @returns {LocalDataSource}
711
- */
712
- setSort(conf, doEmit = true) {
713
- if (conf !== null) {
714
- conf.forEach((fieldConf) => {
715
- if (!fieldConf.field || typeof fieldConf.direction === 'undefined') {
716
- throw new Error('Sort configuration object is not valid');
717
- }
718
- });
719
- this.sortConf = conf;
720
- }
721
- if (doEmit) {
722
- super.setSortEmit();
723
- }
724
- return this;
725
- }
726
- /**
727
- *
728
- * Array of conf objects
729
- * [
730
- * {field: string, search: string, filter: Function|null},
731
- * ]
732
- * @param conf
733
- * @param andOperator
734
- * @param doEmit
735
- * @returns {LocalDataSource}
736
- */
737
- setFilter(conf, andOperator = true, doEmit = true) {
738
- if (conf && conf.length > 0) {
739
- conf.forEach((fieldConf) => {
740
- this.addFilter(fieldConf, andOperator, false);
741
- });
742
- }
743
- else {
744
- this.filterConf = {
745
- filters: [],
746
- andOperator: true,
747
- };
748
- }
749
- this.filterConf.andOperator = andOperator;
750
- if (this.pagingConf) {
751
- this.pagingConf.page = 1;
752
- }
753
- if (doEmit) {
754
- super.setFilterEmit();
755
- }
756
- return this;
685
+ getSort() {
686
+ return this.sortConf;
757
687
  }
758
- addFilter(fieldConf, andOperator = true, doEmit = true) {
759
- if (!fieldConf.field || typeof fieldConf.search === 'undefined') {
760
- throw new Error('Filter configuration object is not valid');
761
- }
762
- let found = false;
763
- this.filterConf.filters.forEach((currentFieldConf, index) => {
764
- if (currentFieldConf.field === fieldConf.field) {
765
- this.filterConf.filters[index] = fieldConf;
766
- found = true;
767
- }
768
- });
769
- if (!found) {
770
- this.filterConf.filters.push(fieldConf);
771
- }
772
- this.filterConf.andOperator = andOperator;
773
- if (doEmit) {
774
- super.addFilterEmit();
775
- }
776
- return this;
688
+ getFilters() {
689
+ return this.filters;
777
690
  }
778
- setPaging(page = 1, perPage, doEmit = true) {
779
- if (this.pagingConf) {
780
- this.pagingConf.page = page;
781
- this.pagingConf.perPage = perPage;
782
- }
783
- else {
784
- this.pagingConf = {
785
- page, perPage
786
- };
691
+ emitOnChanged(event) {
692
+ let renderData = this.filteredAndSorted();
693
+ const action = event.action;
694
+ if (['filter', 'refresh', 'load'].includes(action)) {
695
+ renderData = this.filter(this.data.slice(0));
696
+ this.filteredAndSorted.set(this.sort(renderData));
697
+ renderData = this.filteredAndSorted();
787
698
  }
788
- if (doEmit) {
789
- super.setPagingEmit();
699
+ if (['sort', 'filter', 'refresh', 'load'].includes(action)) {
700
+ this.filteredAndSorted.update((list) => this.sort(list));
701
+ renderData = this.filteredAndSorted();
790
702
  }
791
- return;
792
- }
793
- setPage(page, doEmit = true) {
794
- if (!this.pagingConf) {
795
- return;
796
- }
797
- this.pagingConf.page = page;
798
- if (doEmit) {
799
- super.setPageEmit();
703
+ if (this.pagingConf().display &&
704
+ ['page', 'paging', 'refresh', 'load', 'sort', 'filter'].includes(action)) {
705
+ renderData = this.paginate(this.filteredAndSorted());
800
706
  }
801
- return;
802
- }
803
- getSort() {
804
- return this.sortConf;
805
- }
806
- getFilter() {
807
- return this.filterConf;
808
- }
809
- getPaging() {
810
- return this.pagingConf;
811
- }
812
- prepareData(data) {
813
- data = this.filter(data);
814
- data = this.sort(data);
815
- this.filteredAndSorted = data.slice(0);
816
- if (this.pagingConf) {
817
- return this.paginate(data);
707
+ super.emitOnChanged(event, renderData);
708
+ if (this.pagingConf().display && this.isPageOutOfBounce()) {
709
+ this.setPage(this.pagingConf().page - 1);
818
710
  }
819
- else
820
- return data;
821
711
  }
822
712
  sort(data) {
823
713
  if (this.sortConf) {
824
- this.sortConf.forEach((fieldConf) => {
825
- data = LocalSorter
826
- .sort(data, fieldConf.field, fieldConf.direction, fieldConf.compare);
827
- });
714
+ data = LocalSorter.sort(data, this.sortConf.field, this.sortConf.direction, this.sortConf.compare);
828
715
  }
829
716
  return data;
830
717
  }
831
- // TODO: refactor?
832
718
  filter(data) {
833
- if (this.filterConf.filters) {
834
- if (this.filterConf.andOperator) {
835
- this.filterConf.filters.forEach((fieldConf) => {
836
- if (fieldConf.search?.length > 0) {
837
- data = LocalFilter
838
- .filter(data, fieldConf.field, fieldConf.search, fieldConf.filter);
839
- }
840
- });
841
- }
842
- else {
843
- let mergedData = [];
844
- this.filterConf.filters.forEach((fieldConf) => {
845
- if (fieldConf.search?.length > 0) {
846
- mergedData = mergedData.concat(LocalFilter
847
- .filter(data, fieldConf.field, fieldConf.search, fieldConf.filter));
848
- }
849
- });
850
- // remove non unique items
851
- data = mergedData.filter((elem, pos, arr) => {
852
- return arr.indexOf(elem) === pos;
853
- });
854
- }
719
+ if (this.filters.length > 0) {
720
+ return data.filter((item) => {
721
+ return isElementSatisfied(item, this.filters);
722
+ });
855
723
  }
856
724
  return data;
857
725
  }
858
726
  paginate(data) {
859
- if (this.pagingConf && this.pagingConf.page && this.pagingConf.perPage) {
860
- data = LocalPager.paginate(data, this.pagingConf.page, this.pagingConf.perPage);
727
+ if (this.pagingConf().display) {
728
+ return paginateList(data, this.pagingConf().page, this.pagingConf().perPage);
861
729
  }
862
730
  return data;
863
731
  }
732
+ isPageOutOfBounce() {
733
+ const { page, perPage } = this.pagingConf();
734
+ return page * perPage >= this.count() + perPage && page > 1;
735
+ }
864
736
  }
865
737
 
866
- class PagerComponent {
867
- constructor() {
868
- this.perPageSelect = [];
869
- this.changePage = output();
870
- this.currentPerPage = 0;
871
- this.pages = [];
872
- this.page = 1;
873
- this.count = 0;
874
- this.perPage = 0;
738
+ class ServerDataSource extends DataSource {
739
+ constructor(paramPrepareFunction, requestFunction, initPagingConf) {
740
+ super();
741
+ this.initPagingConf = initPagingConf;
742
+ this.count = computed(() => this.pagingConf().total);
743
+ this.pagingConf.update((old) => ({ ...old, ...this.initPagingConf }));
744
+ this.paramPrepareFunction = paramPrepareFunction;
745
+ this.requestFunction = requestFunction;
875
746
  }
876
- ngOnChanges(changes) {
877
- if (changes["source"]) {
878
- if (!changes["source"].firstChange && this.dataChangedSub) {
879
- this.dataChangedSub.unsubscribe();
880
- }
881
- this.dataChangedSub = this.source.onChanged().subscribe((dataChanges) => {
882
- const paging = this.source.getPaging();
883
- if (paging) {
884
- this.page = paging.page;
885
- this.perPage = paging.perPage;
886
- }
887
- this.currentPerPage = this.perPage;
888
- this.count = this.source.count();
889
- if (this.isPageOutOfBounce()) {
890
- this.source.setPage(--this.page);
891
- }
892
- this.processPageChange(dataChanges);
893
- this.initPages();
894
- });
895
- }
747
+ getAll() {
748
+ return Promise.resolve(this.data);
896
749
  }
897
- /**
898
- * We change the page here depending on the action performed against data source
899
- * if a new element was added to the end of the table - then change the page to the last
900
- * if a new element was added to the beginning of the table - then to the first page
901
- * @param changes
902
- */
903
- processPageChange(changes) {
904
- if (changes["action"] === "prepend") {
905
- this.source.setPage(1);
750
+ getSort() {
751
+ return this.sortConf;
752
+ }
753
+ getFilters() {
754
+ return this.filters;
755
+ }
756
+ emitOnChanged(eventData, newElements) {
757
+ if ([
758
+ SmartTableOnChangedEventName$1.filter,
759
+ SmartTableOnChangedEventName$1.sort,
760
+ SmartTableOnChangedEventName$1.page,
761
+ SmartTableOnChangedEventName$1.paging,
762
+ SmartTableOnChangedEventName$1.refresh,
763
+ ].includes(eventData.action)) {
764
+ this.paramPrepareFunction({
765
+ sort: this.sortConf,
766
+ filters: this.filters,
767
+ page: this.pagingConf().page,
768
+ limit: this.pagingConf().perPage,
769
+ })
770
+ .pipe(switchMap((params) => this.requestFunction(params)))
771
+ .subscribe((res) => {
772
+ this.data = res.data;
773
+ this.pagingConf.update((old) => ({ ...old, total: res.total }));
774
+ super.emitOnChanged(eventData, res.data);
775
+ });
906
776
  }
907
- if (changes["action"] === "append") {
908
- this.source.setPage(this.getLast());
777
+ else {
778
+ super.emitOnChanged(eventData, newElements);
909
779
  }
910
780
  }
911
- shouldShow() {
912
- return this.source.count() > this.perPage;
781
+ }
782
+
783
+ class PagerComponent {
784
+ constructor() {
785
+ this.source = input.required();
786
+ this.pagingConf = computed(() => this.source().pagingConf());
787
+ this.currentPerPage = computed(() => this.pagingConf().perPage);
788
+ this.currentPage = computed(() => this.pagingConf().page);
789
+ this.count = computed(() => this.source().count());
790
+ this.shouldShow = computed(() => this.pagingConf().display && this.count() > this.currentPerPage());
791
+ this.lastPage = computed(() => Math.ceil(this.count() / this.currentPerPage()));
792
+ this.pages = computed(() => this.getPages(this.currentPage(), this.lastPage()));
913
793
  }
914
794
  paginate(page) {
915
- this.source.setPage(page);
916
- this.page = page;
917
- this.changePage.emit({ page });
918
- return false;
795
+ this.source().setPage(page);
919
796
  }
920
797
  next() {
921
- return this.paginate(this.getPage() + 1);
798
+ this.paginate(this.currentPage() + 1);
922
799
  }
923
800
  prev() {
924
- return this.paginate(this.getPage() - 1);
925
- }
926
- getPage() {
927
- return this.page;
928
- }
929
- getPages() {
930
- return this.pages;
801
+ this.paginate(this.currentPage() - 1);
931
802
  }
932
- getLast() {
933
- return Math.ceil(this.count / this.perPage);
803
+ isString(value) {
804
+ return typeof value === 'string';
934
805
  }
935
- isPageOutOfBounce() {
936
- return (this.page * this.perPage >= this.count + this.perPage && this.page > 1);
937
- }
938
- initPages() {
939
- const pagesCount = this.getLast();
940
- let showPagesCount = 4;
941
- showPagesCount = pagesCount < showPagesCount ? pagesCount : showPagesCount;
942
- this.pages = [];
943
- if (this.shouldShow()) {
944
- let middleOne = Math.ceil(showPagesCount / 2);
945
- middleOne = this.page >= middleOne ? this.page : middleOne;
946
- let lastOne = middleOne + Math.floor(showPagesCount / 2);
947
- lastOne = lastOne >= pagesCount ? pagesCount : lastOne;
948
- const firstOne = lastOne - showPagesCount + 1;
949
- for (let i = firstOne; i <= lastOne; i++) {
950
- this.pages.push(i);
806
+ getPages(current, last) {
807
+ const delta = 2, left = current - delta, right = current + delta + 1, range = [], rangeWithDots = [];
808
+ let l;
809
+ for (let i = 1; i <= last; i++) {
810
+ if (i == 1 || i == last || (i >= left && i < right)) {
811
+ range.push(i);
951
812
  }
952
813
  }
953
- }
954
- onChangePerPage() {
955
- const paging = this.source.getPaging();
956
- if (paging) {
957
- paging.perPage = this.currentPerPage * 1;
814
+ for (const i of range) {
815
+ if (l) {
816
+ if (i - l === 2) {
817
+ rangeWithDots.push(l + 1);
818
+ }
819
+ else if (i - l !== 1) {
820
+ rangeWithDots.push('...');
821
+ }
822
+ }
823
+ rangeWithDots.push(i);
824
+ l = i;
958
825
  }
959
- this.source.refresh();
960
- this.initPages();
826
+ return rangeWithDots;
961
827
  }
962
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: PagerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
963
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.3", type: PagerComponent, isStandalone: true, selector: "ng2-smart-table-pager", inputs: { source: "source", perPageSelect: "perPageSelect" }, outputs: { changePage: "changePage" }, usesOnChanges: true, ngImport: i0, template: `
964
- @if (shouldShow()) {
965
- <nav class="ng2-smart-pagination-nav">
966
- <ul class="ng2-smart-pagination pagination">
967
- <li
968
- class="ng2-smart-page-item page-item"
969
- [class.disabled]="getPage() === 1"
970
- >
971
- <a
972
- class="ng2-smart-page-link page-link"
973
- href="#"
974
- (click)="getPage() === 1 ? false : paginate(1)"
975
- aria-label="First"
976
- >
977
- <span aria-hidden="true">&laquo;</span>
978
- <span class="sr-only">First</span>
979
- </a>
980
- </li>
981
- <li
982
- class="ng2-smart-page-item page-item"
983
- [class.disabled]="getPage() === 1"
984
- >
985
- <a
986
- class="ng2-smart-page-link page-link page-link-prev"
987
- href="#"
988
- (click)="getPage() === 1 ? false : prev()"
989
- aria-label="Prev"
990
- >
991
- <span aria-hidden="true">&lt;</span>
992
- <span class="sr-only">Prev</span>
993
- </a>
994
- </li>
995
- @for (page of getPages(); track page) {
996
- <li
997
- class="ng2-smart-page-item page-item"
998
- [class.active]="getPage() === page"
999
- >
1000
- @if (getPage() === page) {
1001
- <span class="ng2-smart-page-link page-link"
1002
- >{{ page }} <span class="sr-only">(current)</span></span
1003
- >
1004
- } @if (getPage() !== page) {
1005
- <a
1006
- class="ng2-smart-page-link page-link"
1007
- href="#"
1008
- (click)="paginate(page)"
1009
- >{{ page }}</a
1010
- >
1011
- }
1012
- </li>
1013
- }
1014
- <li
1015
- class="ng2-smart-page-item page-item"
1016
- [class.disabled]="getPage() === getLast()"
1017
- >
1018
- <a
1019
- class="ng2-smart-page-link page-link page-link-next"
1020
- href="#"
1021
- (click)="getPage() === getLast() ? false : next()"
1022
- aria-label="Next"
1023
- >
1024
- <span aria-hidden="true">&gt;</span>
1025
- <span class="sr-only">Next</span>
1026
- </a>
1027
- </li>
1028
- <li
1029
- class="ng2-smart-page-item page-item"
1030
- [class.disabled]="getPage() === getLast()"
1031
- >
1032
- <a
1033
- class="ng2-smart-page-link page-link"
1034
- href="#"
1035
- (click)="getPage() === getLast() ? false : paginate(getLast())"
1036
- aria-label="Last"
1037
- >
1038
- <span aria-hidden="true">&raquo;</span>
1039
- <span class="sr-only">Last</span>
1040
- </a>
1041
- </li>
1042
- </ul>
1043
- </nav>
1044
- } @if (perPageSelect && perPageSelect.length > 0) {
1045
- <nav class="ng2-smart-pagination-per-page">
1046
- <label for="per-page"> Per Page: </label>
1047
- <select
1048
- (change)="onChangePerPage()"
1049
- [(ngModel)]="currentPerPage"
1050
- id="per-page"
1051
- >
1052
- @for (item of perPageSelect; track $index) {
1053
- <option [value]="item">{{ item }}</option>
828
+ onChangePerPage(target) {
829
+ if (!target.value) {
830
+ return;
1054
831
  }
1055
- </select>
1056
- </nav>
832
+ this.source().setPaging(1, +target.value);
1057
833
  }
1058
- `, isInline: true, styles: [".ng2-smart-pagination{display:inline-flex;font-size:.875em;padding:0}.ng2-smart-pagination .sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}.ng2-smart-pagination .ng2-smart-page-item{display:inline}.ng2-smart-pagination .page-link-next,.ng2-smart-pagination .page-link-prev{font-size:10px}:host{display:flex;justify-content:space-between}:host select{margin:1rem 0 1rem 1rem}:host label{margin:1rem 0 1rem 1rem;line-height:2.5rem}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }] }); }
834
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: PagerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
835
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.3", type: PagerComponent, isStandalone: true, selector: "ng2-smart-table-pager", inputs: { source: { classPropertyName: "source", publicName: "source", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: "@if (shouldShow()) {\n<div class=\"ng2-smart-pagination-wrap\">\n @if ((pagingConf().perPageSelect?.length || 0) > 0) {\n <div></div>\n }\n <nav class=\"ng2-smart-pagination-nav\">\n <ul class=\"ng2-smart-pagination pagination\">\n <li class=\"ng2-smart-page-item page-item\" [class.disabled]=\"currentPage() === 1\">\n <a\n class=\"ng2-smart-page-link page-link\"\n href=\"#\"\n (click)=\"currentPage() === 1 ? false : paginate(1)\"\n aria-label=\"First\">\n <span aria-hidden=\"true\">&laquo;</span>\n </a>\n </li>\n <li class=\"ng2-smart-page-item page-item\" [class.disabled]=\"currentPage() === 1\">\n <a\n class=\"ng2-smart-page-link page-link page-link-prev\"\n href=\"#\"\n (click)=\"currentPage() === 1 ? false : prev()\"\n aria-label=\"Prev\">\n <span aria-hidden=\"true\">&lt;</span>\n </a>\n </li>\n @for (page of pages(); track $index) {\n <li class=\"ng2-smart-page-item page-item\" [class.active]=\"currentPage() === page\">\n @if (currentPage() === page || isString(page)) {\n <span class=\"ng2-smart-page-link page-link\">{{ page }}</span>\n } @else {\n <a class=\"ng2-smart-page-link page-link\" href=\"#\" (click)=\"paginate(page)\">{{ page }}</a>\n }\n </li>\n }\n <li class=\"ng2-smart-page-item page-item\" [class.disabled]=\"currentPage() === lastPage()\">\n <a\n class=\"ng2-smart-page-link page-link page-link-next\"\n href=\"#\"\n (click)=\"currentPage() === lastPage() ? false : next()\"\n aria-label=\"Next\">\n <span aria-hidden=\"true\">&gt;</span>\n </a>\n </li>\n <li class=\"ng2-smart-page-item page-item\" [class.disabled]=\"currentPage() === lastPage()\">\n <a\n class=\"ng2-smart-page-link page-link\"\n href=\"#\"\n (click)=\"currentPage() === lastPage() ? false : paginate(lastPage())\"\n aria-label=\"Last\">\n <span aria-hidden=\"true\">&raquo;</span>\n </a>\n </li>\n </ul>\n </nav>\n @if ((pagingConf().perPageSelect?.length || 0) > 0) {\n <nav class=\"ng2-smart-pagination-per-page\">\n <label for=\"per-page\"> Per Page: </label>\n <select (change)=\"onChangePerPage($any($event.target))\" [ngModel]=\"currentPerPage()\" id=\"per-page\">\n @for (item of pagingConf().perPageSelect; track $index) {\n <option [value]=\"item\">{{ item }}</option>\n }\n </select>\n </nav>\n }\n</div>\n\n}\n", styles: [".ng2-smart-pagination{display:inline-flex;align-items:center;font-size:.875em;padding:0}.ng2-smart-pagination .ng2-smart-page-item{display:inline;padding:.2rem}.ng2-smart-pagination .page-link-next,.ng2-smart-pagination .page-link-prev{font-size:10px}.ng2-smart-pagination-nav{margin:0 auto}.ng2-smart-pagination-wrap{display:flex;align-items:center;justify-content:space-between}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }] }); }
1059
836
  }
1060
837
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: PagerComponent, decorators: [{
1061
838
  type: Component,
1062
- args: [{ selector: "ng2-smart-table-pager", template: `
1063
- @if (shouldShow()) {
1064
- <nav class="ng2-smart-pagination-nav">
1065
- <ul class="ng2-smart-pagination pagination">
1066
- <li
1067
- class="ng2-smart-page-item page-item"
1068
- [class.disabled]="getPage() === 1"
1069
- >
1070
- <a
1071
- class="ng2-smart-page-link page-link"
1072
- href="#"
1073
- (click)="getPage() === 1 ? false : paginate(1)"
1074
- aria-label="First"
1075
- >
1076
- <span aria-hidden="true">&laquo;</span>
1077
- <span class="sr-only">First</span>
1078
- </a>
1079
- </li>
1080
- <li
1081
- class="ng2-smart-page-item page-item"
1082
- [class.disabled]="getPage() === 1"
1083
- >
1084
- <a
1085
- class="ng2-smart-page-link page-link page-link-prev"
1086
- href="#"
1087
- (click)="getPage() === 1 ? false : prev()"
1088
- aria-label="Prev"
1089
- >
1090
- <span aria-hidden="true">&lt;</span>
1091
- <span class="sr-only">Prev</span>
1092
- </a>
1093
- </li>
1094
- @for (page of getPages(); track page) {
1095
- <li
1096
- class="ng2-smart-page-item page-item"
1097
- [class.active]="getPage() === page"
1098
- >
1099
- @if (getPage() === page) {
1100
- <span class="ng2-smart-page-link page-link"
1101
- >{{ page }} <span class="sr-only">(current)</span></span
1102
- >
1103
- } @if (getPage() !== page) {
1104
- <a
1105
- class="ng2-smart-page-link page-link"
1106
- href="#"
1107
- (click)="paginate(page)"
1108
- >{{ page }}</a
1109
- >
1110
- }
1111
- </li>
1112
- }
1113
- <li
1114
- class="ng2-smart-page-item page-item"
1115
- [class.disabled]="getPage() === getLast()"
1116
- >
1117
- <a
1118
- class="ng2-smart-page-link page-link page-link-next"
1119
- href="#"
1120
- (click)="getPage() === getLast() ? false : next()"
1121
- aria-label="Next"
1122
- >
1123
- <span aria-hidden="true">&gt;</span>
1124
- <span class="sr-only">Next</span>
1125
- </a>
1126
- </li>
1127
- <li
1128
- class="ng2-smart-page-item page-item"
1129
- [class.disabled]="getPage() === getLast()"
1130
- >
1131
- <a
1132
- class="ng2-smart-page-link page-link"
1133
- href="#"
1134
- (click)="getPage() === getLast() ? false : paginate(getLast())"
1135
- aria-label="Last"
1136
- >
1137
- <span aria-hidden="true">&raquo;</span>
1138
- <span class="sr-only">Last</span>
1139
- </a>
1140
- </li>
1141
- </ul>
1142
- </nav>
1143
- } @if (perPageSelect && perPageSelect.length > 0) {
1144
- <nav class="ng2-smart-pagination-per-page">
1145
- <label for="per-page"> Per Page: </label>
1146
- <select
1147
- (change)="onChangePerPage()"
1148
- [(ngModel)]="currentPerPage"
1149
- id="per-page"
1150
- >
1151
- @for (item of perPageSelect; track $index) {
1152
- <option [value]="item">{{ item }}</option>
1153
- }
1154
- </select>
1155
- </nav>
1156
- }
1157
- `, standalone: true, imports: [FormsModule], styles: [".ng2-smart-pagination{display:inline-flex;font-size:.875em;padding:0}.ng2-smart-pagination .sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}.ng2-smart-pagination .ng2-smart-page-item{display:inline}.ng2-smart-pagination .page-link-next,.ng2-smart-pagination .page-link-prev{font-size:10px}:host{display:flex;justify-content:space-between}:host select{margin:1rem 0 1rem 1rem}:host label{margin:1rem 0 1rem 1rem;line-height:2.5rem}\n"] }]
1158
- }], propDecorators: { source: [{
1159
- type: Input
1160
- }], perPageSelect: [{
1161
- type: Input
1162
- }] } });
1163
-
1164
- class EditCellDefaultComponent {
1165
- constructor() {
1166
- this.cell = input.required();
1167
- this.inputClass = input('');
1168
- }
1169
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: EditCellDefaultComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1170
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.0.3", type: EditCellDefaultComponent, isStandalone: true, selector: "ng2-edit-cell-default-base-component", inputs: { cell: { classPropertyName: "cell", publicName: "cell", isSignal: true, isRequired: true, transformFunction: null }, inputClass: { classPropertyName: "inputClass", publicName: "inputClass", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: '', isInline: true }); }
1171
- }
1172
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: EditCellDefaultComponent, decorators: [{
1173
- type: Component,
1174
- args: [{ template: '', selector: 'ng2-edit-cell-default-base-component' }]
839
+ args: [{ selector: 'ng2-smart-table-pager', standalone: true, imports: [FormsModule], template: "@if (shouldShow()) {\n<div class=\"ng2-smart-pagination-wrap\">\n @if ((pagingConf().perPageSelect?.length || 0) > 0) {\n <div></div>\n }\n <nav class=\"ng2-smart-pagination-nav\">\n <ul class=\"ng2-smart-pagination pagination\">\n <li class=\"ng2-smart-page-item page-item\" [class.disabled]=\"currentPage() === 1\">\n <a\n class=\"ng2-smart-page-link page-link\"\n href=\"#\"\n (click)=\"currentPage() === 1 ? false : paginate(1)\"\n aria-label=\"First\">\n <span aria-hidden=\"true\">&laquo;</span>\n </a>\n </li>\n <li class=\"ng2-smart-page-item page-item\" [class.disabled]=\"currentPage() === 1\">\n <a\n class=\"ng2-smart-page-link page-link page-link-prev\"\n href=\"#\"\n (click)=\"currentPage() === 1 ? false : prev()\"\n aria-label=\"Prev\">\n <span aria-hidden=\"true\">&lt;</span>\n </a>\n </li>\n @for (page of pages(); track $index) {\n <li class=\"ng2-smart-page-item page-item\" [class.active]=\"currentPage() === page\">\n @if (currentPage() === page || isString(page)) {\n <span class=\"ng2-smart-page-link page-link\">{{ page }}</span>\n } @else {\n <a class=\"ng2-smart-page-link page-link\" href=\"#\" (click)=\"paginate(page)\">{{ page }}</a>\n }\n </li>\n }\n <li class=\"ng2-smart-page-item page-item\" [class.disabled]=\"currentPage() === lastPage()\">\n <a\n class=\"ng2-smart-page-link page-link page-link-next\"\n href=\"#\"\n (click)=\"currentPage() === lastPage() ? false : next()\"\n aria-label=\"Next\">\n <span aria-hidden=\"true\">&gt;</span>\n </a>\n </li>\n <li class=\"ng2-smart-page-item page-item\" [class.disabled]=\"currentPage() === lastPage()\">\n <a\n class=\"ng2-smart-page-link page-link\"\n href=\"#\"\n (click)=\"currentPage() === lastPage() ? false : paginate(lastPage())\"\n aria-label=\"Last\">\n <span aria-hidden=\"true\">&raquo;</span>\n </a>\n </li>\n </ul>\n </nav>\n @if ((pagingConf().perPageSelect?.length || 0) > 0) {\n <nav class=\"ng2-smart-pagination-per-page\">\n <label for=\"per-page\"> Per Page: </label>\n <select (change)=\"onChangePerPage($any($event.target))\" [ngModel]=\"currentPerPage()\" id=\"per-page\">\n @for (item of pagingConf().perPageSelect; track $index) {\n <option [value]=\"item\">{{ item }}</option>\n }\n </select>\n </nav>\n }\n</div>\n\n}\n", styles: [".ng2-smart-pagination{display:inline-flex;align-items:center;font-size:.875em;padding:0}.ng2-smart-pagination .ng2-smart-page-item{display:inline;padding:.2rem}.ng2-smart-pagination .page-link-next,.ng2-smart-pagination .page-link-prev{font-size:10px}.ng2-smart-pagination-nav{margin:0 auto}.ng2-smart-pagination-wrap{display:flex;align-items:center;justify-content:space-between}\n"] }]
1175
840
  }] });
1176
841
 
1177
- class CustomEditComponent extends EditCellDefaultComponent {
1178
- ngOnChanges(changes) {
1179
- const editor = this.cell().getColumn().editor;
1180
- if (this.customComponent) {
1181
- if (this.customComponent?.instance && 'ngOnChanges' in this.customComponent.instance) {
1182
- const onChanges = this.customComponent.instance.ngOnChanges;
1183
- onChanges(changes);
1184
- }
1185
- return;
1186
- }
1187
- if (this.cell() &&
1188
- !this.customComponent &&
1189
- editor &&
1190
- editor.type == "custom") {
1191
- this.customComponent = this.dynamicTarget?.createComponent(editor.component);
1192
- this.customComponent?.setInput('cell', this.cell());
1193
- this.customComponent?.setInput('inputClass', this.inputClass());
1194
- }
1195
- }
1196
- ngOnDestroy() {
1197
- if (this.customComponent) {
1198
- this.customComponent.destroy();
1199
- }
1200
- }
1201
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: CustomEditComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
1202
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.3", type: CustomEditComponent, isStandalone: true, selector: "ng2-table-cell-custom-editor", viewQueries: [{ propertyName: "dynamicTarget", first: true, predicate: ["dynamicTarget"], descendants: true, read: ViewContainerRef, static: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: ` <ng-template #dynamicTarget></ng-template> `, isInline: true }); }
1203
- }
1204
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: CustomEditComponent, decorators: [{
1205
- type: Component,
1206
- args: [{
1207
- selector: "ng2-table-cell-custom-editor",
1208
- template: ` <ng-template #dynamicTarget></ng-template> `,
1209
- standalone: true,
1210
- }]
1211
- }], propDecorators: { dynamicTarget: [{
1212
- type: ViewChild,
1213
- args: ["dynamicTarget", { read: ViewContainerRef, static: true }]
1214
- }] } });
1215
-
1216
- class CheckboxEditorComponent extends DefaultEditor {
842
+ class CheckboxEditorComponent extends BaseEditorComponent {
1217
843
  constructor() {
1218
844
  super();
1219
845
  this.trueVal = computed(() => {
1220
- return this.cell().getColumn().getConfig()?.true || true;
846
+ return this.cell().getColumn().getEditorConfig()?.true || true;
1221
847
  });
1222
848
  this.falseVal = computed(() => {
1223
- return this.cell().getColumn().getConfig()?.false || false;
849
+ return this.cell().getColumn().getEditorConfig()?.false || false;
1224
850
  });
1225
851
  }
1226
852
  onChange(event) {
@@ -1235,15 +861,12 @@ class CheckboxEditorComponent extends DefaultEditor {
1235
861
  [name]="cell().getId()"
1236
862
  [disabled]="!cell().isEditable()"
1237
863
  (change)="onChange($event)"
1238
- [checked]="
1239
- cell().getValue() === trueVal()
1240
- "
1241
- />
864
+ [checked]="cell().getValue() === trueVal()" />
1242
865
  `, isInline: true, styles: [":host input,:host textarea{width:100%;line-height:normal;padding:.375em .75em}\n"] }); }
1243
866
  }
1244
867
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: CheckboxEditorComponent, decorators: [{
1245
868
  type: Component,
1246
- args: [{ selector: "ng2-checkbox-editor", template: `
869
+ args: [{ selector: 'ng2-checkbox-editor', template: `
1247
870
  <input
1248
871
  [class]="inputClass()"
1249
872
  type="checkbox"
@@ -1251,18 +874,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
1251
874
  [name]="cell().getId()"
1252
875
  [disabled]="!cell().isEditable()"
1253
876
  (change)="onChange($event)"
1254
- [checked]="
1255
- cell().getValue() === trueVal()
1256
- "
1257
- />
877
+ [checked]="cell().getValue() === trueVal()" />
1258
878
  `, standalone: true, styles: [":host input,:host textarea{width:100%;line-height:normal;padding:.375em .75em}\n"] }]
1259
879
  }], ctorParameters: () => [] });
1260
880
 
1261
- class InputEditorComponent extends DefaultEditor {
1262
- constructor() {
1263
- super();
1264
- }
1265
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: InputEditorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
881
+ class InputEditorComponent extends BaseEditorComponent {
882
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: InputEditorComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
1266
883
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.3", type: InputEditorComponent, isStandalone: true, selector: "ng2-input-editor", usesInheritance: true, ngImport: i0, template: `
1267
884
  <input
1268
885
  [class]="inputClass()"
@@ -1270,42 +887,33 @@ class InputEditorComponent extends DefaultEditor {
1270
887
  [(ngModel)]="cell().newValue"
1271
888
  [name]="cell().getId()"
1272
889
  [placeholder]="cell().getTitle()"
1273
- [disabled]="!cell().isEditable()"
1274
- />
890
+ [disabled]="!cell().isEditable()" />
1275
891
  `, isInline: true, styles: [":host input,:host textarea{width:100%;line-height:normal;padding:.375em .75em}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }] }); }
1276
892
  }
1277
893
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: InputEditorComponent, decorators: [{
1278
894
  type: Component,
1279
- args: [{ selector: "ng2-input-editor", template: `
895
+ args: [{ selector: 'ng2-input-editor', template: `
1280
896
  <input
1281
897
  [class]="inputClass()"
1282
898
  class="form-control"
1283
899
  [(ngModel)]="cell().newValue"
1284
900
  [name]="cell().getId()"
1285
901
  [placeholder]="cell().getTitle()"
1286
- [disabled]="!cell().isEditable()"
1287
- />
902
+ [disabled]="!cell().isEditable()" />
1288
903
  `, standalone: true, imports: [FormsModule], styles: [":host input,:host textarea{width:100%;line-height:normal;padding:.375em .75em}\n"] }]
1289
- }], ctorParameters: () => [] });
904
+ }] });
1290
905
 
1291
- class SelectEditorComponent extends DefaultEditor {
1292
- constructor() {
1293
- super();
1294
- }
1295
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: SelectEditorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
906
+ class SelectEditorComponent extends BaseEditorComponent {
907
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: SelectEditorComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
1296
908
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.3", type: SelectEditorComponent, isStandalone: true, selector: "ng2-select-editor", usesInheritance: true, ngImport: i0, template: `
1297
909
  <select
1298
910
  [class]="inputClass()"
1299
911
  class="form-control"
1300
912
  [(ngModel)]="cell().newValue"
1301
913
  [name]="cell().getId()"
1302
- [disabled]="!cell().isEditable()"
1303
- >
1304
- @for (option of cell().getColumn().getConfig()?.list; track $index) {
1305
- <option
1306
- [value]="option.value"
1307
- [selected]="option.value === cell().getValue()"
1308
- >
914
+ [disabled]="!cell().isEditable()">
915
+ @for (option of cell().getColumn().getEditorConfig()?.list; track $index) {
916
+ <option [value]="option.value" [selected]="option.value === cell().getValue()">
1309
917
  {{ option.title }}
1310
918
  </option>
1311
919
  }
@@ -1315,20 +923,16 @@ class SelectEditorComponent extends DefaultEditor {
1315
923
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: SelectEditorComponent, decorators: [{
1316
924
  type: Component,
1317
925
  args: [{
1318
- selector: "ng2-select-editor",
926
+ selector: 'ng2-select-editor',
1319
927
  template: `
1320
928
  <select
1321
929
  [class]="inputClass()"
1322
930
  class="form-control"
1323
931
  [(ngModel)]="cell().newValue"
1324
932
  [name]="cell().getId()"
1325
- [disabled]="!cell().isEditable()"
1326
- >
1327
- @for (option of cell().getColumn().getConfig()?.list; track $index) {
1328
- <option
1329
- [value]="option.value"
1330
- [selected]="option.value === cell().getValue()"
1331
- >
933
+ [disabled]="!cell().isEditable()">
934
+ @for (option of cell().getColumn().getEditorConfig()?.list; track $index) {
935
+ <option [value]="option.value" [selected]="option.value === cell().getValue()">
1332
936
  {{ option.title }}
1333
937
  </option>
1334
938
  }
@@ -1337,13 +941,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
1337
941
  standalone: true,
1338
942
  imports: [FormsModule],
1339
943
  }]
1340
- }], ctorParameters: () => [] });
944
+ }] });
1341
945
 
1342
- class TextareaEditorComponent extends DefaultEditor {
1343
- constructor() {
1344
- super();
1345
- }
1346
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: TextareaEditorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
946
+ class TextareaEditorComponent extends BaseEditorComponent {
947
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: TextareaEditorComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
1347
948
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.3", type: TextareaEditorComponent, isStandalone: true, selector: "ng2-textarea-editor", usesInheritance: true, ngImport: i0, template: `
1348
949
  <textarea
1349
950
  [class]="inputClass()"
@@ -1351,98 +952,120 @@ class TextareaEditorComponent extends DefaultEditor {
1351
952
  [(ngModel)]="cell().newValue"
1352
953
  [name]="cell().getId()"
1353
954
  [disabled]="!cell().isEditable()"
1354
- [placeholder]="cell().getTitle()"
1355
- >
955
+ [placeholder]="cell().getTitle()">
1356
956
  </textarea>
1357
957
  `, isInline: true, styles: [":host input,:host textarea{width:100%;line-height:normal;padding:.375em .75em}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }] }); }
1358
958
  }
1359
959
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: TextareaEditorComponent, decorators: [{
1360
960
  type: Component,
1361
- args: [{ selector: "ng2-textarea-editor", template: `
961
+ args: [{ selector: 'ng2-textarea-editor', template: `
1362
962
  <textarea
1363
963
  [class]="inputClass()"
1364
964
  class="form-control"
1365
965
  [(ngModel)]="cell().newValue"
1366
966
  [name]="cell().getId()"
1367
967
  [disabled]="!cell().isEditable()"
1368
- [placeholder]="cell().getTitle()"
1369
- >
968
+ [placeholder]="cell().getTitle()">
1370
969
  </textarea>
1371
970
  `, standalone: true, imports: [FormsModule], styles: [":host input,:host textarea{width:100%;line-height:normal;padding:.375em .75em}\n"] }]
1372
- }], ctorParameters: () => [] });
971
+ }] });
1373
972
 
1374
- class DefaultEditComponent extends EditCellDefaultComponent {
973
+ class BuildInEditorComponent extends BaseEditorComponent$1 {
1375
974
  constructor() {
1376
- super();
975
+ super(...arguments);
976
+ this.editorType = computed(() => {
977
+ const editor = this.cell().getColumn().editor;
978
+ if (editor) {
979
+ return editor.type || 'text';
980
+ }
981
+ return 'text';
982
+ });
1377
983
  }
1378
- getEditorType() {
984
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: BuildInEditorComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
985
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.3", type: BuildInEditorComponent, isStandalone: true, selector: "ng2-table-cell-build-in-editor", usesInheritance: true, ngImport: i0, template: "<div role=\"none\" (click)=\"$event.stopPropagation()\">\n @switch (editorType()) {\n @case ('list') {\n <ng2-select-editor\n [cell]=\"cell()\"\n [inputClass]=\"inputClass()\">\n </ng2-select-editor>\n }\n @case ('textarea') {\n <ng2-textarea-editor\n [cell]=\"cell()\"\n [inputClass]=\"inputClass()\">\n </ng2-textarea-editor>\n }\n @case ('checkbox') {\n <ng2-checkbox-editor\n [cell]=\"cell()\"\n [inputClass]=\"inputClass()\">\n </ng2-checkbox-editor>\n }\n @default {\n <ng2-input-editor\n [cell]=\"cell()\"\n [inputClass]=\"inputClass()\">\n </ng2-input-editor>\n }\n}\n</div>", dependencies: [{ kind: "component", type: SelectEditorComponent, selector: "ng2-select-editor" }, { kind: "component", type: TextareaEditorComponent, selector: "ng2-textarea-editor" }, { kind: "component", type: CheckboxEditorComponent, selector: "ng2-checkbox-editor" }, { kind: "component", type: InputEditorComponent, selector: "ng2-input-editor" }] }); }
986
+ }
987
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: BuildInEditorComponent, decorators: [{
988
+ type: Component,
989
+ args: [{ selector: 'ng2-table-cell-build-in-editor', imports: [SelectEditorComponent, TextareaEditorComponent, CheckboxEditorComponent, InputEditorComponent], standalone: true, template: "<div role=\"none\" (click)=\"$event.stopPropagation()\">\n @switch (editorType()) {\n @case ('list') {\n <ng2-select-editor\n [cell]=\"cell()\"\n [inputClass]=\"inputClass()\">\n </ng2-select-editor>\n }\n @case ('textarea') {\n <ng2-textarea-editor\n [cell]=\"cell()\"\n [inputClass]=\"inputClass()\">\n </ng2-textarea-editor>\n }\n @case ('checkbox') {\n <ng2-checkbox-editor\n [cell]=\"cell()\"\n [inputClass]=\"inputClass()\">\n </ng2-checkbox-editor>\n }\n @default {\n <ng2-input-editor\n [cell]=\"cell()\"\n [inputClass]=\"inputClass()\">\n </ng2-input-editor>\n }\n}\n</div>" }]
990
+ }] });
991
+
992
+ class CustomEditComponent extends BaseEditorComponent$1 {
993
+ ngOnChanges(changes) {
1379
994
  const editor = this.cell().getColumn().editor;
1380
- if (editor) {
1381
- return editor.type || "text";
995
+ if (this.customComponent) {
996
+ if (this.customComponent?.instance && 'ngOnChanges' in this.customComponent.instance) {
997
+ const onChanges = this.customComponent.instance.ngOnChanges;
998
+ onChanges(changes);
999
+ }
1000
+ return;
1001
+ }
1002
+ if (this.cell() &&
1003
+ !this.customComponent &&
1004
+ editor &&
1005
+ editor.type == "custom") {
1006
+ this.customComponent = this.dynamicTarget?.createComponent(editor.component);
1007
+ this.customComponent?.setInput('cell', this.cell());
1008
+ this.customComponent?.setInput('inputClass', this.inputClass());
1382
1009
  }
1383
- return "text";
1384
1010
  }
1385
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: DefaultEditComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1386
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.3", type: DefaultEditComponent, isStandalone: true, selector: "ng2-table-cell-default-editor", usesInheritance: true, ngImport: i0, template: "<div role=\"none\" (click)=\"$event.stopPropagation()\">\n @switch (getEditorType()) {\n @case ('list') {\n <ng2-select-editor\n [cell]=\"cell()\"\n [inputClass]=\"inputClass()\">\n </ng2-select-editor>\n }\n @case ('textarea') {\n <ng2-textarea-editor\n [cell]=\"cell()\"\n [inputClass]=\"inputClass()\">\n </ng2-textarea-editor>\n }\n @case ('checkbox') {\n <ng2-checkbox-editor\n [cell]=\"cell()\"\n [inputClass]=\"inputClass()\">\n </ng2-checkbox-editor>\n }\n @default {\n <ng2-input-editor\n [cell]=\"cell()\"\n [inputClass]=\"inputClass()\">\n </ng2-input-editor>\n }\n}\n</div>", dependencies: [{ kind: "component", type: SelectEditorComponent, selector: "ng2-select-editor" }, { kind: "component", type: TextareaEditorComponent, selector: "ng2-textarea-editor" }, { kind: "component", type: CheckboxEditorComponent, selector: "ng2-checkbox-editor" }, { kind: "component", type: InputEditorComponent, selector: "ng2-input-editor" }] }); }
1011
+ ngOnDestroy() {
1012
+ if (this.customComponent) {
1013
+ this.customComponent.destroy();
1014
+ }
1015
+ }
1016
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: CustomEditComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
1017
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.3", type: CustomEditComponent, isStandalone: true, selector: "ng2-table-cell-custom-editor", viewQueries: [{ propertyName: "dynamicTarget", first: true, predicate: ["dynamicTarget"], descendants: true, read: ViewContainerRef, static: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: ` <ng-template #dynamicTarget></ng-template> `, isInline: true }); }
1387
1018
  }
1388
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: DefaultEditComponent, decorators: [{
1019
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: CustomEditComponent, decorators: [{
1389
1020
  type: Component,
1390
- args: [{ selector: "ng2-table-cell-default-editor", imports: [
1391
- SelectEditorComponent,
1392
- TextareaEditorComponent,
1393
- CheckboxEditorComponent,
1394
- InputEditorComponent,
1395
- ], standalone: true, template: "<div role=\"none\" (click)=\"$event.stopPropagation()\">\n @switch (getEditorType()) {\n @case ('list') {\n <ng2-select-editor\n [cell]=\"cell()\"\n [inputClass]=\"inputClass()\">\n </ng2-select-editor>\n }\n @case ('textarea') {\n <ng2-textarea-editor\n [cell]=\"cell()\"\n [inputClass]=\"inputClass()\">\n </ng2-textarea-editor>\n }\n @case ('checkbox') {\n <ng2-checkbox-editor\n [cell]=\"cell()\"\n [inputClass]=\"inputClass()\">\n </ng2-checkbox-editor>\n }\n @default {\n <ng2-input-editor\n [cell]=\"cell()\"\n [inputClass]=\"inputClass()\">\n </ng2-input-editor>\n }\n}\n</div>" }]
1396
- }], ctorParameters: () => [] });
1021
+ args: [{
1022
+ selector: "ng2-table-cell-custom-editor",
1023
+ template: ` <ng-template #dynamicTarget></ng-template> `,
1024
+ standalone: true,
1025
+ }]
1026
+ }], propDecorators: { dynamicTarget: [{
1027
+ type: ViewChild,
1028
+ args: ["dynamicTarget", { read: ViewContainerRef, static: true }]
1029
+ }] } });
1397
1030
 
1398
1031
  class EditCellComponent {
1399
1032
  constructor() {
1400
1033
  this.cell = input.required();
1401
- this.inputClass = input("");
1034
+ this.inputClass = input('');
1402
1035
  }
1403
1036
  getEditorType() {
1404
1037
  const editor = this.cell().getColumn().editor;
1405
1038
  if (editor) {
1406
1039
  return editor.type;
1407
1040
  }
1408
- return "text";
1041
+ return 'text';
1409
1042
  }
1410
1043
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: EditCellComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1411
1044
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.3", type: EditCellComponent, isStandalone: true, selector: "ng2-table-cell-edit-mode", inputs: { cell: { classPropertyName: "cell", publicName: "cell", isSignal: true, isRequired: true, transformFunction: null }, inputClass: { classPropertyName: "inputClass", publicName: "inputClass", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
1412
1045
  <div>
1413
1046
  @switch (getEditorType()) { @case ('custom') {
1414
- <ng2-table-cell-custom-editor [cell]="cell()" [inputClass]="inputClass()">
1415
- </ng2-table-cell-custom-editor>
1047
+ <ng2-table-cell-custom-editor [cell]="cell()" [inputClass]="inputClass()"> </ng2-table-cell-custom-editor>
1416
1048
  } @default {
1417
- <ng2-table-cell-default-editor
1418
- [cell]="cell()"
1419
- [inputClass]="inputClass()"
1420
- >
1421
- </ng2-table-cell-default-editor>
1049
+ <ng2-table-cell-build-in-editor [cell]="cell()" [inputClass]="inputClass()"> </ng2-table-cell-build-in-editor>
1422
1050
  } }
1423
1051
  </div>
1424
- `, isInline: true, dependencies: [{ kind: "component", type: CustomEditComponent, selector: "ng2-table-cell-custom-editor" }, { kind: "component", type: DefaultEditComponent, selector: "ng2-table-cell-default-editor" }] }); }
1052
+ `, isInline: true, dependencies: [{ kind: "component", type: CustomEditComponent, selector: "ng2-table-cell-custom-editor" }, { kind: "component", type: BuildInEditorComponent, selector: "ng2-table-cell-build-in-editor" }] }); }
1425
1053
  }
1426
1054
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: EditCellComponent, decorators: [{
1427
1055
  type: Component,
1428
1056
  args: [{
1429
- selector: "ng2-table-cell-edit-mode",
1057
+ selector: 'ng2-table-cell-edit-mode',
1430
1058
  template: `
1431
1059
  <div>
1432
1060
  @switch (getEditorType()) { @case ('custom') {
1433
- <ng2-table-cell-custom-editor [cell]="cell()" [inputClass]="inputClass()">
1434
- </ng2-table-cell-custom-editor>
1061
+ <ng2-table-cell-custom-editor [cell]="cell()" [inputClass]="inputClass()"> </ng2-table-cell-custom-editor>
1435
1062
  } @default {
1436
- <ng2-table-cell-default-editor
1437
- [cell]="cell()"
1438
- [inputClass]="inputClass()"
1439
- >
1440
- </ng2-table-cell-default-editor>
1063
+ <ng2-table-cell-build-in-editor [cell]="cell()" [inputClass]="inputClass()"> </ng2-table-cell-build-in-editor>
1441
1064
  } }
1442
1065
  </div>
1443
1066
  `,
1444
1067
  standalone: true,
1445
- imports: [CustomEditComponent, DefaultEditComponent],
1068
+ imports: [CustomEditComponent, BuildInEditorComponent],
1446
1069
  }]
1447
1070
  }] });
1448
1071
 
@@ -1574,7 +1197,7 @@ class TbodyCreateCancelComponent {
1574
1197
  event.preventDefault();
1575
1198
  event.stopPropagation();
1576
1199
  this.editCancel().emit(true);
1577
- this.row().isInEditing = false;
1200
+ this.row().isInEditing.set(false);
1578
1201
  }
1579
1202
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: TbodyCreateCancelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1580
1203
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.3", type: TbodyCreateCancelComponent, isStandalone: true, selector: "ng2-st-tbody-create-cancel", inputs: { grid: { classPropertyName: "grid", publicName: "grid", isSignal: true, isRequired: true, transformFunction: null }, row: { classPropertyName: "row", publicName: "row", isSignal: true, isRequired: true, transformFunction: null }, editConfirm: { classPropertyName: "editConfirm", publicName: "editConfirm", isSignal: true, isRequired: true, transformFunction: null }, editCancel: { classPropertyName: "editCancel", publicName: "editCancel", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: `
@@ -1748,52 +1371,52 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
1748
1371
  class DataSet {
1749
1372
  constructor(data = [], columnSettings) {
1750
1373
  this.columnSettings = columnSettings;
1751
- this.data = [];
1752
- this.columns = [];
1753
- this.rows = [];
1374
+ this.data = signal([]);
1375
+ this.columns = signal([]);
1376
+ this.rows = signal([]);
1754
1377
  this.selectedRows = new Set();
1378
+ this.getColumns = computed(() => this.columns());
1379
+ this.getVisibleColumns = computed(() => this.columns().filter((column) => !column.hide));
1380
+ this.getRows = computed(() => {
1381
+ return this.rows();
1382
+ });
1383
+ this.isAllSelected = computed(() => this.rows().every((row) => row.isSelected()));
1755
1384
  this.createColumns(columnSettings);
1756
1385
  this.setData(data);
1757
1386
  this.createNewRow();
1758
1387
  }
1759
1388
  setData(data) {
1760
- this.data = data;
1389
+ this.data.set(data);
1761
1390
  this.createRows();
1762
1391
  }
1763
- getColumns() {
1764
- return this.columns;
1765
- }
1766
- getRows() {
1767
- return this.rows;
1768
- }
1769
1392
  getFirstRow() {
1770
- return this.rows[0];
1393
+ return this.rows()[0];
1771
1394
  }
1772
1395
  getLastRow() {
1773
- return this.rows[this.rows.length - 1];
1396
+ return this.rows()[this.rows().length - 1];
1774
1397
  }
1775
1398
  findRowByData(data) {
1776
- return this.rows.find((row) => row.getData() === data);
1399
+ return this.rows().find((row) => row.getData() === data);
1777
1400
  }
1778
1401
  setSelectAll(state) {
1779
- this.rows.forEach((row) => {
1780
- row.isSelected = state;
1402
+ this.rows().forEach((row) => {
1403
+ row.isSelected.set(state);
1781
1404
  this.storeSelectedRow(row);
1782
1405
  });
1783
1406
  }
1784
1407
  deselectAll() {
1785
- this.rows.forEach((row) => {
1786
- row.isSelected = false;
1408
+ this.rows().forEach((row) => {
1409
+ row.isSelected.set(false);
1787
1410
  });
1788
1411
  // we need to clear selectedRow field because no one row selected
1789
1412
  this.selectedRows.clear();
1790
1413
  }
1791
1414
  selectRow(row, state) {
1792
- row.isSelected = state;
1415
+ row.isSelected.set(state);
1793
1416
  this.storeSelectedRow(row);
1794
1417
  }
1795
1418
  multipleSelectRow(row) {
1796
- row.isSelected = !row.isSelected;
1419
+ row.isSelected.set(!row.isSelected());
1797
1420
  this.storeSelectedRow(row);
1798
1421
  return row;
1799
1422
  }
@@ -1802,7 +1425,7 @@ class DataSet {
1802
1425
  }
1803
1426
  createNewRow() {
1804
1427
  this.newRow = new Row(-1, {}, this);
1805
- this.newRow.isInEditing = true;
1428
+ this.newRow.isInEditing.set(true);
1806
1429
  }
1807
1430
  /**
1808
1431
  * Create columns by mapping from the settings
@@ -1810,27 +1433,23 @@ class DataSet {
1810
1433
  * @private
1811
1434
  */
1812
1435
  createColumns(columnsParams) {
1813
- columnsParams.forEach((params) => {
1814
- this.columns.push(new Column(params.key, params, this));
1815
- });
1436
+ const columns = columnsParams.map((params) => new Column(params.key, params, this));
1437
+ this.columns.set(columns);
1816
1438
  }
1817
1439
  /**
1818
1440
  * Create rows based on current data prepared in data source
1819
1441
  * @private
1820
1442
  */
1821
1443
  createRows() {
1822
- this.rows = [];
1823
- this.data.forEach((el, index) => {
1444
+ const rows = this.data().map((el, index) => {
1824
1445
  const row = new Row(index, el, this);
1825
- row.isSelected = this.selectedRows.has(row.getData());
1826
- this.rows.push(row);
1446
+ row.isSelected.set(this.selectedRows.has(row.getData()));
1447
+ return row;
1827
1448
  });
1828
- }
1829
- get isAllSelected() {
1830
- return this.rows.every((row) => row.isSelected);
1449
+ this.rows.set(rows);
1831
1450
  }
1832
1451
  storeSelectedRow(row) {
1833
- if (row.isSelected) {
1452
+ if (row.isSelected()) {
1834
1453
  this.selectedRows.add(row.getData());
1835
1454
  }
1836
1455
  else {
@@ -1842,12 +1461,10 @@ class DataSet {
1842
1461
  class Grid {
1843
1462
  constructor(source, settings) {
1844
1463
  this.createFormShown = false;
1845
- this.onSelectRowSource = new Subject();
1846
- this.onDeselectRowSource = new Subject();
1847
1464
  this.currentColumnsSortState = [];
1848
1465
  this.settings = signal({});
1849
1466
  this.isMultiSelectVisible = computed(() => {
1850
- return this.settings().selectMode === "multi";
1467
+ return this.settings().selectMode === 'multi';
1851
1468
  });
1852
1469
  this.isActionsVisible = computed(() => {
1853
1470
  const actions = this.settings().actions;
@@ -1861,8 +1478,8 @@ class Grid {
1861
1478
  this.actionIsOnRight = computed(() => {
1862
1479
  return this.settings().actionsPosition === 'right';
1863
1480
  });
1481
+ this.setSource(source, settings);
1864
1482
  this.setSettings(settings);
1865
- this.setSource(source);
1866
1483
  }
1867
1484
  setColumnsSortedEmitter(emitter) {
1868
1485
  this.columnsSortedEmitter = emitter;
@@ -1880,58 +1497,24 @@ class Grid {
1880
1497
  }
1881
1498
  setSettings(settings) {
1882
1499
  this.updateSettingsAndDataSet(settings);
1883
- if (this.getSetting('columnSort', false)) {
1500
+ if (settings.columnSort) {
1884
1501
  this.setColumnsSortState(settings.columns);
1885
1502
  }
1886
1503
  }
1887
- updateSettingsAndDataSet(settings) {
1888
- this.settings.set(settings);
1889
- this.dataSet = new DataSet([], settings.columns);
1890
- if (this.source) {
1891
- this.source.refresh();
1892
- }
1893
- }
1894
1504
  getDataSet() {
1895
1505
  return this.dataSet;
1896
1506
  }
1897
- setSource(source) {
1898
- this.source = this.prepareSource(source);
1899
- this.detach();
1900
- this.sourceOnChangedSubscription = this.source
1901
- .onChanged()
1902
- .subscribe((changes) => this.processDataChange(changes));
1903
- this.sourceOnUpdatedSubscription = this.source
1904
- .onUpdated()
1905
- .subscribe((data) => {
1906
- const changedRow = this.dataSet.findRowByData(data);
1907
- if (changedRow) {
1908
- changedRow.setData(data);
1909
- }
1910
- });
1911
- }
1912
1507
  getSetting(name, defaultValue) {
1913
1508
  return getDeepFromObject(this.settings(), name, defaultValue);
1914
1509
  }
1915
- getColumns() {
1916
- return this.dataSet.getColumns();
1917
- }
1918
- getRows() {
1919
- return this.dataSet.getRows();
1920
- }
1921
1510
  selectRow(row, state) {
1922
1511
  this.dataSet.selectRow(row, state);
1923
1512
  }
1924
1513
  multipleSelectRow(row) {
1925
1514
  this.dataSet.multipleSelectRow(row);
1926
1515
  }
1927
- onSelectRow() {
1928
- return this.onSelectRowSource.asObservable();
1929
- }
1930
- onDeselectRow() {
1931
- return this.onDeselectRowSource.asObservable();
1932
- }
1933
1516
  edit(row) {
1934
- row.isInEditing = true;
1517
+ row.isInEditing.set(true);
1935
1518
  }
1936
1519
  create(row, confirmEmitter) {
1937
1520
  row.pending.set(true);
@@ -1948,7 +1531,7 @@ class Grid {
1948
1531
  .catch((err) => {
1949
1532
  row.pending.set(false);
1950
1533
  });
1951
- if (this.getSetting("add.confirmCreate", false)) {
1534
+ if (this.getSetting('add.confirmCreate', false)) {
1952
1535
  confirmEmitter.emit({
1953
1536
  newData: row.getNewData(),
1954
1537
  source: this.source,
@@ -1968,14 +1551,14 @@ class Grid {
1968
1551
  row.pending.set(false);
1969
1552
  newData = newData || row.getNewData();
1970
1553
  this.source.update(row.getData(), newData).then(() => {
1971
- row.isInEditing = false;
1554
+ row.isInEditing.set(false);
1972
1555
  });
1973
1556
  })
1974
1557
  .catch(() => {
1975
1558
  row.pending.set(false);
1976
- row.isInEditing = false;
1559
+ row.isInEditing.set(false);
1977
1560
  });
1978
- if (this.getSetting("edit.confirmSave", false)) {
1561
+ if (this.getSetting('edit.confirmSave', false)) {
1979
1562
  confirmEmitter.emit({
1980
1563
  data: row.getData(),
1981
1564
  newData: row.getNewData(),
@@ -2000,7 +1583,7 @@ class Grid {
2000
1583
  row.pending.set(false);
2001
1584
  // doing nothing
2002
1585
  });
2003
- if (this.getSetting("delete.confirmDelete")) {
1586
+ if (this.getSetting('delete.confirmDelete', true)) {
2004
1587
  confirmEmitter.emit({
2005
1588
  data: row.getData(),
2006
1589
  source: this.source,
@@ -2011,52 +1594,53 @@ class Grid {
2011
1594
  deferred.resolve(false);
2012
1595
  row.pending.set(false);
2013
1596
  }
2014
- if (row.isSelected) {
1597
+ if (row.isSelected()) {
2015
1598
  this.dataSet.selectRow(row, false);
2016
1599
  }
2017
1600
  }
2018
- processDataChange(changes) {
2019
- if (this.shouldProcessChange(changes)) {
2020
- if (changes["action"] === "load") {
2021
- this.dataSet.deselectAll();
2022
- }
2023
- this.dataSet.setData(changes["elements"]);
1601
+ processDataChange(event) {
1602
+ if (event.action === 'load') {
1603
+ this.dataSet.deselectAll();
2024
1604
  }
2025
- }
2026
- shouldProcessChange(changes) {
2027
- if (["filter", "sort", "page", "remove", "refresh", "load", "paging"].indexOf(changes["action"]) !== -1) {
2028
- return true;
1605
+ if (event.action !== 'update') {
1606
+ this.dataSet.setData(event.elements);
2029
1607
  }
2030
- else if (["prepend", "append"].indexOf(changes["action"]) !== -1 &&
2031
- !this.getSetting("pager.display")) {
2032
- return true;
1608
+ else {
1609
+ const changedRow = this.dataSet.findRowByData(event.oldItem);
1610
+ if (changedRow) {
1611
+ changedRow.setData(event.newItem || event.oldItem);
1612
+ }
2033
1613
  }
2034
- return false;
2035
1614
  }
2036
- prepareSource(source) {
2037
- const initialSort = this.getInitialSort();
1615
+ prepareSource(source, initialSort, initialPaging) {
1616
+ const preparedSource = source || new LocalDataSource();
2038
1617
  if (initialSort) {
2039
- source.setSort([initialSort], false);
1618
+ preparedSource.setSort(initialSort, false);
2040
1619
  }
2041
- if (this.getSetting("pager.display") === true) {
2042
- source.setPaging(1, this.getSetting("pager.perPage"), false);
1620
+ if (initialPaging && initialPaging?.display) {
1621
+ preparedSource.pagingConf.update((old) => ({
1622
+ ...old,
1623
+ ...initialPaging,
1624
+ }));
2043
1625
  }
2044
- source.refresh();
2045
- return source;
1626
+ return preparedSource;
2046
1627
  }
2047
- getInitialSort() {
2048
- const defaultSortColumn = this.getColumns().find((column) => column.isSortable && column.defaultSortDirection);
1628
+ getInitialSort(columns) {
1629
+ if (!columns || !columns.length) {
1630
+ return false;
1631
+ }
1632
+ const defaultSortColumn = columns?.find((column) => column.sortDirection);
2049
1633
  if (!defaultSortColumn) {
2050
1634
  return false;
2051
1635
  }
2052
1636
  return {
2053
- field: defaultSortColumn.id,
2054
- direction: defaultSortColumn.defaultSortDirection || "asc",
2055
- compare: defaultSortColumn.getCompareFunction(),
1637
+ field: defaultSortColumn.key,
1638
+ direction: defaultSortColumn.sortDirection || 'asc',
1639
+ compare: defaultSortColumn.compareFunction,
2056
1640
  };
2057
1641
  }
2058
1642
  getSelectedRowsData() {
2059
- return this.dataSet.getRows();
1643
+ return this.dataSet.getSelectedRowsData();
2060
1644
  }
2061
1645
  selectAllRows(status) {
2062
1646
  this.dataSet.setSelectAll(status);
@@ -2067,6 +1651,29 @@ class Grid {
2067
1651
  getLastRow() {
2068
1652
  return this.dataSet.getLastRow();
2069
1653
  }
1654
+ updateSettingsAndDataSet(settings, emittedEvent = 'refresh') {
1655
+ this.settings.set(settings);
1656
+ this.dataSet = new DataSet([], settings.columns);
1657
+ if (this.source) {
1658
+ console.log('updateSettingsAndDataSet', emittedEvent);
1659
+ this.source.pagingConf.update((old) => ({
1660
+ ...old,
1661
+ display: this.getSetting('pager.display'),
1662
+ }));
1663
+ if (emittedEvent === 'columnRefresh') {
1664
+ this.source.columnRefresh();
1665
+ }
1666
+ else {
1667
+ this.source.refresh();
1668
+ }
1669
+ }
1670
+ }
1671
+ setSource(source, settings) {
1672
+ const initialSort = this.getInitialSort(settings?.columns);
1673
+ this.source = this.prepareSource(source, initialSort, settings?.pager || false);
1674
+ this.detach();
1675
+ this.sourceOnChangedSubscription = this.source.onChanged().subscribe((changes) => this.processDataChange(changes));
1676
+ }
2070
1677
  // ------------------------------- column sort
2071
1678
  async getSortedTableColumns(newState, columns) {
2072
1679
  const sortedArray = [];
@@ -2083,7 +1690,7 @@ class Grid {
2083
1690
  this.updateSettingsAndDataSet({
2084
1691
  ...this.settings(),
2085
1692
  columns: await this.getSortedTableColumns(this.currentColumnsSortState, this.settings()?.columns),
2086
- });
1693
+ }, 'columnRefresh');
2087
1694
  if (this.columnStateStorageKey) {
2088
1695
  setLocalStorage(this.columnStateStorageKey, this.currentColumnsSortState);
2089
1696
  }
@@ -2452,14 +2059,11 @@ class Ng2SmartTableTbodyComponent {
2452
2059
  return this.grid().settings().noDataMessage || "No data found";
2453
2060
  });
2454
2061
  }
2455
- getVisibleCells(cells) {
2456
- return (cells || []).filter((cell) => !cell.getColumn().hide);
2457
- }
2458
2062
  trackByIdOrIndex(index, item) {
2459
2063
  return item?.id || index;
2460
2064
  }
2461
2065
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: Ng2SmartTableTbodyComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
2462
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.3", type: Ng2SmartTableTbodyComponent, isStandalone: true, selector: "[ng2-st-tbody]", inputs: { grid: { classPropertyName: "grid", publicName: "grid", isSignal: true, isRequired: true, transformFunction: null }, source: { classPropertyName: "source", publicName: "source", isSignal: true, isRequired: true, transformFunction: null }, deleteConfirm: { classPropertyName: "deleteConfirm", publicName: "deleteConfirm", isSignal: true, isRequired: true, transformFunction: null }, createConfirm: { classPropertyName: "createConfirm", publicName: "createConfirm", isSignal: true, isRequired: true, transformFunction: null }, editConfirm: { classPropertyName: "editConfirm", publicName: "editConfirm", isSignal: true, isRequired: true, transformFunction: null }, rowClassFunction: { classPropertyName: "rowClassFunction", publicName: "rowClassFunction", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { save: "save", edit: "edit", editCancel: "editCancel", delete: "delete", custom: "custom", edited: "edited", userSelectRow: "userSelectRow", userClickedRow: "userClickedRow", multipleSelectRow: "multipleSelectRow" }, ngImport: i0, template: "@for (row of grid().getRows(); track trackByIdOrIndex($index, row)) {\n<tr\n (click)=\"userClickedRow.emit(row)\"\n class=\"ng2-smart-row\"\n [class]=\"rowClassFunction()(row)\"\n [class.selected]=\"row.isSelected\"\n>\n @if (grid().isMultiSelectVisible()) {\n <td\n class=\"ng2-smart-actions ng2-smart-action-multiple-select\"\n (click)=\"$event.stopPropagation(); multipleSelectRow.emit(row)\"\n >\n <input\n type=\"checkbox\"\n [id]=\"'row-' + row.index + '_select-checkbox'\"\n class=\"form-control\"\n [ngModel]=\"row.isSelected\"\n />\n </td>\n } @if (grid().actionIsOnLeft()) {\n <ng-container [ngTemplateOutlet]=\"actions\"></ng-container>\n } @for (cell of getVisibleCells(row.cells); track cell.getId() + $index) {\n <td [class]=\"cell.getColumnClass()\">\n <ng2-smart-table-cell\n [cell]=\"cell\"\n [inputClass]=\"editInputClass()\"\n [isInEditing]=\"row.isInEditing\"\n >\n </ng2-smart-table-cell>\n </td>\n } @if (grid().actionIsOnRight()) {\n <ng-container [ngTemplateOutlet]=\"actions\"></ng-container>\n }\n</tr>\n\n<ng-template #actions>\n @if (row.isInEditing) {\n <td class=\"ng2-smart-actions\">\n <ng2-st-tbody-create-cancel\n [grid]=\"grid()\"\n [row]=\"row\"\n [editConfirm]=\"editConfirm()\"\n [editCancel]=\"editCancel\"\n ></ng2-st-tbody-create-cancel>\n </td>\n } @if (!row.isInEditing && grid().isActionsVisible() ) {\n <td class=\"ng2-smart-actions\" (click)=\"$event.stopPropagation()\">\n <ng2-st-tbody-custom\n [grid]=\"grid()\"\n (custom)=\"custom.emit($event)\"\n [row]=\"row\"\n [source]=\"source()\"\n ></ng2-st-tbody-custom>\n <ng2-st-tbody-edit-delete\n [grid]=\"grid()\"\n [deleteConfirm]=\"deleteConfirm()\"\n (edit)=\"edit.emit(row)\"\n (delete)=\"delete.emit(row)\"\n [row]=\"row\"\n [source]=\"source()\"\n >\n </ng2-st-tbody-edit-delete>\n </td>\n }\n</ng-template>\n} @empty {\n<tr>\n <td colspan=\"50\">\n {{ noDataMessage() }}\n </td>\n</tr>\n}\n", styles: [":host .ng2-smart-row.selected{background:#0000000d}:host .ng2-smart-row .ng2-smart-actions.ng2-smart-action-multiple-select{text-align:center}:host ::ng-deep ng2-st-tbody-edit-delete a:first-child,:host ::ng-deep ng2-st-tbody-create-cancel a:first-child{margin-right:.25rem}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: TbodyCustomComponent, selector: "ng2-st-tbody-custom", inputs: ["grid", "row", "source"], outputs: ["custom"] }, { kind: "component", type: TbodyEditDeleteComponent, selector: "ng2-st-tbody-edit-delete", inputs: ["grid", "row", "source", "deleteConfirm"], outputs: ["edit", "delete"] }, { kind: "component", type: TbodyCreateCancelComponent, selector: "ng2-st-tbody-create-cancel", inputs: ["grid", "row", "editConfirm", "editCancel"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: CellComponent, selector: "ng2-smart-table-cell", inputs: ["cell", "inputClass", "isInEditing"] }] }); }
2066
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.3", type: Ng2SmartTableTbodyComponent, isStandalone: true, selector: "[ng2-st-tbody]", inputs: { grid: { classPropertyName: "grid", publicName: "grid", isSignal: true, isRequired: true, transformFunction: null }, source: { classPropertyName: "source", publicName: "source", isSignal: true, isRequired: true, transformFunction: null }, deleteConfirm: { classPropertyName: "deleteConfirm", publicName: "deleteConfirm", isSignal: true, isRequired: true, transformFunction: null }, createConfirm: { classPropertyName: "createConfirm", publicName: "createConfirm", isSignal: true, isRequired: true, transformFunction: null }, editConfirm: { classPropertyName: "editConfirm", publicName: "editConfirm", isSignal: true, isRequired: true, transformFunction: null }, rowClassFunction: { classPropertyName: "rowClassFunction", publicName: "rowClassFunction", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { save: "save", edit: "edit", editCancel: "editCancel", delete: "delete", custom: "custom", edited: "edited", userSelectRow: "userSelectRow", userClickedRow: "userClickedRow", multipleSelectRow: "multipleSelectRow" }, ngImport: i0, template: "@for (row of grid().dataSet.getRows(); track trackByIdOrIndex($index, row)) {\n<tr\n (click)=\"userClickedRow.emit(row)\"\n class=\"ng2-smart-row\"\n [class]=\"rowClassFunction()(row)\"\n [class.selected]=\"row.isSelected()\">\n @if (grid().isMultiSelectVisible()) {\n <td\n class=\"ng2-smart-actions ng2-smart-action-multiple-select\"\n (click)=\"$event.stopPropagation(); multipleSelectRow.emit(row)\">\n <input\n type=\"checkbox\"\n [id]=\"'row-' + row.index + '_select-checkbox'\"\n class=\"form-control\"\n [ngModel]=\"row.isSelected()\" />\n </td>\n } @if (grid().actionIsOnLeft()) {\n <ng-container [ngTemplateOutlet]=\"actions\"></ng-container>\n } @for (cell of row.visibleCells(); track cell.getId() + $index) {\n <td [class]=\"cell.getColumnClass()\">\n <ng2-smart-table-cell [cell]=\"cell\" [inputClass]=\"editInputClass()\" [isInEditing]=\"row.isInEditing()\">\n </ng2-smart-table-cell>\n </td>\n } @if (grid().actionIsOnRight()) {\n <ng-container [ngTemplateOutlet]=\"actions\"></ng-container>\n }\n</tr>\n\n<ng-template #actions>\n @if (row.isInEditing()) {\n <td class=\"ng2-smart-actions\">\n <ng2-st-tbody-create-cancel\n [grid]=\"grid()\"\n [row]=\"row\"\n [editConfirm]=\"editConfirm()\"\n [editCancel]=\"editCancel\"></ng2-st-tbody-create-cancel>\n </td>\n } @if (!row.isInEditing() && grid().isActionsVisible() ) {\n <td class=\"ng2-smart-actions\" (click)=\"$event.stopPropagation()\">\n <ng2-st-tbody-custom\n [grid]=\"grid()\"\n (custom)=\"custom.emit($event)\"\n [row]=\"row\"\n [source]=\"source()\"></ng2-st-tbody-custom>\n <ng2-st-tbody-edit-delete\n [grid]=\"grid()\"\n [deleteConfirm]=\"deleteConfirm()\"\n (edit)=\"edit.emit(row)\"\n (delete)=\"delete.emit(row)\"\n [row]=\"row\"\n [source]=\"source()\">\n </ng2-st-tbody-edit-delete>\n </td>\n }\n</ng-template>\n} @empty {\n<tr>\n <td colspan=\"50\">\n {{ noDataMessage() }}\n </td>\n</tr>\n}\n", styles: [":host .ng2-smart-row.selected{background:#0000000d}:host .ng2-smart-row .ng2-smart-actions.ng2-smart-action-multiple-select{text-align:center}:host ::ng-deep ng2-st-tbody-edit-delete a:first-child,:host ::ng-deep ng2-st-tbody-create-cancel a:first-child{margin-right:.25rem}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: TbodyCustomComponent, selector: "ng2-st-tbody-custom", inputs: ["grid", "row", "source"], outputs: ["custom"] }, { kind: "component", type: TbodyEditDeleteComponent, selector: "ng2-st-tbody-edit-delete", inputs: ["grid", "row", "source", "deleteConfirm"], outputs: ["edit", "delete"] }, { kind: "component", type: TbodyCreateCancelComponent, selector: "ng2-st-tbody-create-cancel", inputs: ["grid", "row", "editConfirm", "editCancel"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: CellComponent, selector: "ng2-smart-table-cell", inputs: ["cell", "inputClass", "isInEditing"] }] }); }
2463
2067
  }
2464
2068
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: Ng2SmartTableTbodyComponent, decorators: [{
2465
2069
  type: Component,
@@ -2470,133 +2074,62 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
2470
2074
  TbodyCreateCancelComponent,
2471
2075
  NgTemplateOutlet,
2472
2076
  CellComponent,
2473
- ], template: "@for (row of grid().getRows(); track trackByIdOrIndex($index, row)) {\n<tr\n (click)=\"userClickedRow.emit(row)\"\n class=\"ng2-smart-row\"\n [class]=\"rowClassFunction()(row)\"\n [class.selected]=\"row.isSelected\"\n>\n @if (grid().isMultiSelectVisible()) {\n <td\n class=\"ng2-smart-actions ng2-smart-action-multiple-select\"\n (click)=\"$event.stopPropagation(); multipleSelectRow.emit(row)\"\n >\n <input\n type=\"checkbox\"\n [id]=\"'row-' + row.index + '_select-checkbox'\"\n class=\"form-control\"\n [ngModel]=\"row.isSelected\"\n />\n </td>\n } @if (grid().actionIsOnLeft()) {\n <ng-container [ngTemplateOutlet]=\"actions\"></ng-container>\n } @for (cell of getVisibleCells(row.cells); track cell.getId() + $index) {\n <td [class]=\"cell.getColumnClass()\">\n <ng2-smart-table-cell\n [cell]=\"cell\"\n [inputClass]=\"editInputClass()\"\n [isInEditing]=\"row.isInEditing\"\n >\n </ng2-smart-table-cell>\n </td>\n } @if (grid().actionIsOnRight()) {\n <ng-container [ngTemplateOutlet]=\"actions\"></ng-container>\n }\n</tr>\n\n<ng-template #actions>\n @if (row.isInEditing) {\n <td class=\"ng2-smart-actions\">\n <ng2-st-tbody-create-cancel\n [grid]=\"grid()\"\n [row]=\"row\"\n [editConfirm]=\"editConfirm()\"\n [editCancel]=\"editCancel\"\n ></ng2-st-tbody-create-cancel>\n </td>\n } @if (!row.isInEditing && grid().isActionsVisible() ) {\n <td class=\"ng2-smart-actions\" (click)=\"$event.stopPropagation()\">\n <ng2-st-tbody-custom\n [grid]=\"grid()\"\n (custom)=\"custom.emit($event)\"\n [row]=\"row\"\n [source]=\"source()\"\n ></ng2-st-tbody-custom>\n <ng2-st-tbody-edit-delete\n [grid]=\"grid()\"\n [deleteConfirm]=\"deleteConfirm()\"\n (edit)=\"edit.emit(row)\"\n (delete)=\"delete.emit(row)\"\n [row]=\"row\"\n [source]=\"source()\"\n >\n </ng2-st-tbody-edit-delete>\n </td>\n }\n</ng-template>\n} @empty {\n<tr>\n <td colspan=\"50\">\n {{ noDataMessage() }}\n </td>\n</tr>\n}\n", styles: [":host .ng2-smart-row.selected{background:#0000000d}:host .ng2-smart-row .ng2-smart-actions.ng2-smart-action-multiple-select{text-align:center}:host ::ng-deep ng2-st-tbody-edit-delete a:first-child,:host ::ng-deep ng2-st-tbody-create-cancel a:first-child{margin-right:.25rem}\n"] }]
2077
+ ], template: "@for (row of grid().dataSet.getRows(); track trackByIdOrIndex($index, row)) {\n<tr\n (click)=\"userClickedRow.emit(row)\"\n class=\"ng2-smart-row\"\n [class]=\"rowClassFunction()(row)\"\n [class.selected]=\"row.isSelected()\">\n @if (grid().isMultiSelectVisible()) {\n <td\n class=\"ng2-smart-actions ng2-smart-action-multiple-select\"\n (click)=\"$event.stopPropagation(); multipleSelectRow.emit(row)\">\n <input\n type=\"checkbox\"\n [id]=\"'row-' + row.index + '_select-checkbox'\"\n class=\"form-control\"\n [ngModel]=\"row.isSelected()\" />\n </td>\n } @if (grid().actionIsOnLeft()) {\n <ng-container [ngTemplateOutlet]=\"actions\"></ng-container>\n } @for (cell of row.visibleCells(); track cell.getId() + $index) {\n <td [class]=\"cell.getColumnClass()\">\n <ng2-smart-table-cell [cell]=\"cell\" [inputClass]=\"editInputClass()\" [isInEditing]=\"row.isInEditing()\">\n </ng2-smart-table-cell>\n </td>\n } @if (grid().actionIsOnRight()) {\n <ng-container [ngTemplateOutlet]=\"actions\"></ng-container>\n }\n</tr>\n\n<ng-template #actions>\n @if (row.isInEditing()) {\n <td class=\"ng2-smart-actions\">\n <ng2-st-tbody-create-cancel\n [grid]=\"grid()\"\n [row]=\"row\"\n [editConfirm]=\"editConfirm()\"\n [editCancel]=\"editCancel\"></ng2-st-tbody-create-cancel>\n </td>\n } @if (!row.isInEditing() && grid().isActionsVisible() ) {\n <td class=\"ng2-smart-actions\" (click)=\"$event.stopPropagation()\">\n <ng2-st-tbody-custom\n [grid]=\"grid()\"\n (custom)=\"custom.emit($event)\"\n [row]=\"row\"\n [source]=\"source()\"></ng2-st-tbody-custom>\n <ng2-st-tbody-edit-delete\n [grid]=\"grid()\"\n [deleteConfirm]=\"deleteConfirm()\"\n (edit)=\"edit.emit(row)\"\n (delete)=\"delete.emit(row)\"\n [row]=\"row\"\n [source]=\"source()\">\n </ng2-st-tbody-edit-delete>\n </td>\n }\n</ng-template>\n} @empty {\n<tr>\n <td colspan=\"50\">\n {{ noDataMessage() }}\n </td>\n</tr>\n}\n", styles: [":host .ng2-smart-row.selected{background:#0000000d}:host .ng2-smart-row .ng2-smart-actions.ng2-smart-action-multiple-select{text-align:center}:host ::ng-deep ng2-st-tbody-edit-delete a:first-child,:host ::ng-deep ng2-st-tbody-create-cancel a:first-child{margin-right:.25rem}\n"] }]
2474
2078
  }] });
2475
2079
 
2476
- class FilterDefault {
2477
- constructor() {
2478
- this.column = input.required();
2479
- this.source = input.required();
2480
- this.inputClass = input('');
2481
- this.query = '';
2482
- this.filter = output();
2483
- }
2484
- onFilter(query) {
2485
- this.source().addFilter({
2486
- field: this.column().id,
2487
- search: query,
2488
- filter: this.column().getFilterFunction(),
2489
- });
2490
- }
2491
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: FilterDefault, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
2492
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.0.3", type: FilterDefault, isStandalone: true, selector: "ng2-filter-default-component", inputs: { column: { classPropertyName: "column", publicName: "column", isSignal: true, isRequired: true, transformFunction: null }, source: { classPropertyName: "source", publicName: "source", isSignal: true, isRequired: true, transformFunction: null }, inputClass: { classPropertyName: "inputClass", publicName: "inputClass", isSignal: true, isRequired: false, transformFunction: null }, query: { classPropertyName: "query", publicName: "query", isSignal: false, isRequired: false, transformFunction: null } }, outputs: { filter: "filter" }, ngImport: i0, template: '', isInline: true }); }
2493
- }
2494
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: FilterDefault, decorators: [{
2495
- type: Component,
2496
- args: [{ template: '', selector: 'ng2-filter-default-component' }]
2497
- }], propDecorators: { query: [{
2498
- type: Input
2499
- }] } });
2500
-
2501
- class CustomFilterComponent extends FilterDefault {
2502
- ngOnChanges(changes) {
2503
- if (this.customComponent) {
2504
- if (this.customComponent?.instance &&
2505
- "ngOnChanges" in this.customComponent.instance) {
2506
- const onChanges = this.customComponent.instance.ngOnChanges;
2507
- onChanges(changes);
2508
- }
2509
- return;
2510
- }
2511
- const columnFilter = this.column().filter;
2512
- if (columnFilter && columnFilter.type === "custom") {
2513
- this.customComponent = this.dynamicTarget?.createComponent(columnFilter?.component);
2514
- // set @Inputs and @Outputs of custom component
2515
- this.customComponent?.setInput("query", this.query);
2516
- this.customComponent?.setInput("column", this.column());
2517
- this.customComponent?.setInput("source", this.source());
2518
- this.customComponent?.setInput("inputClass", this.inputClass());
2519
- this.customComponent?.instance.filter.subscribe((event) => this.onFilter(event));
2520
- }
2521
- }
2522
- ngOnDestroy() {
2523
- if (this.customComponent) {
2524
- this.customComponent.destroy();
2525
- }
2526
- }
2527
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: CustomFilterComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
2528
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.3", type: CustomFilterComponent, isStandalone: true, selector: "ng2-custom-table-filter", viewQueries: [{ propertyName: "dynamicTarget", first: true, predicate: ["dynamicTarget"], descendants: true, read: ViewContainerRef, static: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: `<ng-template #dynamicTarget></ng-template>`, isInline: true }); }
2529
- }
2530
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: CustomFilterComponent, decorators: [{
2531
- type: Component,
2532
- args: [{
2533
- selector: "ng2-custom-table-filter",
2534
- template: `<ng-template #dynamicTarget></ng-template>`,
2535
- standalone: true,
2536
- }]
2537
- }], propDecorators: { dynamicTarget: [{
2538
- type: ViewChild,
2539
- args: ["dynamicTarget", { read: ViewContainerRef, static: true }]
2540
- }] } });
2541
-
2542
- class CheckboxFilterComponent extends DefaultFilter {
2080
+ class CheckboxFilterComponent extends BaseFilterComponent {
2543
2081
  constructor() {
2544
2082
  super();
2545
2083
  this.filterActive = false;
2546
- this.inputControl = new UntypedFormControl();
2084
+ this.trueVal = true;
2085
+ this.falseVal = false;
2547
2086
  }
2548
2087
  ngOnInit() {
2088
+ const filterConfig = this.column().getFilterConfig();
2089
+ try {
2090
+ const { true: trueVal, false: falseVal } = filterConfig;
2091
+ this.trueVal = trueVal ?? true;
2092
+ this.falseVal = falseVal ?? false;
2093
+ }
2094
+ catch {
2095
+ // do nothing
2096
+ }
2549
2097
  this.changesSubscription = this.inputControl.valueChanges
2550
- .pipe(debounceTime(this.delay))
2098
+ .pipe(distinctUntilChanged(), debounceTime(this.delay))
2551
2099
  .subscribe((checked) => {
2552
2100
  this.filterActive = true;
2553
- const trueVal = (this.column().getFilterConfig() &&
2554
- this.column().getFilterConfig().true) ||
2555
- true;
2556
- const falseVal = (this.column().getFilterConfig() &&
2557
- this.column().getFilterConfig().false) ||
2558
- false;
2559
- this.query = checked ? trueVal : falseVal;
2560
- this.setFilter();
2101
+ const value = checked ? this.trueVal : this.falseVal;
2102
+ this.setFilter(value);
2561
2103
  });
2562
2104
  }
2105
+ ngOnChanges({ query }) {
2106
+ if (query) {
2107
+ this.inputControl.setValue(query.currentValue === this.trueVal, { emitEvent: false });
2108
+ }
2109
+ }
2563
2110
  resetFilter(event) {
2564
2111
  event.preventDefault();
2565
- this.query = "";
2112
+ event.stopPropagation();
2566
2113
  this.inputControl.setValue(false, { emitEvent: false });
2567
2114
  this.filterActive = false;
2568
- this.setFilter();
2115
+ this.setFilter(null);
2569
2116
  }
2570
2117
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: CheckboxFilterComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
2571
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.3", type: CheckboxFilterComponent, isStandalone: true, selector: "ng2-checkbox-filter", usesInheritance: true, ngImport: i0, template: `
2572
- <input
2573
- type="checkbox"
2574
- [formControl]="inputControl"
2575
- [class]="inputClass()"
2576
- class="form-control"
2577
- />
2118
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.3", type: CheckboxFilterComponent, isStandalone: true, selector: "ng2-checkbox-filter", usesInheritance: true, usesOnChanges: true, ngImport: i0, template: `
2119
+ <input type="checkbox" [formControl]="inputControl" [class]="inputClass()" class="form-control" />
2578
2120
  @if (filterActive) {
2579
- <a href="#" (click)="resetFilter($event)">{{
2580
- column().getFilterConfig()?.resetText || "reset"
2581
- }}</a>
2121
+ <a href="#" (click)="resetFilter($event)">{{ column().getFilterConfig()?.resetText || 'reset' }}</a>
2582
2122
  }
2583
2123
  `, isInline: true, dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }] }); }
2584
2124
  }
2585
2125
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: CheckboxFilterComponent, decorators: [{
2586
2126
  type: Component,
2587
2127
  args: [{
2588
- selector: "ng2-checkbox-filter",
2128
+ selector: 'ng2-checkbox-filter',
2589
2129
  template: `
2590
- <input
2591
- type="checkbox"
2592
- [formControl]="inputControl"
2593
- [class]="inputClass()"
2594
- class="form-control"
2595
- />
2130
+ <input type="checkbox" [formControl]="inputControl" [class]="inputClass()" class="form-control" />
2596
2131
  @if (filterActive) {
2597
- <a href="#" (click)="resetFilter($event)">{{
2598
- column().getFilterConfig()?.resetText || "reset"
2599
- }}</a>
2132
+ <a href="#" (click)="resetFilter($event)">{{ column().getFilterConfig()?.resetText || 'reset' }}</a>
2600
2133
  }
2601
2134
  `,
2602
2135
  standalone: true,
@@ -2604,264 +2137,269 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
2604
2137
  }]
2605
2138
  }], ctorParameters: () => [] });
2606
2139
 
2607
- class InputFilterComponent extends DefaultFilter {
2608
- constructor() {
2609
- super();
2610
- this.inputControl = new UntypedFormControl();
2611
- }
2612
- ngOnInit() {
2613
- if (this.query) {
2614
- this.inputControl.setValue(this.query);
2615
- }
2616
- this.inputControl.valueChanges
2617
- .pipe(distinctUntilChanged(), debounceTime(this.delay))
2618
- .subscribe((value) => {
2619
- this.query = this.inputControl.value;
2620
- this.setFilter();
2621
- });
2622
- }
2623
- ngOnChanges(changes) {
2624
- if (changes?.["query"]) {
2625
- this.inputControl.setValue(this.query);
2626
- }
2627
- }
2628
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: InputFilterComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
2629
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.3", type: InputFilterComponent, isStandalone: true, selector: "ng2-input-filter", usesInheritance: true, usesOnChanges: true, ngImport: i0, template: `
2140
+ class InputFilterComponent extends BaseFilterComponent {
2141
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: InputFilterComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
2142
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.3", type: InputFilterComponent, isStandalone: true, selector: "ng2-input-filter", usesInheritance: true, ngImport: i0, template: `
2630
2143
  <input
2631
2144
  [class]="inputClass()"
2632
2145
  [formControl]="inputControl"
2633
2146
  class="form-control"
2634
2147
  type="text"
2635
- placeholder="{{ column().title }}"
2636
- />
2148
+ placeholder="{{ column().title }}" />
2637
2149
  `, isInline: true, dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }] }); }
2638
2150
  }
2639
2151
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: InputFilterComponent, decorators: [{
2640
2152
  type: Component,
2641
2153
  args: [{
2642
- selector: "ng2-input-filter",
2154
+ selector: 'ng2-input-filter',
2643
2155
  template: `
2644
2156
  <input
2645
2157
  [class]="inputClass()"
2646
2158
  [formControl]="inputControl"
2647
2159
  class="form-control"
2648
2160
  type="text"
2649
- placeholder="{{ column().title }}"
2650
- />
2161
+ placeholder="{{ column().title }}" />
2651
2162
  `,
2652
2163
  standalone: true,
2653
2164
  imports: [FormsModule, ReactiveFormsModule],
2654
2165
  }]
2655
- }], ctorParameters: () => [] });
2656
-
2657
- class SelectFilterComponent extends DefaultFilter {
2658
- constructor() {
2659
- super();
2660
- }
2661
- ngOnInit() {
2662
- if (this.inputControl.valueChanges) {
2663
- this.inputControl.valueChanges
2664
- .pipe(skip(1), distinctUntilChanged(), debounceTime(this.delay))
2665
- .subscribe((value) => this.setFilter());
2666
- }
2667
- }
2668
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: SelectFilterComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
2669
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.3", type: SelectFilterComponent, isStandalone: true, selector: "ng2-select-filter", viewQueries: [{ propertyName: "inputControl", first: true, predicate: ["inputControl"], descendants: true, read: NgControl, static: true }], usesInheritance: true, ngImport: i0, template: `
2670
- <select [class]="inputClass()"
2671
- class="form-control"
2672
- #inputControl
2673
- [(ngModel)]="query">
2166
+ }] });
2674
2167
 
2168
+ class SelectFilterComponent extends BaseFilterComponent {
2169
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: SelectFilterComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
2170
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.3", type: SelectFilterComponent, isStandalone: true, selector: "ng2-select-filter", usesInheritance: true, ngImport: i0, template: `
2171
+ <select [class]="inputClass()" class="form-control" [formControl]="inputControl">
2675
2172
  <option value="">{{ column().getFilterConfig().selectText }}</option>
2676
2173
  @for (option of column().getFilterConfig().list; track $index) {
2677
- <option [value]="option.value">
2678
- {{ option.title }}
2679
- </option>
2174
+ <option [value]="option.value">
2175
+ {{ option.title }}
2176
+ </option>
2680
2177
  }
2681
2178
  </select>
2682
- `, isInline: true, dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }] }); }
2179
+ `, isInline: true, dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }] }); }
2683
2180
  }
2684
2181
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: SelectFilterComponent, decorators: [{
2685
2182
  type: Component,
2686
2183
  args: [{
2687
2184
  selector: 'ng2-select-filter',
2688
2185
  template: `
2689
- <select [class]="inputClass()"
2690
- class="form-control"
2691
- #inputControl
2692
- [(ngModel)]="query">
2693
-
2186
+ <select [class]="inputClass()" class="form-control" [formControl]="inputControl">
2694
2187
  <option value="">{{ column().getFilterConfig().selectText }}</option>
2695
2188
  @for (option of column().getFilterConfig().list; track $index) {
2696
- <option [value]="option.value">
2697
- {{ option.title }}
2698
- </option>
2189
+ <option [value]="option.value">
2190
+ {{ option.title }}
2191
+ </option>
2699
2192
  }
2700
2193
  </select>
2701
- `,
2194
+ `,
2702
2195
  standalone: true,
2703
- imports: [FormsModule]
2196
+ imports: [FormsModule, ReactiveFormsModule],
2704
2197
  }]
2705
- }], ctorParameters: () => [], propDecorators: { inputControl: [{
2706
- type: ViewChild,
2707
- args: ['inputControl', { read: NgControl, static: true }]
2708
- }] } });
2198
+ }] });
2709
2199
 
2710
- class DefaultFilterComponent extends FilterDefault {
2711
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: DefaultFilterComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
2712
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.3", type: DefaultFilterComponent, isStandalone: true, selector: "ng2-default-table-filter", usesInheritance: true, ngImport: i0, template: `
2200
+ class BuildInFilterComponent {
2201
+ constructor() {
2202
+ this.query = input('');
2203
+ this.inputClass = input('');
2204
+ this.source = input.required();
2205
+ this.column = input.required();
2206
+ this.filter = output();
2207
+ }
2208
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: BuildInFilterComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
2209
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.3", type: BuildInFilterComponent, isStandalone: true, selector: "ng2-build-in-table-filter", inputs: { query: { classPropertyName: "query", publicName: "query", isSignal: true, isRequired: false, transformFunction: null }, inputClass: { classPropertyName: "inputClass", publicName: "inputClass", isSignal: true, isRequired: false, transformFunction: null }, source: { classPropertyName: "source", publicName: "source", isSignal: true, isRequired: true, transformFunction: null }, column: { classPropertyName: "column", publicName: "column", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { filter: "filter" }, ngImport: i0, template: `
2713
2210
  @switch (column().getFilterType()) { @case ('list') {
2714
2211
  <ng2-select-filter
2715
- [query]="query"
2212
+ [query]="query()"
2716
2213
  [class]="inputClass()"
2717
2214
  [source]="source()"
2718
2215
  [column]="column()"
2719
- (filter)="onFilter($event)"
2720
- >
2216
+ (filter)="filter.emit($event)">
2721
2217
  </ng2-select-filter>
2722
2218
  } @case ('checkbox') {
2723
2219
  <ng2-checkbox-filter
2724
- [query]="query"
2220
+ [query]="query()"
2725
2221
  [source]="source()"
2726
2222
  [class]="inputClass()"
2727
2223
  [column]="column()"
2728
- (filter)="onFilter($event)"
2729
- >
2224
+ (filter)="filter.emit($event)">
2730
2225
  </ng2-checkbox-filter>
2731
2226
  } @default {
2732
2227
  <ng2-input-filter
2733
- [query]="query"
2228
+ [query]="query()"
2734
2229
  [source]="source()"
2735
2230
  [class]="inputClass()"
2736
2231
  [column]="column()"
2737
- (filter)="onFilter($event)"
2738
- >
2232
+ (filter)="filter.emit($event)">
2739
2233
  </ng2-input-filter>
2740
2234
  } }
2741
2235
  `, isInline: true, dependencies: [{ kind: "component", type: SelectFilterComponent, selector: "ng2-select-filter" }, { kind: "component", type: CheckboxFilterComponent, selector: "ng2-checkbox-filter" }, { kind: "component", type: InputFilterComponent, selector: "ng2-input-filter" }] }); }
2742
2236
  }
2743
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: DefaultFilterComponent, decorators: [{
2237
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: BuildInFilterComponent, decorators: [{
2744
2238
  type: Component,
2745
2239
  args: [{
2746
- selector: "ng2-default-table-filter",
2240
+ selector: 'ng2-build-in-table-filter',
2747
2241
  template: `
2748
2242
  @switch (column().getFilterType()) { @case ('list') {
2749
2243
  <ng2-select-filter
2750
- [query]="query"
2244
+ [query]="query()"
2751
2245
  [class]="inputClass()"
2752
2246
  [source]="source()"
2753
2247
  [column]="column()"
2754
- (filter)="onFilter($event)"
2755
- >
2248
+ (filter)="filter.emit($event)">
2756
2249
  </ng2-select-filter>
2757
2250
  } @case ('checkbox') {
2758
2251
  <ng2-checkbox-filter
2759
- [query]="query"
2252
+ [query]="query()"
2760
2253
  [source]="source()"
2761
2254
  [class]="inputClass()"
2762
2255
  [column]="column()"
2763
- (filter)="onFilter($event)"
2764
- >
2256
+ (filter)="filter.emit($event)">
2765
2257
  </ng2-checkbox-filter>
2766
2258
  } @default {
2767
2259
  <ng2-input-filter
2768
- [query]="query"
2260
+ [query]="query()"
2769
2261
  [source]="source()"
2770
2262
  [class]="inputClass()"
2771
2263
  [column]="column()"
2772
- (filter)="onFilter($event)"
2773
- >
2264
+ (filter)="filter.emit($event)">
2774
2265
  </ng2-input-filter>
2775
2266
  } }
2776
2267
  `,
2777
2268
  standalone: true,
2778
- imports: [
2779
- SelectFilterComponent,
2780
- CheckboxFilterComponent,
2781
- InputFilterComponent,
2782
- ],
2269
+ imports: [SelectFilterComponent, CheckboxFilterComponent, InputFilterComponent],
2783
2270
  }]
2784
2271
  }] });
2785
2272
 
2786
- class FilterComponent extends FilterDefault {
2273
+ class CustomFilterComponent {
2274
+ constructor() {
2275
+ this.query = input('');
2276
+ this.inputClass = input('');
2277
+ this.source = input.required();
2278
+ this.column = input.required();
2279
+ this.filter = output();
2280
+ }
2787
2281
  ngOnChanges(changes) {
2788
- if (changes['source']) {
2789
- if (!changes['source'].firstChange && this.dataChangedSub) {
2790
- this.dataChangedSub.unsubscribe();
2282
+ if (this.customComponent) {
2283
+ if (this.customComponent?.instance && 'ngOnChanges' in this.customComponent.instance) {
2284
+ const onChanges = this.customComponent.instance.ngOnChanges;
2285
+ onChanges(changes);
2791
2286
  }
2792
- this.dataChangedSub = this.source().onChanged().subscribe((dataChanges) => {
2793
- const filterConf = this.source().getFilter();
2794
- if (filterConf && filterConf.filters && filterConf.filters.length === 0) {
2795
- this.query = '';
2796
- // add a check for existing filters an set the query if one exists for this column
2797
- // this covers instances where the filter is set by user code while maintaining existing functionality
2798
- }
2799
- else if (filterConf && filterConf.filters && filterConf.filters.length > 0) {
2800
- filterConf.filters.forEach((k, v) => {
2801
- if (k.field == this.column().id) {
2802
- this.query = k.search;
2803
- }
2804
- });
2805
- }
2806
- });
2287
+ return;
2288
+ }
2289
+ const columnFilter = this.column().filter;
2290
+ if (columnFilter && columnFilter.type === 'custom') {
2291
+ this.customComponent = this.dynamicTarget?.createComponent(columnFilter?.component);
2292
+ // set @Inputs and @Outputs of custom component
2293
+ this.customComponent?.setInput('query', this.query());
2294
+ this.customComponent?.setInput('column', this.column());
2295
+ this.customComponent?.setInput('source', this.source());
2296
+ this.customComponent?.setInput('inputClass', this.inputClass());
2297
+ this.filterSubscription = this.customComponent?.instance.filter.subscribe((event) => this.filter.emit(event));
2807
2298
  }
2808
2299
  }
2809
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: FilterComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
2810
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.3", type: FilterComponent, isStandalone: true, selector: "ng2-smart-table-filter", usesInheritance: true, usesOnChanges: true, ngImport: i0, template: `
2811
- @if (column().isFilterable) {
2812
- <div class="ng2-smart-filter">
2813
- @switch (column().getFilterType()) {
2814
- @case ('custom') {
2815
- <ng2-custom-table-filter
2816
- [query]="query"
2817
- [column]="column()"
2818
- [source]="source()"
2819
- [inputClass]="inputClass()"
2820
- (filter)="onFilter($event)">
2821
- </ng2-custom-table-filter>
2300
+ ngOnDestroy() {
2301
+ if (this.customComponent) {
2302
+ this.customComponent.destroy();
2303
+ }
2304
+ if (this.filterSubscription) {
2305
+ this.filterSubscription.unsubscribe();
2306
+ }
2307
+ }
2308
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: CustomFilterComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
2309
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.0.3", type: CustomFilterComponent, isStandalone: true, selector: "ng2-custom-table-filter", inputs: { query: { classPropertyName: "query", publicName: "query", isSignal: true, isRequired: false, transformFunction: null }, inputClass: { classPropertyName: "inputClass", publicName: "inputClass", isSignal: true, isRequired: false, transformFunction: null }, source: { classPropertyName: "source", publicName: "source", isSignal: true, isRequired: true, transformFunction: null }, column: { classPropertyName: "column", publicName: "column", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { filter: "filter" }, viewQueries: [{ propertyName: "dynamicTarget", first: true, predicate: ["dynamicTarget"], descendants: true, read: ViewContainerRef, static: true }], usesOnChanges: true, ngImport: i0, template: `<ng-template #dynamicTarget></ng-template>`, isInline: true }); }
2310
+ }
2311
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: CustomFilterComponent, decorators: [{
2312
+ type: Component,
2313
+ args: [{
2314
+ selector: 'ng2-custom-table-filter',
2315
+ template: `<ng-template #dynamicTarget></ng-template>`,
2316
+ standalone: true,
2317
+ }]
2318
+ }], propDecorators: { dynamicTarget: [{
2319
+ type: ViewChild,
2320
+ args: ['dynamicTarget', { read: ViewContainerRef, static: true }]
2321
+ }] } });
2322
+
2323
+ class FilterComponent {
2324
+ constructor() {
2325
+ this.query = signal('');
2326
+ this.column = input.required();
2327
+ this.source = input.required();
2328
+ this.inputClass = input('');
2329
+ this.destroyRef = inject(DestroyRef);
2330
+ }
2331
+ ngOnInit() {
2332
+ this.source()
2333
+ .onChanged()
2334
+ .pipe(takeUntilDestroyed(this.destroyRef))
2335
+ .subscribe(({ filters }) => {
2336
+ if (!filters.length) {
2337
+ return;
2822
2338
  }
2823
- @default {
2824
- <ng2-default-table-filter
2825
- [query]="query"
2826
- [column]="column()"
2827
- [source]="source()"
2828
- [inputClass]="inputClass()"
2829
- (filter)="onFilter($event)">
2830
- </ng2-default-table-filter>
2339
+ const columnFilter = filters.find((filter) => filter.field === this.column().id);
2340
+ if (!columnFilter) {
2341
+ return;
2831
2342
  }
2832
- }
2833
- </div>
2834
- }
2835
- `, isInline: true, styles: [":host .ng2-smart-filter ::ng-deep input,:host .ng2-smart-filter ::ng-deep select{width:100%;line-height:normal;padding:.375em .75em;font-weight:400}:host .ng2-smart-filter ::ng-deep input[type=search]{box-sizing:inherit}:host .ng2-smart-filter ::ng-deep .completer-dropdown-holder{font-weight:400}:host .ng2-smart-filter ::ng-deep a{font-weight:400}\n"], dependencies: [{ kind: "component", type: CustomFilterComponent, selector: "ng2-custom-table-filter" }, { kind: "component", type: DefaultFilterComponent, selector: "ng2-default-table-filter" }] }); }
2343
+ this.query.set(columnFilter.search);
2344
+ });
2345
+ }
2346
+ onFilter(query) {
2347
+ this.source().addFilter({
2348
+ field: this.column().id,
2349
+ search: query,
2350
+ filter: this.column().filterFunction,
2351
+ });
2352
+ }
2353
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: FilterComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
2354
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.3", type: FilterComponent, isStandalone: true, selector: "ng2-smart-table-filter", inputs: { column: { classPropertyName: "column", publicName: "column", isSignal: true, isRequired: true, transformFunction: null }, source: { classPropertyName: "source", publicName: "source", isSignal: true, isRequired: true, transformFunction: null }, inputClass: { classPropertyName: "inputClass", publicName: "inputClass", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
2355
+ @if (column().isFilterable) {
2356
+ <div class="ng2-smart-filter">
2357
+ @switch (column().getFilterType()) { @case ('custom') {
2358
+ <ng2-custom-table-filter
2359
+ [query]="query()"
2360
+ [column]="column()"
2361
+ [source]="source()"
2362
+ [inputClass]="inputClass()"
2363
+ (filter)="onFilter($event)">
2364
+ </ng2-custom-table-filter>
2365
+ } @default {
2366
+ <ng2-build-in-table-filter
2367
+ [query]="query()"
2368
+ [column]="column()"
2369
+ [source]="source()"
2370
+ [inputClass]="inputClass()"
2371
+ (filter)="onFilter($event)">
2372
+ </ng2-build-in-table-filter>
2373
+ } }
2374
+ </div>
2375
+ }
2376
+ `, isInline: true, styles: [":host .ng2-smart-filter ::ng-deep input,:host .ng2-smart-filter ::ng-deep select{width:100%;line-height:normal;padding:.375em .75em;font-weight:400}:host .ng2-smart-filter ::ng-deep input[type=search]{box-sizing:inherit}:host .ng2-smart-filter ::ng-deep .completer-dropdown-holder{font-weight:400}:host .ng2-smart-filter ::ng-deep a{font-weight:400}\n"], dependencies: [{ kind: "component", type: CustomFilterComponent, selector: "ng2-custom-table-filter", inputs: ["query", "inputClass", "source", "column"], outputs: ["filter"] }, { kind: "component", type: BuildInFilterComponent, selector: "ng2-build-in-table-filter", inputs: ["query", "inputClass", "source", "column"], outputs: ["filter"] }] }); }
2836
2377
  }
2837
2378
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: FilterComponent, decorators: [{
2838
2379
  type: Component,
2839
2380
  args: [{ selector: 'ng2-smart-table-filter', template: `
2840
- @if (column().isFilterable) {
2841
- <div class="ng2-smart-filter">
2842
- @switch (column().getFilterType()) {
2843
- @case ('custom') {
2844
- <ng2-custom-table-filter
2845
- [query]="query"
2846
- [column]="column()"
2847
- [source]="source()"
2848
- [inputClass]="inputClass()"
2849
- (filter)="onFilter($event)">
2850
- </ng2-custom-table-filter>
2851
- }
2852
- @default {
2853
- <ng2-default-table-filter
2854
- [query]="query"
2855
- [column]="column()"
2856
- [source]="source()"
2857
- [inputClass]="inputClass()"
2858
- (filter)="onFilter($event)">
2859
- </ng2-default-table-filter>
2860
- }
2861
- }
2862
- </div>
2863
- }
2864
- `, standalone: true, imports: [CustomFilterComponent, DefaultFilterComponent], styles: [":host .ng2-smart-filter ::ng-deep input,:host .ng2-smart-filter ::ng-deep select{width:100%;line-height:normal;padding:.375em .75em;font-weight:400}:host .ng2-smart-filter ::ng-deep input[type=search]{box-sizing:inherit}:host .ng2-smart-filter ::ng-deep .completer-dropdown-holder{font-weight:400}:host .ng2-smart-filter ::ng-deep a{font-weight:400}\n"] }]
2381
+ @if (column().isFilterable) {
2382
+ <div class="ng2-smart-filter">
2383
+ @switch (column().getFilterType()) { @case ('custom') {
2384
+ <ng2-custom-table-filter
2385
+ [query]="query()"
2386
+ [column]="column()"
2387
+ [source]="source()"
2388
+ [inputClass]="inputClass()"
2389
+ (filter)="onFilter($event)">
2390
+ </ng2-custom-table-filter>
2391
+ } @default {
2392
+ <ng2-build-in-table-filter
2393
+ [query]="query()"
2394
+ [column]="column()"
2395
+ [source]="source()"
2396
+ [inputClass]="inputClass()"
2397
+ (filter)="onFilter($event)">
2398
+ </ng2-build-in-table-filter>
2399
+ } }
2400
+ </div>
2401
+ }
2402
+ `, standalone: true, imports: [CustomFilterComponent, BuildInFilterComponent], styles: [":host .ng2-smart-filter ::ng-deep input,:host .ng2-smart-filter ::ng-deep select{width:100%;line-height:normal;padding:.375em .75em;font-weight:400}:host .ng2-smart-filter ::ng-deep input[type=search]{box-sizing:inherit}:host .ng2-smart-filter ::ng-deep .completer-dropdown-holder{font-weight:400}:host .ng2-smart-filter ::ng-deep a{font-weight:400}\n"] }]
2865
2403
  }] });
2866
2404
 
2867
2405
  class AddButtonComponent {
@@ -2934,7 +2472,6 @@ class TheadFiltersRowComponent {
2934
2472
  this.grid = input.required();
2935
2473
  this.source = input.required();
2936
2474
  this.create = output();
2937
- this.filter = output();
2938
2475
  this.filterInputClass = computed(() => {
2939
2476
  const filterOptions = this.grid().settings()?.filter;
2940
2477
  if (!filterOptions) {
@@ -2943,11 +2480,8 @@ class TheadFiltersRowComponent {
2943
2480
  return filterOptions.inputClass || "";
2944
2481
  });
2945
2482
  }
2946
- getVisibleColumns() {
2947
- return (this.grid().getColumns() || []).filter((column) => !column.hide);
2948
- }
2949
2483
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: TheadFiltersRowComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
2950
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.3", type: TheadFiltersRowComponent, isStandalone: true, selector: "[ng2-st-thead-filters-row]", inputs: { grid: { classPropertyName: "grid", publicName: "grid", isSignal: true, isRequired: true, transformFunction: null }, source: { classPropertyName: "source", publicName: "source", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { create: "create", filter: "filter" }, ngImport: i0, template: `
2484
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.3", type: TheadFiltersRowComponent, isStandalone: true, selector: "[ng2-st-thead-filters-row]", inputs: { grid: { classPropertyName: "grid", publicName: "grid", isSignal: true, isRequired: true, transformFunction: null }, source: { classPropertyName: "source", publicName: "source", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { create: "create" }, ngImport: i0, template: `
2951
2485
  @if (grid().isMultiSelectVisible()) {
2952
2486
  <th></th>
2953
2487
  } @if (grid().actionIsOnLeft() && grid().isActionsVisible()) {
@@ -2957,13 +2491,12 @@ class TheadFiltersRowComponent {
2957
2491
  [grid]="grid()"
2958
2492
  (create)="create.emit($event)"
2959
2493
  ></th>
2960
- } @for (column of getVisibleColumns(); track column.id + $index) {
2494
+ } @for (column of grid().dataSet.getVisibleColumns(); track column.id + $index) {
2961
2495
  <th class="ng2-smart-th {{ column.id }}">
2962
2496
  <ng2-smart-table-filter
2963
2497
  [source]="source()"
2964
2498
  [column]="column"
2965
2499
  [inputClass]="filterInputClass()"
2966
- (filter)="filter.emit($event)"
2967
2500
  >
2968
2501
  </ng2-smart-table-filter>
2969
2502
  </th>
@@ -2975,7 +2508,7 @@ class TheadFiltersRowComponent {
2975
2508
  (create)="create.emit($event)"
2976
2509
  ></th>
2977
2510
  }
2978
- `, isInline: true, dependencies: [{ kind: "component", type: AddButtonComponent, selector: "[ng2-st-add-button]", inputs: ["grid", "source"], outputs: ["create"] }, { kind: "component", type: FilterComponent, selector: "ng2-smart-table-filter" }] }); }
2511
+ `, isInline: true, dependencies: [{ kind: "component", type: AddButtonComponent, selector: "[ng2-st-add-button]", inputs: ["grid", "source"], outputs: ["create"] }, { kind: "component", type: FilterComponent, selector: "ng2-smart-table-filter", inputs: ["column", "source", "inputClass"] }] }); }
2979
2512
  }
2980
2513
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: TheadFiltersRowComponent, decorators: [{
2981
2514
  type: Component,
@@ -2991,13 +2524,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
2991
2524
  [grid]="grid()"
2992
2525
  (create)="create.emit($event)"
2993
2526
  ></th>
2994
- } @for (column of getVisibleColumns(); track column.id + $index) {
2527
+ } @for (column of grid().dataSet.getVisibleColumns(); track column.id + $index) {
2995
2528
  <th class="ng2-smart-th {{ column.id }}">
2996
2529
  <ng2-smart-table-filter
2997
2530
  [source]="source()"
2998
2531
  [column]="column"
2999
2532
  [inputClass]="filterInputClass()"
3000
- (filter)="filter.emit($event)"
3001
2533
  >
3002
2534
  </ng2-smart-table-filter>
3003
2535
  </th>
@@ -3089,7 +2621,7 @@ class TheadFormRowComponent {
3089
2621
  this.grid().create(this.grid().getNewRow(), this.createConfirm);
3090
2622
  }
3091
2623
  getVisibleCells() {
3092
- return (this.grid().getNewRow().getCells() || []).filter((cell) => !cell.getColumn().hide);
2624
+ return (this.grid().getNewRow().cells() || []).filter((cell) => !cell.getColumn().hide);
3093
2625
  }
3094
2626
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: TheadFormRowComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
3095
2627
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.3", type: TheadFormRowComponent, isStandalone: true, selector: "[ng2-st-thead-form-row]", inputs: { grid: { classPropertyName: "grid", publicName: "grid", isSignal: true, isRequired: true, transformFunction: null }, createConfirm: { classPropertyName: "createConfirm", publicName: "createConfirm", isSignal: false, isRequired: false, transformFunction: null } }, outputs: { create: "create" }, ngImport: i0, template: `
@@ -3107,7 +2639,7 @@ class TheadFormRowComponent {
3107
2639
  <ng2-smart-table-cell
3108
2640
  [cell]="cell"
3109
2641
  [inputClass]="addInputClass()"
3110
- [isInEditing]="grid().getNewRow().isInEditing"
2642
+ [isInEditing]="grid().getNewRow().isInEditing()"
3111
2643
  >
3112
2644
  </ng2-smart-table-cell>
3113
2645
  </td>
@@ -3140,7 +2672,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
3140
2672
  <ng2-smart-table-cell
3141
2673
  [cell]="cell"
3142
2674
  [inputClass]="addInputClass()"
3143
- [isInEditing]="grid().getNewRow().isInEditing"
2675
+ [isInEditing]="grid().getNewRow().isInEditing()"
3144
2676
  >
3145
2677
  </ng2-smart-table-cell>
3146
2678
  </td>
@@ -3192,7 +2724,7 @@ class CheckboxSelectAllComponent {
3192
2724
  }
3193
2725
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: CheckboxSelectAllComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
3194
2726
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.0.3", type: CheckboxSelectAllComponent, isStandalone: true, selector: "[ng2-st-checkbox-select-all]", inputs: { grid: { classPropertyName: "grid", publicName: "grid", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: `
3195
- <input type="checkbox" [ngModel]="this.grid().dataSet.isAllSelected" />
2727
+ <input type="checkbox" [ngModel]="this.grid().dataSet.isAllSelected()" />
3196
2728
  `, isInline: true, dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }] }); }
3197
2729
  }
3198
2730
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: CheckboxSelectAllComponent, decorators: [{
@@ -3200,7 +2732,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
3200
2732
  args: [{
3201
2733
  selector: "[ng2-st-checkbox-select-all]",
3202
2734
  template: `
3203
- <input type="checkbox" [ngModel]="this.grid().dataSet.isAllSelected" />
2735
+ <input type="checkbox" [ngModel]="this.grid().dataSet.isAllSelected()" />
3204
2736
  `,
3205
2737
  standalone: true,
3206
2738
  imports: [FormsModule],
@@ -3209,105 +2741,70 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
3209
2741
 
3210
2742
  class TitleComponent {
3211
2743
  constructor() {
3212
- this.currentDirection = "";
3213
2744
  this.source = input.required();
3214
2745
  this.column = input.required();
3215
- this.sort = output();
3216
- this.dataChangedSub = false;
2746
+ this.destroyRef = inject(DestroyRef);
2747
+ this.currentSortDirection = signal('');
3217
2748
  }
3218
- ngOnChanges(changes) {
3219
- if (changes["source"]) {
3220
- if (!changes["source"].firstChange && this.dataChangedSub) {
3221
- this.dataChangedSub.unsubscribe();
2749
+ ngOnInit() {
2750
+ this.source()
2751
+ .onChanged()
2752
+ .pipe(map(({ sort }) => {
2753
+ if (sort.field === this.column().id) {
2754
+ return sort.direction;
3222
2755
  }
3223
- this.dataChangedSub = this.source().onChanged().subscribe((dataChanges) => {
3224
- const sortConf = this.source().getSort();
3225
- if (sortConf.length > 0 && sortConf[0]["field"] === this.column().id) {
3226
- this.currentDirection = sortConf[0]["direction"];
3227
- }
3228
- else {
3229
- this.currentDirection = "";
3230
- }
3231
- });
3232
- }
3233
- }
3234
- ngOnDestroy() {
3235
- if (this.dataChangedSub) {
3236
- this.dataChangedSub?.unsubscribe();
3237
- }
2756
+ else {
2757
+ return '';
2758
+ }
2759
+ }), takeUntilDestroyed(this.destroyRef))
2760
+ .subscribe(this.currentSortDirection.set);
3238
2761
  }
3239
2762
  _sort(event) {
3240
2763
  event.preventDefault();
3241
- this.changeSortDirection();
3242
- this.source().setSort([
3243
- {
3244
- field: this.column().id,
3245
- direction: this.currentDirection === "desc" ? "desc" : "asc",
3246
- compare: this.column().getCompareFunction(),
3247
- },
3248
- ]);
3249
- this.sort.emit(null);
3250
- }
3251
- changeSortDirection() {
3252
- if (this.currentDirection) {
3253
- const newDirection = this.currentDirection === "asc" ? "desc" : "asc";
3254
- this.currentDirection = newDirection;
3255
- }
3256
- else {
3257
- this.currentDirection = this.column().sortDirection;
3258
- }
3259
- return this.currentDirection;
2764
+ this.source().setSort({
2765
+ field: this.column().id,
2766
+ direction: this.currentSortDirection() === 'desc' ? 'asc' : 'desc',
2767
+ compare: this.column().compareFunction,
2768
+ });
3260
2769
  }
3261
2770
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: TitleComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
3262
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.3", type: TitleComponent, isStandalone: true, selector: "ng2-smart-table-title", inputs: { source: { classPropertyName: "source", publicName: "source", isSignal: true, isRequired: true, transformFunction: null }, column: { classPropertyName: "column", publicName: "column", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { sort: "sort" }, usesOnChanges: true, ngImport: i0, template: `
2771
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.3", type: TitleComponent, isStandalone: true, selector: "ng2-smart-table-title", inputs: { source: { classPropertyName: "source", publicName: "source", isSignal: true, isRequired: true, transformFunction: null }, column: { classPropertyName: "column", publicName: "column", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: `
3263
2772
  @if (column().isSortable) {
3264
- <a
3265
- href="#"
3266
- (click)="_sort($event)"
3267
- class="ng2-smart-sort-link sort"
3268
- [class]="currentDirection"
3269
- >
2773
+ <a href="#" (click)="_sort($event)" class="ng2-smart-sort-link sort" [class]="currentSortDirection()">
3270
2774
  {{ column().title }}
3271
2775
  </a>
3272
2776
  } @else {
3273
2777
  <span class="ng2-smart-sort">{{ column().title }}</span>
3274
2778
  }
3275
- `, isInline: true, styles: ["a.sort.asc,a.sort.desc{font-weight:700}a.sort.asc:after,a.sort.desc:after{content:\"\";display:inline-block;width:0;height:0;border-bottom:4px solid rgba(0,0,0,.3);border-top:4px solid transparent;border-left:4px solid transparent;border-right:4px solid transparent;margin-bottom:2px}a.sort.desc:after{-webkit-transform:rotate(-180deg);transform:rotate(-180deg);margin-bottom:-2px}\n"] }); }
2779
+ `, isInline: true, styles: ["a.sort{white-space:nowrap}a.sort.asc,a.sort.desc{font-weight:700}a.sort.asc:after,a.sort.desc:after{content:\"\";display:inline-block;width:0;height:0;border-bottom:4px solid rgba(0,0,0,.3);border-top:4px solid transparent;border-left:4px solid transparent;border-right:4px solid transparent;margin-bottom:2px}a.sort.desc:after{-webkit-transform:rotate(-180deg);transform:rotate(-180deg);margin-bottom:-2px}\n"] }); }
3276
2780
  }
3277
2781
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: TitleComponent, decorators: [{
3278
2782
  type: Component,
3279
- args: [{ selector: "ng2-smart-table-title", template: `
2783
+ args: [{ selector: 'ng2-smart-table-title', template: `
3280
2784
  @if (column().isSortable) {
3281
- <a
3282
- href="#"
3283
- (click)="_sort($event)"
3284
- class="ng2-smart-sort-link sort"
3285
- [class]="currentDirection"
3286
- >
2785
+ <a href="#" (click)="_sort($event)" class="ng2-smart-sort-link sort" [class]="currentSortDirection()">
3287
2786
  {{ column().title }}
3288
2787
  </a>
3289
2788
  } @else {
3290
2789
  <span class="ng2-smart-sort">{{ column().title }}</span>
3291
2790
  }
3292
- `, standalone: true, styles: ["a.sort.asc,a.sort.desc{font-weight:700}a.sort.asc:after,a.sort.desc:after{content:\"\";display:inline-block;width:0;height:0;border-bottom:4px solid rgba(0,0,0,.3);border-top:4px solid transparent;border-left:4px solid transparent;border-right:4px solid transparent;margin-bottom:2px}a.sort.desc:after{-webkit-transform:rotate(-180deg);transform:rotate(-180deg);margin-bottom:-2px}\n"] }]
2791
+ `, standalone: true, styles: ["a.sort{white-space:nowrap}a.sort.asc,a.sort.desc{font-weight:700}a.sort.asc:after,a.sort.desc:after{content:\"\";display:inline-block;width:0;height:0;border-bottom:4px solid rgba(0,0,0,.3);border-top:4px solid transparent;border-left:4px solid transparent;border-right:4px solid transparent;margin-bottom:2px}a.sort.desc:after{-webkit-transform:rotate(-180deg);transform:rotate(-180deg);margin-bottom:-2px}\n"] }]
3293
2792
  }] });
3294
2793
 
3295
2794
  class ColumnTitleComponent {
3296
2795
  constructor() {
3297
2796
  this.source = input.required();
3298
2797
  this.column = input.required();
3299
- this.sort = output();
3300
2798
  }
3301
2799
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: ColumnTitleComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
3302
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.0.3", type: ColumnTitleComponent, isStandalone: true, selector: "ng2-st-column-title", inputs: { source: { classPropertyName: "source", publicName: "source", isSignal: true, isRequired: true, transformFunction: null }, column: { classPropertyName: "column", publicName: "column", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { sort: "sort" }, ngImport: i0, template: `
2800
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.0.3", type: ColumnTitleComponent, isStandalone: true, selector: "ng2-st-column-title", inputs: { source: { classPropertyName: "source", publicName: "source", isSignal: true, isRequired: true, transformFunction: null }, column: { classPropertyName: "column", publicName: "column", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: `
3303
2801
  <div class="ng2-smart-title">
3304
2802
  <ng2-smart-table-title
3305
2803
  [source]="source()"
3306
2804
  [column]="column()"
3307
- (sort)="sort.emit($event)"
3308
2805
  ></ng2-smart-table-title>
3309
2806
  </div>
3310
- `, isInline: true, dependencies: [{ kind: "component", type: TitleComponent, selector: "ng2-smart-table-title", inputs: ["source", "column"], outputs: ["sort"] }] }); }
2807
+ `, isInline: true, dependencies: [{ kind: "component", type: TitleComponent, selector: "ng2-smart-table-title", inputs: ["source", "column"] }] }); }
3311
2808
  }
3312
2809
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: ColumnTitleComponent, decorators: [{
3313
2810
  type: Component,
@@ -3318,7 +2815,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
3318
2815
  <ng2-smart-table-title
3319
2816
  [source]="source()"
3320
2817
  [column]="column()"
3321
- (sort)="sort.emit($event)"
3322
2818
  ></ng2-smart-table-title>
3323
2819
  </div>
3324
2820
  `,
@@ -3331,24 +2827,20 @@ class TheadTitlesRowComponent {
3331
2827
  constructor() {
3332
2828
  this.grid = input.required();
3333
2829
  this.source = input.required();
3334
- this.sort = output();
3335
2830
  this.selectAllRows = output();
3336
2831
  }
3337
- getVisibleColumns() {
3338
- return (this.grid().getColumns() || []).filter((column) => !column.hide);
3339
- }
3340
2832
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: TheadTitlesRowComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
3341
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.3", type: TheadTitlesRowComponent, isStandalone: true, selector: "[ng2-st-thead-titles-row]", inputs: { grid: { classPropertyName: "grid", publicName: "grid", isSignal: true, isRequired: true, transformFunction: null }, source: { classPropertyName: "source", publicName: "source", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { sort: "sort", selectAllRows: "selectAllRows" }, ngImport: i0, template: `
2833
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.3", type: TheadTitlesRowComponent, isStandalone: true, selector: "[ng2-st-thead-titles-row]", inputs: { grid: { classPropertyName: "grid", publicName: "grid", isSignal: true, isRequired: true, transformFunction: null }, source: { classPropertyName: "source", publicName: "source", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { selectAllRows: "selectAllRows" }, ngImport: i0, template: `
3342
2834
  @if (grid().isMultiSelectVisible()) {
3343
2835
  <th
3344
2836
  ng2-st-checkbox-select-all
3345
2837
  [grid]="grid()"
3346
- (click)="selectAllRows.emit($event)"
2838
+ (click)="selectAllRows.emit()"
3347
2839
  ></th>
3348
2840
  } @if (grid().actionIsOnLeft() && grid().isActionsVisible()) {
3349
2841
 
3350
2842
  <th ng2-st-actions-title [grid]="grid()"></th>
3351
- } @for (column of getVisibleColumns(); track column.id + $index) {
2843
+ } @for (column of grid().dataSet.getVisibleColumns(); track column.id + $index) {
3352
2844
  <th
3353
2845
  class="ng2-smart-th {{ column.id }}"
3354
2846
  [class]="column.class"
@@ -3357,13 +2849,12 @@ class TheadTitlesRowComponent {
3357
2849
  <ng2-st-column-title
3358
2850
  [source]="source()"
3359
2851
  [column]="column"
3360
- (sort)="sort.emit($event)"
3361
2852
  ></ng2-st-column-title>
3362
2853
  </th>
3363
2854
  } @if (grid().actionIsOnRight() && grid().isActionsVisible()) {
3364
2855
  <th ng2-st-actions-title [grid]="grid()"></th>
3365
2856
  }
3366
- `, isInline: true, dependencies: [{ kind: "component", type: CheckboxSelectAllComponent, selector: "[ng2-st-checkbox-select-all]", inputs: ["grid"] }, { kind: "component", type: ActionsTitleComponent, selector: "[ng2-st-actions-title]", inputs: ["grid"] }, { kind: "component", type: ColumnTitleComponent, selector: "ng2-st-column-title", inputs: ["source", "column"], outputs: ["sort"] }] }); }
2857
+ `, isInline: true, dependencies: [{ kind: "component", type: CheckboxSelectAllComponent, selector: "[ng2-st-checkbox-select-all]", inputs: ["grid"] }, { kind: "component", type: ActionsTitleComponent, selector: "[ng2-st-actions-title]", inputs: ["grid"] }, { kind: "component", type: ColumnTitleComponent, selector: "ng2-st-column-title", inputs: ["source", "column"] }] }); }
3367
2858
  }
3368
2859
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: TheadTitlesRowComponent, decorators: [{
3369
2860
  type: Component,
@@ -3374,12 +2865,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
3374
2865
  <th
3375
2866
  ng2-st-checkbox-select-all
3376
2867
  [grid]="grid()"
3377
- (click)="selectAllRows.emit($event)"
2868
+ (click)="selectAllRows.emit()"
3378
2869
  ></th>
3379
2870
  } @if (grid().actionIsOnLeft() && grid().isActionsVisible()) {
3380
2871
 
3381
2872
  <th ng2-st-actions-title [grid]="grid()"></th>
3382
- } @for (column of getVisibleColumns(); track column.id + $index) {
2873
+ } @for (column of grid().dataSet.getVisibleColumns(); track column.id + $index) {
3383
2874
  <th
3384
2875
  class="ng2-smart-th {{ column.id }}"
3385
2876
  [class]="column.class"
@@ -3388,7 +2879,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
3388
2879
  <ng2-st-column-title
3389
2880
  [source]="source()"
3390
2881
  [column]="column"
3391
- (sort)="sort.emit($event)"
3392
2882
  ></ng2-st-column-title>
3393
2883
  </th>
3394
2884
  } @if (grid().actionIsOnRight() && grid().isActionsVisible()) {
@@ -3408,10 +2898,8 @@ class Ng2SmartTableTheadComponent {
3408
2898
  constructor() {
3409
2899
  this.grid = input.required();
3410
2900
  this.source = input.required();
3411
- this.sort = output();
3412
2901
  this.selectAllRows = output();
3413
2902
  this.create = output();
3414
- this.filter = output();
3415
2903
  this.isHideHeader = computed(() => {
3416
2904
  return this.grid().settings()?.hideHeader || false;
3417
2905
  });
@@ -3420,7 +2908,7 @@ class Ng2SmartTableTheadComponent {
3420
2908
  });
3421
2909
  }
3422
2910
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: Ng2SmartTableTheadComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
3423
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.3", type: Ng2SmartTableTheadComponent, isStandalone: true, selector: "[ng2-st-thead]", inputs: { grid: { classPropertyName: "grid", publicName: "grid", isSignal: true, isRequired: true, transformFunction: null }, source: { classPropertyName: "source", publicName: "source", isSignal: true, isRequired: true, transformFunction: null }, createConfirm: { classPropertyName: "createConfirm", publicName: "createConfirm", isSignal: false, isRequired: false, transformFunction: null } }, outputs: { sort: "sort", selectAllRows: "selectAllRows", create: "create", filter: "filter" }, ngImport: i0, template: "@if (!isHideHeader()) {\n <tr ng2-st-thead-titles-row\n class=\"ng2-smart-titles\"\n [grid]=\"grid()\"\n [source]=\"source()\"\n (sort)=\"sort.emit($event)\"\n (selectAllRows)=\"selectAllRows.emit($event)\">\n </tr>\n}\n\n@if (!isHideSubHeader()) {\n <tr ng2-st-thead-filters-row\n class=\"ng2-smart-filters\"\n [grid]=\"grid()\"\n [source]=\"source()\"\n (create)=\"create.emit($event)\"\n (filter)=\"filter.emit($event)\">\n </tr>\n}\n\n@if (grid().createFormShown) {\n <tr ng2-st-thead-form-row\n [grid]=\"grid()\"\n [createConfirm]=\"createConfirm\">\n </tr>\n}\n", dependencies: [{ kind: "component", type: TheadTitlesRowComponent, selector: "[ng2-st-thead-titles-row]", inputs: ["grid", "source"], outputs: ["sort", "selectAllRows"] }, { kind: "component", type: TheadFiltersRowComponent, selector: "[ng2-st-thead-filters-row]", inputs: ["grid", "source"], outputs: ["create", "filter"] }, { kind: "component", type: TheadFormRowComponent, selector: "[ng2-st-thead-form-row]", inputs: ["grid", "createConfirm"], outputs: ["create"] }] }); }
2911
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.3", type: Ng2SmartTableTheadComponent, isStandalone: true, selector: "[ng2-st-thead]", inputs: { grid: { classPropertyName: "grid", publicName: "grid", isSignal: true, isRequired: true, transformFunction: null }, source: { classPropertyName: "source", publicName: "source", isSignal: true, isRequired: true, transformFunction: null }, createConfirm: { classPropertyName: "createConfirm", publicName: "createConfirm", isSignal: false, isRequired: false, transformFunction: null } }, outputs: { selectAllRows: "selectAllRows", create: "create" }, ngImport: i0, template: "@if (!isHideHeader()) {\n <tr ng2-st-thead-titles-row\n class=\"ng2-smart-titles\"\n [grid]=\"grid()\"\n [source]=\"source()\"\n (selectAllRows)=\"selectAllRows.emit()\">\n </tr>\n}\n\n@if (!isHideSubHeader()) {\n <tr ng2-st-thead-filters-row\n class=\"ng2-smart-filters\"\n [grid]=\"grid()\"\n [source]=\"source()\"\n (create)=\"create.emit($event)\">\n </tr>\n}\n\n@if (grid().createFormShown) {\n <tr ng2-st-thead-form-row\n [grid]=\"grid()\"\n [createConfirm]=\"createConfirm\">\n </tr>\n}\n", dependencies: [{ kind: "component", type: TheadTitlesRowComponent, selector: "[ng2-st-thead-titles-row]", inputs: ["grid", "source"], outputs: ["selectAllRows"] }, { kind: "component", type: TheadFiltersRowComponent, selector: "[ng2-st-thead-filters-row]", inputs: ["grid", "source"], outputs: ["create"] }, { kind: "component", type: TheadFormRowComponent, selector: "[ng2-st-thead-form-row]", inputs: ["grid", "createConfirm"], outputs: ["create"] }] }); }
3424
2912
  }
3425
2913
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: Ng2SmartTableTheadComponent, decorators: [{
3426
2914
  type: Component,
@@ -3428,13 +2916,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
3428
2916
  TheadTitlesRowComponent,
3429
2917
  TheadFiltersRowComponent,
3430
2918
  TheadFormRowComponent,
3431
- ], template: "@if (!isHideHeader()) {\n <tr ng2-st-thead-titles-row\n class=\"ng2-smart-titles\"\n [grid]=\"grid()\"\n [source]=\"source()\"\n (sort)=\"sort.emit($event)\"\n (selectAllRows)=\"selectAllRows.emit($event)\">\n </tr>\n}\n\n@if (!isHideSubHeader()) {\n <tr ng2-st-thead-filters-row\n class=\"ng2-smart-filters\"\n [grid]=\"grid()\"\n [source]=\"source()\"\n (create)=\"create.emit($event)\"\n (filter)=\"filter.emit($event)\">\n </tr>\n}\n\n@if (grid().createFormShown) {\n <tr ng2-st-thead-form-row\n [grid]=\"grid()\"\n [createConfirm]=\"createConfirm\">\n </tr>\n}\n" }]
2919
+ ], template: "@if (!isHideHeader()) {\n <tr ng2-st-thead-titles-row\n class=\"ng2-smart-titles\"\n [grid]=\"grid()\"\n [source]=\"source()\"\n (selectAllRows)=\"selectAllRows.emit()\">\n </tr>\n}\n\n@if (!isHideSubHeader()) {\n <tr ng2-st-thead-filters-row\n class=\"ng2-smart-filters\"\n [grid]=\"grid()\"\n [source]=\"source()\"\n (create)=\"create.emit($event)\">\n </tr>\n}\n\n@if (grid().createFormShown) {\n <tr ng2-st-thead-form-row\n [grid]=\"grid()\"\n [createConfirm]=\"createConfirm\">\n </tr>\n}\n" }]
3432
2920
  }], propDecorators: { createConfirm: [{
3433
2921
  type: Input
3434
2922
  }] } });
3435
2923
 
3436
2924
  class Ng2SmartTableComponent {
3437
2925
  constructor() {
2926
+ this.source = input.required();
2927
+ this.settings = input.required();
3438
2928
  this.multiRowSelect = output();
3439
2929
  this.rowClicked = output();
3440
2930
  this.columnsSorted = output();
@@ -3446,40 +2936,39 @@ class Ng2SmartTableComponent {
3446
2936
  this.deleteConfirm = output();
3447
2937
  this.editConfirm = output();
3448
2938
  this.createConfirm = output();
3449
- this.tableClass = "";
3450
- this.tableId = "";
3451
- this.perPageSelect = [];
3452
- this.isPagerDisplay = false;
3453
- this.rowClassFunction = () => '';
3454
- effect(() => {
3455
- const settings = this.grid.settings();
3456
- this.tableId = settings.attr?.id || getRandomId();
3457
- this.tableClass = settings.attr?.class || '';
3458
- this.isPagerDisplay = this.grid.getSetting("pager.display", false);
3459
- this.perPageSelect = this.grid.getSetting("pager.perPageSelect");
3460
- this.rowClassFunction = settings.rowClassFunction || (() => "");
2939
+ this.tableClass = computed(() => {
2940
+ return this.settings().attr?.class || '';
2941
+ });
2942
+ this.tableId = computed(() => {
2943
+ return this.settings().attr?.id || getRandomId();
2944
+ });
2945
+ this.isPagerDisplay = computed(() => {
2946
+ const { pager } = this.settings();
2947
+ return pager ? pager.display : false;
2948
+ });
2949
+ this.rowClassFunction = computed(() => {
2950
+ return this.settings().rowClassFunction || (() => '');
3461
2951
  });
3462
2952
  }
3463
- ngOnChanges({ settings, source }) {
2953
+ ngOnChanges({ settings }) {
3464
2954
  if (this.grid) {
3465
2955
  if (settings) {
3466
- this.grid.setSettings(this.settings);
3467
- }
3468
- if (source) {
3469
- this.source = this.prepareSource();
3470
- this.grid.setSource(this.source);
2956
+ this.grid.setSettings(this.settings());
3471
2957
  }
3472
2958
  }
3473
2959
  else {
3474
2960
  this.initGrid();
3475
2961
  }
3476
2962
  }
2963
+ ngOnDestroy() {
2964
+ this.grid.detach();
2965
+ }
3477
2966
  multipleSelectRow(row) {
3478
2967
  this.grid.multipleSelectRow(row);
3479
2968
  this.emitUserSelectRow(row);
3480
2969
  }
3481
2970
  onSelectAllRows() {
3482
- this.grid.selectAllRows(!this.grid.dataSet.isAllSelected);
2971
+ this.grid.selectAllRows(!this.grid.dataSet.isAllSelected());
3483
2972
  this.emitUserSelectRow(null);
3484
2973
  }
3485
2974
  onSelectRow(row, state) {
@@ -3488,49 +2977,32 @@ class Ng2SmartTableComponent {
3488
2977
  emitUserRowClicked(row) {
3489
2978
  this.rowClicked.emit({
3490
2979
  data: row ? row.getData() : null,
3491
- source: this.source,
2980
+ source: this.source(),
3492
2981
  });
3493
2982
  }
3494
2983
  initGrid() {
3495
- this.source = this.prepareSource();
3496
- this.grid = new Grid(this.source, this.settings);
2984
+ this.grid = new Grid(this.source(), this.settings());
3497
2985
  this.grid.setColumnsSortedEmitter(this.columnsSorted);
3498
2986
  }
3499
- prepareSource() {
3500
- if (this.source instanceof LocalDataSource) {
3501
- return this.source;
3502
- }
3503
- return new LocalDataSource();
3504
- }
3505
2987
  emitUserSelectRow(row) {
3506
2988
  this.multiRowSelect.emit({
3507
2989
  data: row ? row.getData() : null,
3508
- isSelected: row ? row.getIsSelected() : false,
3509
- source: this.source,
2990
+ isSelected: row ? row.isSelected() : false,
2991
+ source: this.source(),
3510
2992
  selected: this.grid.dataSet.getSelectedRowsData(),
3511
2993
  });
3512
2994
  }
3513
2995
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: Ng2SmartTableComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
3514
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.3", type: Ng2SmartTableComponent, isStandalone: true, selector: "ng2-smart-table", inputs: { source: "source", settings: "settings" }, outputs: { multiRowSelect: "multiRowSelect", rowClicked: "rowClicked", columnsSorted: "columnsSorted", delete: "delete", edit: "edit", editCancel: "editCancel", create: "create", custom: "custom", deleteConfirm: "deleteConfirm", editConfirm: "editConfirm", createConfirm: "createConfirm" }, usesOnChanges: true, ngImport: i0, template: "<table [id]=\"tableId\" [class]=\"tableClass\">\n <thead\n ng2-st-thead\n [grid]=\"grid\"\n [source]=\"source\"\n [createConfirm]=\"createConfirm\"\n (create)=\"create.emit($event)\"\n (selectAllRows)=\"onSelectAllRows()\"\n ></thead>\n\n <tbody\n ng2-st-tbody\n [grid]=\"grid\"\n [source]=\"source\"\n [deleteConfirm]=\"deleteConfirm\"\n [editConfirm]=\"editConfirm\"\n [createConfirm]=\"createConfirm\"\n [rowClassFunction]=\"rowClassFunction\"\n (edit)=\"edit.emit($event)\"\n (editCancel)=\"editCancel.emit($event)\"\n (delete)=\"delete.emit($event)\"\n (custom)=\"custom.emit($event)\"\n (userClickedRow)=\"emitUserRowClicked($event)\"\n (multipleSelectRow)=\"multipleSelectRow($event)\"\n ></tbody>\n</table>\n\n@if (isPagerDisplay) {\n<ng2-smart-table-pager [source]=\"source\" [perPageSelect]=\"perPageSelect\">\n</ng2-smart-table-pager>\n}\n", styles: [":host{font-size:1rem}:host ::ng-deep *{box-sizing:border-box}:host ::ng-deep button,:host ::ng-deep input,:host ::ng-deep optgroup,:host ::ng-deep select,:host ::ng-deep textarea{color:inherit;font:inherit;margin:0}:host ::ng-deep table{line-height:1.5em;border-collapse:collapse;border-spacing:0;display:table;width:100%;max-width:100%;word-break:normal;word-break:keep-all;overflow:auto}:host ::ng-deep table tr th{font-weight:700}:host ::ng-deep table tr section{font-size:.75em;font-weight:700}:host ::ng-deep table tr td,:host ::ng-deep table tr th{font-size:.875em;margin:0;padding:.5em 1em}:host ::ng-deep a{color:#1e6bb8;text-decoration:none}:host ::ng-deep a:hover{text-decoration:underline}\n"], dependencies: [{ kind: "component", type: Ng2SmartTableTheadComponent, selector: "[ng2-st-thead]", inputs: ["grid", "source", "createConfirm"], outputs: ["sort", "selectAllRows", "create", "filter"] }, { kind: "component", type: Ng2SmartTableTbodyComponent, selector: "[ng2-st-tbody]", inputs: ["grid", "source", "deleteConfirm", "createConfirm", "editConfirm", "rowClassFunction"], outputs: ["save", "edit", "editCancel", "delete", "custom", "edited", "userSelectRow", "userClickedRow", "multipleSelectRow"] }, { kind: "component", type: PagerComponent, selector: "ng2-smart-table-pager", inputs: ["source", "perPageSelect"], outputs: ["changePage"] }] }); }
2996
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.3", type: Ng2SmartTableComponent, isStandalone: true, selector: "ng2-smart-table", inputs: { source: { classPropertyName: "source", publicName: "source", isSignal: true, isRequired: true, transformFunction: null }, settings: { classPropertyName: "settings", publicName: "settings", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { multiRowSelect: "multiRowSelect", rowClicked: "rowClicked", columnsSorted: "columnsSorted", delete: "delete", edit: "edit", editCancel: "editCancel", create: "create", custom: "custom", deleteConfirm: "deleteConfirm", editConfirm: "editConfirm", createConfirm: "createConfirm" }, usesOnChanges: true, ngImport: i0, template: "<table [id]=\"tableId()\" [class]=\"tableClass()\">\n <thead\n ng2-st-thead\n [grid]=\"grid\"\n [source]=\"source()\"\n [createConfirm]=\"createConfirm\"\n (create)=\"create.emit($event)\"\n (selectAllRows)=\"onSelectAllRows()\"\n ></thead>\n\n <tbody\n ng2-st-tbody\n [grid]=\"grid\"\n [source]=\"source()\"\n [deleteConfirm]=\"deleteConfirm\"\n [editConfirm]=\"editConfirm\"\n [createConfirm]=\"createConfirm\"\n [rowClassFunction]=\"rowClassFunction()\"\n (edit)=\"edit.emit($event)\"\n (editCancel)=\"editCancel.emit($event)\"\n (delete)=\"delete.emit($event)\"\n (custom)=\"custom.emit($event)\"\n (userClickedRow)=\"emitUserRowClicked($event)\"\n (multipleSelectRow)=\"multipleSelectRow($event)\"\n ></tbody>\n</table>\n\n@if (isPagerDisplay()) {\n<ng2-smart-table-pager [source]=\"source()\">\n</ng2-smart-table-pager>\n}\n", styles: [":host{font-size:1rem}:host ::ng-deep *{box-sizing:border-box}:host ::ng-deep button,:host ::ng-deep input,:host ::ng-deep optgroup,:host ::ng-deep select,:host ::ng-deep textarea{color:inherit;font:inherit;margin:0}:host ::ng-deep table{line-height:1.5em;border-collapse:collapse;border-spacing:0;display:table;width:100%;max-width:100%;word-break:normal;word-break:keep-all;overflow:auto}:host ::ng-deep table tr th{font-weight:700}:host ::ng-deep table tr section{font-size:.75em;font-weight:700}:host ::ng-deep table tr td,:host ::ng-deep table tr th{font-size:.875em;margin:0;padding:.5em 1em}:host ::ng-deep a{color:#1e6bb8;text-decoration:none}:host ::ng-deep a:hover{text-decoration:underline}\n"], dependencies: [{ kind: "component", type: Ng2SmartTableTheadComponent, selector: "[ng2-st-thead]", inputs: ["grid", "source", "createConfirm"], outputs: ["selectAllRows", "create"] }, { kind: "component", type: Ng2SmartTableTbodyComponent, selector: "[ng2-st-tbody]", inputs: ["grid", "source", "deleteConfirm", "createConfirm", "editConfirm", "rowClassFunction"], outputs: ["save", "edit", "editCancel", "delete", "custom", "edited", "userSelectRow", "userClickedRow", "multipleSelectRow"] }, { kind: "component", type: PagerComponent, selector: "ng2-smart-table-pager", inputs: ["source"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
3515
2997
  }
3516
2998
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: Ng2SmartTableComponent, decorators: [{
3517
2999
  type: Component,
3518
- args: [{ selector: "ng2-smart-table", standalone: true, imports: [
3519
- Ng2SmartTableTheadComponent,
3520
- Ng2SmartTableTbodyComponent,
3521
- PagerComponent,
3522
- ], template: "<table [id]=\"tableId\" [class]=\"tableClass\">\n <thead\n ng2-st-thead\n [grid]=\"grid\"\n [source]=\"source\"\n [createConfirm]=\"createConfirm\"\n (create)=\"create.emit($event)\"\n (selectAllRows)=\"onSelectAllRows()\"\n ></thead>\n\n <tbody\n ng2-st-tbody\n [grid]=\"grid\"\n [source]=\"source\"\n [deleteConfirm]=\"deleteConfirm\"\n [editConfirm]=\"editConfirm\"\n [createConfirm]=\"createConfirm\"\n [rowClassFunction]=\"rowClassFunction\"\n (edit)=\"edit.emit($event)\"\n (editCancel)=\"editCancel.emit($event)\"\n (delete)=\"delete.emit($event)\"\n (custom)=\"custom.emit($event)\"\n (userClickedRow)=\"emitUserRowClicked($event)\"\n (multipleSelectRow)=\"multipleSelectRow($event)\"\n ></tbody>\n</table>\n\n@if (isPagerDisplay) {\n<ng2-smart-table-pager [source]=\"source\" [perPageSelect]=\"perPageSelect\">\n</ng2-smart-table-pager>\n}\n", styles: [":host{font-size:1rem}:host ::ng-deep *{box-sizing:border-box}:host ::ng-deep button,:host ::ng-deep input,:host ::ng-deep optgroup,:host ::ng-deep select,:host ::ng-deep textarea{color:inherit;font:inherit;margin:0}:host ::ng-deep table{line-height:1.5em;border-collapse:collapse;border-spacing:0;display:table;width:100%;max-width:100%;word-break:normal;word-break:keep-all;overflow:auto}:host ::ng-deep table tr th{font-weight:700}:host ::ng-deep table tr section{font-size:.75em;font-weight:700}:host ::ng-deep table tr td,:host ::ng-deep table tr th{font-size:.875em;margin:0;padding:.5em 1em}:host ::ng-deep a{color:#1e6bb8;text-decoration:none}:host ::ng-deep a:hover{text-decoration:underline}\n"] }]
3523
- }], ctorParameters: () => [], propDecorators: { source: [{
3524
- type: Input,
3525
- args: [{ required: true }]
3526
- }], settings: [{
3527
- type: Input,
3528
- args: [{ required: true }]
3529
- }] } });
3000
+ args: [{ selector: 'ng2-smart-table', standalone: true, imports: [Ng2SmartTableTheadComponent, Ng2SmartTableTbodyComponent, PagerComponent], changeDetection: ChangeDetectionStrategy.OnPush, template: "<table [id]=\"tableId()\" [class]=\"tableClass()\">\n <thead\n ng2-st-thead\n [grid]=\"grid\"\n [source]=\"source()\"\n [createConfirm]=\"createConfirm\"\n (create)=\"create.emit($event)\"\n (selectAllRows)=\"onSelectAllRows()\"\n ></thead>\n\n <tbody\n ng2-st-tbody\n [grid]=\"grid\"\n [source]=\"source()\"\n [deleteConfirm]=\"deleteConfirm\"\n [editConfirm]=\"editConfirm\"\n [createConfirm]=\"createConfirm\"\n [rowClassFunction]=\"rowClassFunction()\"\n (edit)=\"edit.emit($event)\"\n (editCancel)=\"editCancel.emit($event)\"\n (delete)=\"delete.emit($event)\"\n (custom)=\"custom.emit($event)\"\n (userClickedRow)=\"emitUserRowClicked($event)\"\n (multipleSelectRow)=\"multipleSelectRow($event)\"\n ></tbody>\n</table>\n\n@if (isPagerDisplay()) {\n<ng2-smart-table-pager [source]=\"source()\">\n</ng2-smart-table-pager>\n}\n", styles: [":host{font-size:1rem}:host ::ng-deep *{box-sizing:border-box}:host ::ng-deep button,:host ::ng-deep input,:host ::ng-deep optgroup,:host ::ng-deep select,:host ::ng-deep textarea{color:inherit;font:inherit;margin:0}:host ::ng-deep table{line-height:1.5em;border-collapse:collapse;border-spacing:0;display:table;width:100%;max-width:100%;word-break:normal;word-break:keep-all;overflow:auto}:host ::ng-deep table tr th{font-weight:700}:host ::ng-deep table tr section{font-size:.75em;font-weight:700}:host ::ng-deep table tr td,:host ::ng-deep table tr th{font-size:.875em;margin:0;padding:.5em 1em}:host ::ng-deep a{color:#1e6bb8;text-decoration:none}:host ::ng-deep a:hover{text-decoration:underline}\n"] }]
3001
+ }] });
3530
3002
 
3531
3003
  /**
3532
3004
  * Generated bundle index. Do not edit.
3533
3005
  */
3534
3006
 
3535
- export { Cell, Column, DataSource, DefaultEditor, DefaultFilter, Deferred, LocalDataSource, Ng2SmartTableComponent, Row, SmartTableColumnEditorDirective, SmartTableOnChangedEventName };
3007
+ export { BaseEditorComponent, BaseFilterComponent, Cell, Column, DataSource, Deferred, LocalDataSource, Ng2SmartTableComponent, Row, ServerDataSource, SmartTableColumnEditorDirective, SmartTableOnChangedEventName };
3536
3008
  //# sourceMappingURL=den4ik92-ng2-smart-table.mjs.map