@den4ik92/ng2-smart-table 19.1.5 → 19.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -421,8 +421,8 @@ class Row {
421
421
  this.data = data;
422
422
  this._dataSet = _dataSet;
423
423
  this.pending = signal(false);
424
- this.isSelected = false;
425
- this.isInEditing = false;
424
+ this.isSelected = signal(false);
425
+ this.isInEditing = signal(false);
426
426
  this.cells = [];
427
427
  this.process();
428
428
  }
@@ -435,9 +435,6 @@ class Row {
435
435
  getData() {
436
436
  return this.data;
437
437
  }
438
- getIsSelected() {
439
- return this.isSelected;
440
- }
441
438
  getNewData() {
442
439
  const values = Object.assign({}, this.data);
443
440
  this.getCells().forEach((cell) => values[cell.getColumn().id] = cell.newValue);
@@ -1574,7 +1571,7 @@ class TbodyCreateCancelComponent {
1574
1571
  event.preventDefault();
1575
1572
  event.stopPropagation();
1576
1573
  this.editCancel().emit(true);
1577
- this.row().isInEditing = false;
1574
+ this.row().isInEditing.set(false);
1578
1575
  }
1579
1576
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: TbodyCreateCancelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1580
1577
  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: `
@@ -1777,23 +1774,23 @@ class DataSet {
1777
1774
  }
1778
1775
  setSelectAll(state) {
1779
1776
  this.rows.forEach((row) => {
1780
- row.isSelected = state;
1777
+ row.isSelected.set(state);
1781
1778
  this.storeSelectedRow(row);
1782
1779
  });
1783
1780
  }
1784
1781
  deselectAll() {
1785
1782
  this.rows.forEach((row) => {
1786
- row.isSelected = false;
1783
+ row.isSelected.set(false);
1787
1784
  });
1788
1785
  // we need to clear selectedRow field because no one row selected
1789
1786
  this.selectedRows.clear();
1790
1787
  }
1791
1788
  selectRow(row, state) {
1792
- row.isSelected = state;
1789
+ row.isSelected.set(state);
1793
1790
  this.storeSelectedRow(row);
1794
1791
  }
1795
1792
  multipleSelectRow(row) {
1796
- row.isSelected = !row.isSelected;
1793
+ row.isSelected.set(!row.isSelected());
1797
1794
  this.storeSelectedRow(row);
1798
1795
  return row;
1799
1796
  }
@@ -1802,7 +1799,7 @@ class DataSet {
1802
1799
  }
1803
1800
  createNewRow() {
1804
1801
  this.newRow = new Row(-1, {}, this);
1805
- this.newRow.isInEditing = true;
1802
+ this.newRow.isInEditing.set(true);
1806
1803
  }
1807
1804
  /**
1808
1805
  * Create columns by mapping from the settings
@@ -1822,15 +1819,15 @@ class DataSet {
1822
1819
  this.rows = [];
1823
1820
  this.data.forEach((el, index) => {
1824
1821
  const row = new Row(index, el, this);
1825
- row.isSelected = this.selectedRows.has(row.getData());
1822
+ row.isSelected.set(this.selectedRows.has(row.getData()));
1826
1823
  this.rows.push(row);
1827
1824
  });
1828
1825
  }
1829
1826
  get isAllSelected() {
1830
- return this.rows.every((row) => row.isSelected);
1827
+ return this.rows.every((row) => row.isSelected());
1831
1828
  }
1832
1829
  storeSelectedRow(row) {
1833
- if (row.isSelected) {
1830
+ if (row.isSelected()) {
1834
1831
  this.selectedRows.add(row.getData());
1835
1832
  }
1836
1833
  else {
@@ -1884,31 +1881,9 @@ class Grid {
1884
1881
  this.setColumnsSortState(settings.columns);
1885
1882
  }
1886
1883
  }
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
1884
  getDataSet() {
1895
1885
  return this.dataSet;
1896
1886
  }
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
1887
  getSetting(name, defaultValue) {
1913
1888
  return getDeepFromObject(this.settings(), name, defaultValue);
1914
1889
  }
@@ -1931,7 +1906,7 @@ class Grid {
1931
1906
  return this.onDeselectRowSource.asObservable();
1932
1907
  }
1933
1908
  edit(row) {
1934
- row.isInEditing = true;
1909
+ row.isInEditing.set(true);
1935
1910
  }
1936
1911
  create(row, confirmEmitter) {
1937
1912
  row.pending.set(true);
@@ -1968,12 +1943,12 @@ class Grid {
1968
1943
  row.pending.set(false);
1969
1944
  newData = newData || row.getNewData();
1970
1945
  this.source.update(row.getData(), newData).then(() => {
1971
- row.isInEditing = false;
1946
+ row.isInEditing.set(false);
1972
1947
  });
1973
1948
  })
1974
1949
  .catch(() => {
1975
1950
  row.pending.set(false);
1976
- row.isInEditing = false;
1951
+ row.isInEditing.set(false);
1977
1952
  });
1978
1953
  if (this.getSetting("edit.confirmSave", false)) {
1979
1954
  confirmEmitter.emit({
@@ -2011,38 +1986,29 @@ class Grid {
2011
1986
  deferred.resolve(false);
2012
1987
  row.pending.set(false);
2013
1988
  }
2014
- if (row.isSelected) {
1989
+ if (row.isSelected()) {
2015
1990
  this.dataSet.selectRow(row, false);
2016
1991
  }
2017
1992
  }
2018
- processDataChange(changes) {
2019
- if (this.shouldProcessChange(changes)) {
2020
- if (changes["action"] === "load") {
2021
- this.dataSet.deselectAll();
2022
- }
2023
- this.dataSet.setData(changes["elements"]);
2024
- }
2025
- }
2026
- shouldProcessChange(changes) {
2027
- if (["filter", "sort", "page", "remove", "refresh", "load", "paging"].indexOf(changes["action"]) !== -1) {
2028
- return true;
1993
+ processDataChange({ action, elements }) {
1994
+ if (action === "load") {
1995
+ this.dataSet.deselectAll();
2029
1996
  }
2030
- else if (["prepend", "append"].indexOf(changes["action"]) !== -1 &&
2031
- !this.getSetting("pager.display")) {
2032
- return true;
1997
+ if (action !== "update") {
1998
+ this.dataSet.setData(elements);
2033
1999
  }
2034
- return false;
2035
2000
  }
2036
2001
  prepareSource(source) {
2002
+ const preparedSource = source || new LocalDataSource();
2037
2003
  const initialSort = this.getInitialSort();
2038
2004
  if (initialSort) {
2039
- source.setSort([initialSort], false);
2005
+ preparedSource.setSort([initialSort], false);
2040
2006
  }
2041
- if (this.getSetting("pager.display") === true) {
2042
- source.setPaging(1, this.getSetting("pager.perPage"), false);
2007
+ if (this.getSetting("pager.display", false) === true) {
2008
+ preparedSource.setPaging(1, this.getSetting("pager.perPage"), false);
2043
2009
  }
2044
- source.refresh();
2045
- return source;
2010
+ preparedSource.refresh();
2011
+ return preparedSource;
2046
2012
  }
2047
2013
  getInitialSort() {
2048
2014
  const defaultSortColumn = this.getColumns().find((column) => column.isSortable && column.defaultSortDirection);
@@ -2067,6 +2033,28 @@ class Grid {
2067
2033
  getLastRow() {
2068
2034
  return this.dataSet.getLastRow();
2069
2035
  }
2036
+ updateSettingsAndDataSet(settings) {
2037
+ this.settings.set(settings);
2038
+ this.dataSet = new DataSet([], settings.columns);
2039
+ if (this.source) {
2040
+ this.source.refresh();
2041
+ }
2042
+ }
2043
+ setSource(source) {
2044
+ this.source = this.prepareSource(source);
2045
+ this.detach();
2046
+ this.sourceOnChangedSubscription = this.source
2047
+ .onChanged()
2048
+ .subscribe((changes) => this.processDataChange(changes));
2049
+ this.sourceOnUpdatedSubscription = this.source
2050
+ .onUpdated()
2051
+ .subscribe((data) => {
2052
+ const changedRow = this.dataSet.findRowByData(data);
2053
+ if (changedRow) {
2054
+ changedRow.setData(data);
2055
+ }
2056
+ });
2057
+ }
2070
2058
  // ------------------------------- column sort
2071
2059
  async getSortedTableColumns(newState, columns) {
2072
2060
  const sortedArray = [];
@@ -2459,7 +2447,7 @@ class Ng2SmartTableTbodyComponent {
2459
2447
  return item?.id || index;
2460
2448
  }
2461
2449
  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"] }] }); }
2450
+ 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"] }] }); }
2463
2451
  }
2464
2452
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: Ng2SmartTableTbodyComponent, decorators: [{
2465
2453
  type: Component,
@@ -2470,7 +2458,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
2470
2458
  TbodyCreateCancelComponent,
2471
2459
  NgTemplateOutlet,
2472
2460
  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"] }]
2461
+ ], 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"] }]
2474
2462
  }] });
2475
2463
 
2476
2464
  class FilterDefault {
@@ -3107,7 +3095,7 @@ class TheadFormRowComponent {
3107
3095
  <ng2-smart-table-cell
3108
3096
  [cell]="cell"
3109
3097
  [inputClass]="addInputClass()"
3110
- [isInEditing]="grid().getNewRow().isInEditing"
3098
+ [isInEditing]="grid().getNewRow().isInEditing()"
3111
3099
  >
3112
3100
  </ng2-smart-table-cell>
3113
3101
  </td>
@@ -3140,7 +3128,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
3140
3128
  <ng2-smart-table-cell
3141
3129
  [cell]="cell"
3142
3130
  [inputClass]="addInputClass()"
3143
- [isInEditing]="grid().getNewRow().isInEditing"
3131
+ [isInEditing]="grid().getNewRow().isInEditing()"
3144
3132
  >
3145
3133
  </ng2-smart-table-cell>
3146
3134
  </td>
@@ -3435,6 +3423,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
3435
3423
 
3436
3424
  class Ng2SmartTableComponent {
3437
3425
  constructor() {
3426
+ this.source = input.required();
3427
+ this.settings = input.required();
3438
3428
  this.multiRowSelect = output();
3439
3429
  this.rowClicked = output();
3440
3430
  this.columnsSorted = output();
@@ -3446,34 +3436,37 @@ class Ng2SmartTableComponent {
3446
3436
  this.deleteConfirm = output();
3447
3437
  this.editConfirm = output();
3448
3438
  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 || (() => "");
3439
+ this.tableClass = computed(() => {
3440
+ return this.settings().attr?.class || "";
3441
+ });
3442
+ this.tableId = computed(() => {
3443
+ return this.settings().attr?.id || getRandomId();
3444
+ });
3445
+ this.perPageSelect = computed(() => {
3446
+ const { pager } = this.settings();
3447
+ return pager ? pager.perPageSelect || [] : [];
3448
+ });
3449
+ this.isPagerDisplay = computed(() => {
3450
+ const { pager } = this.settings();
3451
+ return pager ? pager.display : false;
3452
+ });
3453
+ this.rowClassFunction = computed(() => {
3454
+ return this.settings().rowClassFunction || (() => "");
3461
3455
  });
3462
3456
  }
3463
- ngOnChanges({ settings, source }) {
3457
+ ngOnChanges({ settings }) {
3464
3458
  if (this.grid) {
3465
3459
  if (settings) {
3466
- this.grid.setSettings(this.settings);
3467
- }
3468
- if (source) {
3469
- this.source = this.prepareSource();
3470
- this.grid.setSource(this.source);
3460
+ this.grid.setSettings(this.settings());
3471
3461
  }
3472
3462
  }
3473
3463
  else {
3474
3464
  this.initGrid();
3475
3465
  }
3476
3466
  }
3467
+ ngOnDestroy() {
3468
+ this.grid.detach();
3469
+ }
3477
3470
  multipleSelectRow(row) {
3478
3471
  this.grid.multipleSelectRow(row);
3479
3472
  this.emitUserSelectRow(row);
@@ -3488,30 +3481,23 @@ class Ng2SmartTableComponent {
3488
3481
  emitUserRowClicked(row) {
3489
3482
  this.rowClicked.emit({
3490
3483
  data: row ? row.getData() : null,
3491
- source: this.source,
3484
+ source: this.source(),
3492
3485
  });
3493
3486
  }
3494
3487
  initGrid() {
3495
- this.source = this.prepareSource();
3496
- this.grid = new Grid(this.source, this.settings);
3488
+ this.grid = new Grid(this.source(), this.settings());
3497
3489
  this.grid.setColumnsSortedEmitter(this.columnsSorted);
3498
3490
  }
3499
- prepareSource() {
3500
- if (this.source instanceof LocalDataSource) {
3501
- return this.source;
3502
- }
3503
- return new LocalDataSource();
3504
- }
3505
3491
  emitUserSelectRow(row) {
3506
3492
  this.multiRowSelect.emit({
3507
3493
  data: row ? row.getData() : null,
3508
- isSelected: row ? row.getIsSelected() : false,
3509
- source: this.source,
3494
+ isSelected: row ? row.isSelected() : false,
3495
+ source: this.source(),
3510
3496
  selected: this.grid.dataSet.getSelectedRowsData(),
3511
3497
  });
3512
3498
  }
3513
3499
  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"] }] }); }
3500
+ 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()\" [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"] }] }); }
3515
3501
  }
3516
3502
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: Ng2SmartTableComponent, decorators: [{
3517
3503
  type: Component,
@@ -3519,14 +3505,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
3519
3505
  Ng2SmartTableTheadComponent,
3520
3506
  Ng2SmartTableTbodyComponent,
3521
3507
  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
- }] } });
3508
+ ], 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"] }]
3509
+ }] });
3530
3510
 
3531
3511
  /**
3532
3512
  * Generated bundle index. Do not edit.