@den4ik92/ng2-smart-table 1.1.0 → 2.0.1

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 (87) hide show
  1. package/esm2020/lib/components/cell/cell-edit-mode/custom-edit.component.mjs +4 -3
  2. package/esm2020/lib/components/cell/cell-edit-mode/default-edit.component.mjs +11 -8
  3. package/esm2020/lib/components/cell/cell-edit-mode/edit-cell-default.mjs +1 -1
  4. package/esm2020/lib/components/cell/cell-edit-mode/edit-cell.component.mjs +6 -2
  5. package/esm2020/lib/components/cell/cell-editors/checkbox-editor.component.mjs +6 -5
  6. package/esm2020/lib/components/cell/cell-editors/default-editor.mjs +2 -1
  7. package/esm2020/lib/components/cell/cell-view-mode/custom-view.component.mjs +1 -6
  8. package/esm2020/lib/components/cell/cell-view-mode/view-cell.component.mjs +1 -1
  9. package/esm2020/lib/components/cell/cell.component.mjs +1 -1
  10. package/esm2020/lib/components/cell/cell.module.mjs +1 -5
  11. package/esm2020/lib/components/filter/custom-filter.component.mjs +15 -16
  12. package/esm2020/lib/components/filter/default-filter.component.mjs +7 -22
  13. package/esm2020/lib/components/filter/filter-default.mjs +6 -4
  14. package/esm2020/lib/components/filter/filter-types/default-filter.mjs +3 -1
  15. package/esm2020/lib/components/filter/filter-types/input-filter.component.mjs +2 -2
  16. package/esm2020/lib/components/filter/filter-types/select-filter.component.mjs +6 -4
  17. package/esm2020/lib/components/filter/filter.component.mjs +4 -8
  18. package/esm2020/lib/components/filter/filter.module.mjs +1 -5
  19. package/esm2020/lib/components/pager/pager.component.mjs +21 -18
  20. package/esm2020/lib/components/tbody/cells/create-cancel.component.mjs +7 -3
  21. package/esm2020/lib/components/tbody/cells/custom.component.mjs +2 -1
  22. package/esm2020/lib/components/tbody/cells/edit-delete.component.mjs +6 -2
  23. package/esm2020/lib/components/tbody/tbody.component.mjs +22 -9
  24. package/esm2020/lib/components/thead/cells/actions-title.component.mjs +2 -1
  25. package/esm2020/lib/components/thead/cells/actions.component.mjs +3 -1
  26. package/esm2020/lib/components/thead/cells/add-button.component.mjs +4 -2
  27. package/esm2020/lib/components/thead/cells/checkbox-select-all.component.mjs +2 -2
  28. package/esm2020/lib/components/thead/cells/column-title.component.mjs +2 -2
  29. package/esm2020/lib/components/thead/cells/title/title.component.mjs +6 -7
  30. package/esm2020/lib/components/thead/rows/thead-filters-row.component.mjs +7 -3
  31. package/esm2020/lib/components/thead/rows/thead-form-row.component.mjs +6 -2
  32. package/esm2020/lib/components/thead/rows/thead-titles-row.component.mjs +5 -2
  33. package/esm2020/lib/components/thead/thead.component.mjs +6 -4
  34. package/esm2020/lib/lib/data-set/column.mjs +37 -38
  35. package/esm2020/lib/lib/data-set/data-set.mjs +1 -1
  36. package/esm2020/lib/lib/data-set/row.mjs +1 -1
  37. package/esm2020/lib/lib/data-source/data-source.mjs +18 -28
  38. package/esm2020/lib/lib/data-source/local/local.data-source.mjs +58 -26
  39. package/esm2020/lib/lib/grid.mjs +19 -32
  40. package/esm2020/lib/lib/helpers.mjs +2 -2
  41. package/esm2020/lib/lib/interfaces/smart-table.models.mjs +1 -1
  42. package/esm2020/lib/ng2-smart-table.component.mjs +35 -26
  43. package/esm2020/public-api.mjs +1 -2
  44. package/fesm2015/den4ik92-ng2-smart-table.mjs +332 -490
  45. package/fesm2015/den4ik92-ng2-smart-table.mjs.map +1 -1
  46. package/fesm2020/den4ik92-ng2-smart-table.mjs +1656 -1819
  47. package/fesm2020/den4ik92-ng2-smart-table.mjs.map +1 -1
  48. package/lib/components/cell/cell-edit-mode/default-edit.component.d.ts +2 -1
  49. package/lib/components/cell/cell-edit-mode/edit-cell.component.d.ts +2 -1
  50. package/lib/components/cell/cell-view-mode/custom-view.component.d.ts +0 -1
  51. package/lib/components/cell/cell.module.d.ts +8 -9
  52. package/lib/components/filter/custom-filter.component.d.ts +1 -2
  53. package/lib/components/filter/default-filter.component.d.ts +1 -2
  54. package/lib/components/filter/filter-default.d.ts +4 -4
  55. package/lib/components/filter/filter-types/default-filter.d.ts +1 -1
  56. package/lib/components/filter/filter.component.d.ts +1 -2
  57. package/lib/components/filter/filter.module.d.ts +5 -6
  58. package/lib/components/pager/pager.component.d.ts +8 -8
  59. package/lib/components/tbody/cells/custom.component.d.ts +2 -1
  60. package/lib/components/tbody/cells/edit-delete.component.d.ts +2 -2
  61. package/lib/components/tbody/tbody.component.d.ts +5 -4
  62. package/lib/components/thead/cells/add-button.component.d.ts +2 -2
  63. package/lib/components/thead/cells/checkbox-select-all.component.d.ts +2 -2
  64. package/lib/components/thead/cells/column-title.component.d.ts +2 -2
  65. package/lib/components/thead/cells/title/title.component.d.ts +5 -4
  66. package/lib/components/thead/rows/thead-filters-row.component.d.ts +2 -2
  67. package/lib/components/thead/rows/thead-titles-row.component.d.ts +2 -2
  68. package/lib/components/thead/thead.component.d.ts +2 -2
  69. package/lib/lib/data-set/column.d.ts +16 -26
  70. package/lib/lib/data-set/data-set.d.ts +4 -4
  71. package/lib/lib/data-set/row.d.ts +3 -3
  72. package/lib/lib/data-source/data-source.d.ts +13 -13
  73. package/lib/lib/data-source/local/local.data-source.d.ts +5 -4
  74. package/lib/lib/grid.d.ts +8 -10
  75. package/lib/lib/helpers.d.ts +1 -1
  76. package/lib/lib/interfaces/smart-table.models.d.ts +27 -29
  77. package/lib/ng2-smart-table.component.d.ts +16 -11
  78. package/package.json +1 -1
  79. package/public-api.d.ts +0 -1
  80. package/esm2020/lib/components/cell/cell-editors/completer-editor.component.mjs +0 -46
  81. package/esm2020/lib/components/filter/filter-types/completer-filter.component.mjs +0 -61
  82. package/esm2020/lib/lib/data-source/server/server-source.conf.mjs +0 -20
  83. package/esm2020/lib/lib/data-source/server/server.data-source.mjs +0 -93
  84. package/lib/components/cell/cell-editors/completer-editor.component.d.ts +0 -13
  85. package/lib/components/filter/filter-types/completer-filter.component.d.ts +0 -12
  86. package/lib/lib/data-source/server/server-source.conf.d.ts +0 -27
  87. package/lib/lib/data-source/server/server.data-source.d.ts +0 -30
@@ -4,9 +4,8 @@ import * as i1 from '@angular/common';
4
4
  import { CommonModule } from '@angular/common';
5
5
  import * as i2 from '@angular/forms';
6
6
  import { FormsModule, UntypedFormControl, NgControl, ReactiveFormsModule } from '@angular/forms';
7
- import { debounceTime, distinctUntilChanged, skip, map } from 'rxjs/operators';
7
+ import { debounceTime, distinctUntilChanged, skip } from 'rxjs/operators';
8
8
  import { Subject } from 'rxjs';
9
- import { HttpParams } from '@angular/common/http';
10
9
 
11
10
  class EditCellDefault {
12
11
  constructor() {
@@ -46,8 +45,9 @@ class CustomEditComponent extends EditCellDefault {
46
45
  this.resolver = resolver;
47
46
  }
48
47
  ngOnChanges(changes) {
49
- if (this.cell && !this.customComponent) {
50
- const componentFactory = this.resolver.resolveComponentFactory(this.cell.getColumn().editor.component);
48
+ const editor = this.cell.getColumn().editor;
49
+ if (this.cell && !this.customComponent && editor && editor.type == 'custom') {
50
+ const componentFactory = this.resolver.resolveComponentFactory(editor.component);
51
51
  this.customComponent = this.dynamicTarget.createComponent(componentFactory);
52
52
  // set @Inputs and @Outputs of custom component
53
53
  this.customComponent.instance.cell = this.cell;
@@ -82,6 +82,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
82
82
 
83
83
  class DefaultEditor {
84
84
  constructor() {
85
+ this.inputClass = '';
85
86
  this.onStopEditing = new EventEmitter();
86
87
  this.onEdited = new EventEmitter();
87
88
  this.onClick = new EventEmitter();
@@ -111,8 +112,9 @@ class CheckboxEditorComponent extends DefaultEditor {
111
112
  super();
112
113
  }
113
114
  onChange(event) {
114
- const trueVal = (this.cell.getColumn().getConfig() && this.cell.getColumn().getConfig().true) || true;
115
- const falseVal = (this.cell.getColumn().getConfig() && this.cell.getColumn().getConfig().false) || false;
115
+ const config = this.cell.getColumn().getConfig();
116
+ const trueVal = (config && (config === null || config === void 0 ? void 0 : config.true)) || true;
117
+ const falseVal = (config && (config === null || config === void 0 ? void 0 : config.false)) || false;
116
118
  this.cell.newValue = event.target.checked ? trueVal : falseVal;
117
119
  }
118
120
  }
@@ -123,7 +125,7 @@ CheckboxEditorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0"
123
125
  class="form-control"
124
126
  [name]="cell.getId()"
125
127
  [disabled]="!cell.isEditable()"
126
- [checked]="cell.getValue() == (cell.getColumn().getConfig()?.true || true)"
128
+ [checked]="cell.getValue() === (cell.getColumn().getConfig()?.true || true)"
127
129
  (click)="onClick.emit($event)"
128
130
  (change)="onChange($event)">
129
131
  `, isInline: true, styles: [":host input,:host textarea{width:100%;line-height:normal;padding:.375em .75em}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }] });
@@ -135,55 +137,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
135
137
  class="form-control"
136
138
  [name]="cell.getId()"
137
139
  [disabled]="!cell.isEditable()"
138
- [checked]="cell.getValue() == (cell.getColumn().getConfig()?.true || true)"
140
+ [checked]="cell.getValue() === (cell.getColumn().getConfig()?.true || true)"
139
141
  (click)="onClick.emit($event)"
140
142
  (change)="onChange($event)">
141
143
  `, styles: [":host input,:host textarea{width:100%;line-height:normal;padding:.375em .75em}\n"] }]
142
144
  }], ctorParameters: function () { return []; } });
143
145
 
144
- class CompleterEditorComponent extends DefaultEditor {
145
- constructor() {
146
- super();
147
- this.completerStr = '';
148
- }
149
- ngOnInit() {
150
- // if (this.cell.getColumn().editor && this.cell.getColumn().editor.type === 'completer') {
151
- // const config = this.cell.getColumn().getConfig().completer;
152
- // config.dataService = this.completerService.local(config.data, config.searchFields, config.titleField);
153
- // config.dataService.descriptionField(config.descriptionField);
154
- // }
155
- }
156
- onEditedCompleter(event) {
157
- this.cell.newValue = event.title;
158
- return false;
159
- }
160
- }
161
- CompleterEditorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CompleterEditorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
162
- CompleterEditorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: CompleterEditorComponent, selector: "completer-editor", usesInheritance: true, ngImport: i0, template: `
163
- <!-- <ng2-completer [(ngModel)]="completerStr"
164
- [dataService]="cell.getColumn().getConfig().completer.dataService"
165
- [minSearchLength]="cell.getColumn().getConfig().completer.minSearchLength || 0"
166
- [pause]="cell.getColumn().getConfig().completer.pause || 0"
167
- [placeholder]="cell.getColumn().getConfig().completer.placeholder || 'Start typing...'"
168
- (selected)="onEditedCompleter($event)">
169
- </ng2-completer> -->
170
- `, isInline: true });
171
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CompleterEditorComponent, decorators: [{
172
- type: Component,
173
- args: [{
174
- selector: 'completer-editor',
175
- template: `
176
- <!-- <ng2-completer [(ngModel)]="completerStr"
177
- [dataService]="cell.getColumn().getConfig().completer.dataService"
178
- [minSearchLength]="cell.getColumn().getConfig().completer.minSearchLength || 0"
179
- [pause]="cell.getColumn().getConfig().completer.pause || 0"
180
- [placeholder]="cell.getColumn().getConfig().completer.placeholder || 'Start typing...'"
181
- (selected)="onEditedCompleter($event)">
182
- </ng2-completer> -->
183
- `,
184
- }]
185
- }], ctorParameters: function () { return []; } });
186
-
187
146
  class InputEditorComponent extends DefaultEditor {
188
147
  constructor() {
189
148
  super();
@@ -298,14 +257,18 @@ class DefaultEditComponent extends EditCellDefault {
298
257
  super();
299
258
  }
300
259
  getEditorType() {
301
- return this.cell.getColumn().editor && this.cell.getColumn().editor.type;
260
+ const editor = this.cell.getColumn().editor;
261
+ if (editor) {
262
+ return editor.type;
263
+ }
264
+ return 'text';
302
265
  }
303
266
  }
304
267
  DefaultEditComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DefaultEditComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
305
- DefaultEditComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: DefaultEditComponent, selector: "table-cell-default-editor", usesInheritance: true, ngImport: i0, template: "<div [ngSwitch]=\"getEditorType()\">\n <select-editor *ngSwitchCase=\"'list'\"\n [cell]=\"cell\"\n [inputClass]=\"inputClass\"\n (onClick)=\"onClick($event)\"\n (onEdited)=\"onEdited($event)\"\n (onStopEditing)=\"onStopEditing()\">\n </select-editor>\n\n <textarea-editor *ngSwitchCase=\"'textarea'\"\n [cell]=\"cell\"\n [inputClass]=\"inputClass\"\n (onClick)=\"onClick($event)\"\n (onEdited)=\"onEdited($event)\"\n (onStopEditing)=\"onStopEditing()\">\n </textarea-editor>\n\n <checkbox-editor *ngSwitchCase=\"'checkbox'\"\n [cell]=\"cell\"\n [inputClass]=\"inputClass\"\n (onClick)=\"onClick($event)\">\n </checkbox-editor>\n\n <completer-editor *ngSwitchCase=\"'completer'\"\n [cell]=\"cell\">\n </completer-editor>\n\n <input-editor *ngSwitchDefault\n [cell]=\"cell\"\n [inputClass]=\"inputClass\"\n (onClick)=\"onClick($event)\"\n (onEdited)=\"onEdited($event)\"\n (onStopEditing)=\"onStopEditing()\">\n </input-editor>\n</div>", dependencies: [{ kind: "directive", type: i1.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { kind: "directive", type: i1.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { kind: "directive", type: i1.NgSwitchDefault, selector: "[ngSwitchDefault]" }, { kind: "component", type: CheckboxEditorComponent, selector: "checkbox-editor" }, { kind: "component", type: CompleterEditorComponent, selector: "completer-editor" }, { kind: "component", type: InputEditorComponent, selector: "input-editor" }, { kind: "component", type: SelectEditorComponent, selector: "select-editor" }, { kind: "component", type: TextareaEditorComponent, selector: "textarea-editor" }] });
268
+ DefaultEditComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: DefaultEditComponent, selector: "table-cell-default-editor", usesInheritance: true, ngImport: i0, template: "<div [ngSwitch]=\"getEditorType()\">\n <select-editor *ngSwitchCase=\"'list'\"\n [cell]=\"cell\"\n [inputClass]=\"inputClass\"\n (onClick)=\"onClick($event)\"\n (onEdited)=\"onEdited($event)\"\n (onStopEditing)=\"onStopEditing()\">\n </select-editor>\n\n <textarea-editor *ngSwitchCase=\"'textarea'\"\n [cell]=\"cell\"\n [inputClass]=\"inputClass\"\n (onClick)=\"onClick($event)\"\n (onEdited)=\"onEdited($event)\"\n (onStopEditing)=\"onStopEditing()\">\n </textarea-editor>\n\n <checkbox-editor *ngSwitchCase=\"'checkbox'\"\n [cell]=\"cell\"\n [inputClass]=\"inputClass\"\n (onClick)=\"onClick($event)\">\n </checkbox-editor>\n\n <input-editor *ngSwitchDefault\n [cell]=\"cell\"\n [inputClass]=\"inputClass\"\n (onClick)=\"onClick($event)\"\n (onEdited)=\"onEdited($event)\"\n (onStopEditing)=\"onStopEditing()\">\n </input-editor>\n</div>", dependencies: [{ kind: "directive", type: i1.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { kind: "directive", type: i1.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { kind: "directive", type: i1.NgSwitchDefault, selector: "[ngSwitchDefault]" }, { kind: "component", type: CheckboxEditorComponent, selector: "checkbox-editor" }, { kind: "component", type: InputEditorComponent, selector: "input-editor" }, { kind: "component", type: SelectEditorComponent, selector: "select-editor" }, { kind: "component", type: TextareaEditorComponent, selector: "textarea-editor" }] });
306
269
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DefaultEditComponent, decorators: [{
307
270
  type: Component,
308
- args: [{ selector: 'table-cell-default-editor', template: "<div [ngSwitch]=\"getEditorType()\">\n <select-editor *ngSwitchCase=\"'list'\"\n [cell]=\"cell\"\n [inputClass]=\"inputClass\"\n (onClick)=\"onClick($event)\"\n (onEdited)=\"onEdited($event)\"\n (onStopEditing)=\"onStopEditing()\">\n </select-editor>\n\n <textarea-editor *ngSwitchCase=\"'textarea'\"\n [cell]=\"cell\"\n [inputClass]=\"inputClass\"\n (onClick)=\"onClick($event)\"\n (onEdited)=\"onEdited($event)\"\n (onStopEditing)=\"onStopEditing()\">\n </textarea-editor>\n\n <checkbox-editor *ngSwitchCase=\"'checkbox'\"\n [cell]=\"cell\"\n [inputClass]=\"inputClass\"\n (onClick)=\"onClick($event)\">\n </checkbox-editor>\n\n <completer-editor *ngSwitchCase=\"'completer'\"\n [cell]=\"cell\">\n </completer-editor>\n\n <input-editor *ngSwitchDefault\n [cell]=\"cell\"\n [inputClass]=\"inputClass\"\n (onClick)=\"onClick($event)\"\n (onEdited)=\"onEdited($event)\"\n (onStopEditing)=\"onStopEditing()\">\n </input-editor>\n</div>" }]
271
+ args: [{ selector: 'table-cell-default-editor', template: "<div [ngSwitch]=\"getEditorType()\">\n <select-editor *ngSwitchCase=\"'list'\"\n [cell]=\"cell\"\n [inputClass]=\"inputClass\"\n (onClick)=\"onClick($event)\"\n (onEdited)=\"onEdited($event)\"\n (onStopEditing)=\"onStopEditing()\">\n </select-editor>\n\n <textarea-editor *ngSwitchCase=\"'textarea'\"\n [cell]=\"cell\"\n [inputClass]=\"inputClass\"\n (onClick)=\"onClick($event)\"\n (onEdited)=\"onEdited($event)\"\n (onStopEditing)=\"onStopEditing()\">\n </textarea-editor>\n\n <checkbox-editor *ngSwitchCase=\"'checkbox'\"\n [cell]=\"cell\"\n [inputClass]=\"inputClass\"\n (onClick)=\"onClick($event)\">\n </checkbox-editor>\n\n <input-editor *ngSwitchDefault\n [cell]=\"cell\"\n [inputClass]=\"inputClass\"\n (onClick)=\"onClick($event)\"\n (onEdited)=\"onEdited($event)\"\n (onStopEditing)=\"onStopEditing()\">\n </input-editor>\n</div>" }]
309
272
  }], ctorParameters: function () { return []; } });
310
273
 
311
274
  class EditCellComponent {
@@ -318,7 +281,11 @@ class EditCellComponent {
318
281
  return false;
319
282
  }
320
283
  getEditorType() {
321
- return this.cell.getColumn().editor && this.cell.getColumn().editor.type;
284
+ const editor = this.cell.getColumn().editor;
285
+ if (editor) {
286
+ return editor.type;
287
+ }
288
+ return 'text';
322
289
  }
323
290
  }
324
291
  EditCellComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EditCellComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
@@ -370,7 +337,6 @@ class CustomViewComponent {
370
337
  ngOnInit() {
371
338
  if (this.cell && !this.customComponent) {
372
339
  this.createCustomComponent();
373
- this.callOnComponentInit();
374
340
  this.patchInstance();
375
341
  }
376
342
  }
@@ -383,10 +349,6 @@ class CustomViewComponent {
383
349
  const componentFactory = this.resolver.resolveComponentFactory(this.cell.getColumn().renderComponent);
384
350
  this.customComponent = this.dynamicTarget.createComponent(componentFactory);
385
351
  }
386
- callOnComponentInit() {
387
- const onComponentInitFunction = this.cell.getColumn().getOnComponentInitFunction();
388
- onComponentInitFunction && onComponentInitFunction(this.customComponent.instance);
389
- }
390
352
  patchInstance() {
391
353
  Object.assign(this.customComponent.instance, this.getPatch());
392
354
  }
@@ -509,7 +471,6 @@ const CELL_COMPONENTS = [
509
471
  DefaultEditComponent,
510
472
  EditCellComponent,
511
473
  CheckboxEditorComponent,
512
- CompleterEditorComponent,
513
474
  InputEditorComponent,
514
475
  SelectEditorComponent,
515
476
  TextareaEditorComponent,
@@ -526,7 +487,6 @@ CellModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15
526
487
  DefaultEditComponent,
527
488
  EditCellComponent,
528
489
  CheckboxEditorComponent,
529
- CompleterEditorComponent,
530
490
  InputEditorComponent,
531
491
  SelectEditorComponent,
532
492
  TextareaEditorComponent,
@@ -539,7 +499,6 @@ CellModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15
539
499
  DefaultEditComponent,
540
500
  EditCellComponent,
541
501
  CheckboxEditorComponent,
542
- CompleterEditorComponent,
543
502
  InputEditorComponent,
544
503
  SelectEditorComponent,
545
504
  TextareaEditorComponent,
@@ -566,8 +525,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
566
525
  class FilterDefault {
567
526
  constructor() {
568
527
  this.inputClass = '';
569
- this.filter = new EventEmitter();
570
528
  this.query = '';
529
+ this.filter = new EventEmitter();
571
530
  }
572
531
  onFilter(query) {
573
532
  this.source.addFilter({
@@ -578,7 +537,7 @@ class FilterDefault {
578
537
  }
579
538
  }
580
539
  FilterDefault.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FilterDefault, deps: [], target: i0.ɵɵFactoryTarget.Component });
581
- FilterDefault.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: FilterDefault, selector: "ng-component", inputs: { column: "column", source: "source", inputClass: "inputClass" }, outputs: { filter: "filter" }, ngImport: i0, template: '', isInline: true });
540
+ FilterDefault.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: FilterDefault, selector: "ng-component", inputs: { column: "column", source: "source", inputClass: "inputClass", query: "query" }, outputs: { filter: "filter" }, ngImport: i0, template: '', isInline: true });
582
541
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FilterDefault, decorators: [{
583
542
  type: Component,
584
543
  args: [{
@@ -590,6 +549,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
590
549
  type: Input
591
550
  }], inputClass: [{
592
551
  type: Input
552
+ }], query: [{
553
+ type: Input
593
554
  }], filter: [{
594
555
  type: Output
595
556
  }] } });
@@ -597,6 +558,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
597
558
  class DefaultFilter {
598
559
  constructor() {
599
560
  this.delay = 300;
561
+ this.query = '';
562
+ this.inputClass = '';
600
563
  this.filter = new EventEmitter();
601
564
  }
602
565
  ngOnDestroy() {
@@ -668,63 +631,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
668
631
  }]
669
632
  }], ctorParameters: function () { return []; } });
670
633
 
671
- class CompleterFilterComponent extends DefaultFilter {
672
- constructor() {
673
- super();
674
- this.completerContent = new Subject();
675
- }
676
- ngOnInit() {
677
- // const config = this.column.getFilterConfig().completer;
678
- // config.dataService = this.completerService.local(config.data, config.searchFields, config.titleField);
679
- // config.dataService.descriptionField(config.descriptionField);
680
- // this.changesSubscription = this.completerContent
681
- // .pipe(
682
- // map((ev: any) => (ev && ev.title) || ev || ''),
683
- // distinctUntilChanged(),
684
- // debounceTime(this.delay)
685
- // )
686
- // .subscribe((search: string) => {
687
- // this.query = search;
688
- // this.setFilter();
689
- // });
690
- }
691
- inputTextChanged(event) {
692
- // workaround to trigger the search event when the home/end buttons are clicked
693
- // when this happens the [(ngModel)]="query" is set to "" but the (selected) method is not called
694
- // so here it gets called manually
695
- if (event === '') {
696
- this.completerContent.next(event);
697
- }
698
- }
699
- }
700
- CompleterFilterComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CompleterFilterComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
701
- CompleterFilterComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: CompleterFilterComponent, selector: "completer-filter", usesInheritance: true, ngImport: i0, template: `
702
- <!-- <ng2-completer [(ngModel)]="query"
703
- (ngModelChange)="inputTextChanged($event)"
704
- [dataService]="column.getFilterConfig().completer.dataService"
705
- [minSearchLength]="column.getFilterConfig().completer.minSearchLength || 0"
706
- [pause]="column.getFilterConfig().completer.pause || 0"
707
- [placeholder]="column.getFilterConfig().completer.placeholder || 'Start typing...'"
708
- (selected)="completerContent.next($event)">
709
- </ng2-completer> -->
710
- `, isInline: true });
711
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CompleterFilterComponent, decorators: [{
712
- type: Component,
713
- args: [{
714
- selector: 'completer-filter',
715
- template: `
716
- <!-- <ng2-completer [(ngModel)]="query"
717
- (ngModelChange)="inputTextChanged($event)"
718
- [dataService]="column.getFilterConfig().completer.dataService"
719
- [minSearchLength]="column.getFilterConfig().completer.minSearchLength || 0"
720
- [pause]="column.getFilterConfig().completer.pause || 0"
721
- [placeholder]="column.getFilterConfig().completer.placeholder || 'Start typing...'"
722
- (selected)="completerContent.next($event)">
723
- </ng2-completer> -->
724
- `,
725
- }]
726
- }], ctorParameters: function () { return []; } });
727
-
728
634
  class InputFilterComponent extends DefaultFilter {
729
635
  constructor() {
730
636
  super();
@@ -742,7 +648,7 @@ class InputFilterComponent extends DefaultFilter {
742
648
  });
743
649
  }
744
650
  ngOnChanges(changes) {
745
- if (changes.query) {
651
+ if (changes === null || changes === void 0 ? void 0 : changes['query']) {
746
652
  this.inputControl.setValue(this.query);
747
653
  }
748
654
  }
@@ -776,9 +682,11 @@ class SelectFilterComponent extends DefaultFilter {
776
682
  super();
777
683
  }
778
684
  ngOnInit() {
779
- this.inputControl.valueChanges
780
- .pipe(skip(1), distinctUntilChanged(), debounceTime(this.delay))
781
- .subscribe((value) => this.setFilter());
685
+ if (this.inputControl.valueChanges) {
686
+ this.inputControl.valueChanges
687
+ .pipe(skip(1), distinctUntilChanged(), debounceTime(this.delay))
688
+ .subscribe((value) => this.setFilter());
689
+ }
782
690
  }
783
691
  }
784
692
  SelectFilterComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SelectFilterComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
@@ -819,7 +727,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
819
727
  class DefaultFilterComponent extends FilterDefault {
820
728
  }
821
729
  DefaultFilterComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DefaultFilterComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
822
- DefaultFilterComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: DefaultFilterComponent, selector: "default-table-filter", inputs: { query: "query" }, usesInheritance: true, ngImport: i0, template: `
730
+ DefaultFilterComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: DefaultFilterComponent, selector: "default-table-filter", usesInheritance: true, ngImport: i0, template: `
823
731
  <ng-container [ngSwitch]="column.getFilterType()">
824
732
  <select-filter *ngSwitchCase="'list'"
825
733
  [query]="query"
@@ -833,12 +741,6 @@ DefaultFilterComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0",
833
741
  [column]="column"
834
742
  (filter)="onFilter($event)">
835
743
  </checkbox-filter>
836
- <completer-filter *ngSwitchCase="'completer'"
837
- [query]="query"
838
- [ngClass]="inputClass"
839
- [column]="column"
840
- (filter)="onFilter($event)">
841
- </completer-filter>
842
744
  <input-filter *ngSwitchDefault
843
745
  [query]="query"
844
746
  [ngClass]="inputClass"
@@ -846,7 +748,7 @@ DefaultFilterComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0",
846
748
  (filter)="onFilter($event)">
847
749
  </input-filter>
848
750
  </ng-container>
849
- `, isInline: true, dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { kind: "directive", type: i1.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { kind: "directive", type: i1.NgSwitchDefault, selector: "[ngSwitchDefault]" }, { kind: "component", type: CheckboxFilterComponent, selector: "checkbox-filter" }, { kind: "component", type: CompleterFilterComponent, selector: "completer-filter" }, { kind: "component", type: InputFilterComponent, selector: "input-filter" }, { kind: "component", type: SelectFilterComponent, selector: "select-filter" }] });
751
+ `, isInline: true, dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { kind: "directive", type: i1.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { kind: "directive", type: i1.NgSwitchDefault, selector: "[ngSwitchDefault]" }, { kind: "component", type: CheckboxFilterComponent, selector: "checkbox-filter" }, { kind: "component", type: InputFilterComponent, selector: "input-filter" }, { kind: "component", type: SelectFilterComponent, selector: "select-filter" }] });
850
752
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DefaultFilterComponent, decorators: [{
851
753
  type: Component,
852
754
  args: [{
@@ -865,12 +767,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
865
767
  [column]="column"
866
768
  (filter)="onFilter($event)">
867
769
  </checkbox-filter>
868
- <completer-filter *ngSwitchCase="'completer'"
869
- [query]="query"
870
- [ngClass]="inputClass"
871
- [column]="column"
872
- (filter)="onFilter($event)">
873
- </completer-filter>
874
770
  <input-filter *ngSwitchDefault
875
771
  [query]="query"
876
772
  [ngClass]="inputClass"
@@ -880,9 +776,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
880
776
  </ng-container>
881
777
  `,
882
778
  }]
883
- }], propDecorators: { query: [{
884
- type: Input
885
- }] } });
779
+ }] });
886
780
 
887
781
  class CustomFilterComponent extends FilterDefault {
888
782
  constructor(resolver) {
@@ -890,19 +784,21 @@ class CustomFilterComponent extends FilterDefault {
890
784
  this.resolver = resolver;
891
785
  }
892
786
  ngOnChanges(changes) {
893
- if (this.column && !this.customComponent) {
894
- const componentFactory = this.resolver.resolveComponentFactory(this.column.filter.component);
895
- this.customComponent = this.dynamicTarget.createComponent(componentFactory);
896
- // set @Inputs and @Outputs of custom component
897
- this.customComponent.instance.query = this.query;
898
- this.customComponent.instance.column = this.column;
899
- this.customComponent.instance.source = this.source;
900
- this.customComponent.instance.inputClass = this.inputClass;
901
- this.customComponent.instance.filter.subscribe((event) => this.onFilter(event));
902
- }
787
+ var _a;
903
788
  if (this.customComponent) {
904
789
  this.customComponent.instance.ngOnChanges(changes);
790
+ return;
791
+ }
792
+ if (this.column.filter && this.column.filter.type === 'custom') {
793
+ const componentFactory = this.resolver.resolveComponentFactory((_a = this.column.filter) === null || _a === void 0 ? void 0 : _a.component);
794
+ this.customComponent = this.dynamicTarget.createComponent(componentFactory);
905
795
  }
796
+ // set @Inputs and @Outputs of custom component
797
+ this.customComponent.instance.query = this.query;
798
+ this.customComponent.instance.column = this.column;
799
+ this.customComponent.instance.source = this.source;
800
+ this.customComponent.instance.inputClass = this.inputClass;
801
+ this.customComponent.instance.filter.subscribe((event) => this.onFilter(event));
906
802
  }
907
803
  ngOnDestroy() {
908
804
  if (this.customComponent) {
@@ -911,28 +807,22 @@ class CustomFilterComponent extends FilterDefault {
911
807
  }
912
808
  }
913
809
  CustomFilterComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CustomFilterComponent, deps: [{ token: i0.ComponentFactoryResolver }], target: i0.ɵɵFactoryTarget.Component });
914
- CustomFilterComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: CustomFilterComponent, selector: "custom-table-filter", inputs: { query: "query" }, 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 });
810
+ CustomFilterComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: CustomFilterComponent, selector: "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 });
915
811
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CustomFilterComponent, decorators: [{
916
812
  type: Component,
917
813
  args: [{
918
814
  selector: 'custom-table-filter',
919
815
  template: `<ng-template #dynamicTarget></ng-template>`,
920
816
  }]
921
- }], ctorParameters: function () { return [{ type: i0.ComponentFactoryResolver }]; }, propDecorators: { query: [{
922
- type: Input
923
- }], dynamicTarget: [{
817
+ }], ctorParameters: function () { return [{ type: i0.ComponentFactoryResolver }]; }, propDecorators: { dynamicTarget: [{
924
818
  type: ViewChild,
925
819
  args: ['dynamicTarget', { read: ViewContainerRef, static: true }]
926
820
  }] } });
927
821
 
928
822
  class FilterComponent extends FilterDefault {
929
- constructor() {
930
- super(...arguments);
931
- this.query = '';
932
- }
933
823
  ngOnChanges(changes) {
934
- if (changes.source) {
935
- if (!changes.source.firstChange) {
824
+ if (changes['source']) {
825
+ if (!changes['source'].firstChange && this.dataChangedSub) {
936
826
  this.dataChangedSub.unsubscribe();
937
827
  }
938
828
  this.dataChangedSub = this.source.onChanged().subscribe((dataChanges) => {
@@ -971,7 +861,7 @@ FilterComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", versio
971
861
  (filter)="onFilter($event)">
972
862
  </default-table-filter>
973
863
  </div>
974
- `, 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: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { kind: "directive", type: i1.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { kind: "directive", type: i1.NgSwitchDefault, selector: "[ngSwitchDefault]" }, { kind: "component", type: DefaultFilterComponent, selector: "default-table-filter", inputs: ["query"] }, { kind: "component", type: CustomFilterComponent, selector: "custom-table-filter", inputs: ["query"] }] });
864
+ `, 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: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { kind: "directive", type: i1.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { kind: "directive", type: i1.NgSwitchDefault, selector: "[ngSwitchDefault]" }, { kind: "component", type: DefaultFilterComponent, selector: "default-table-filter" }, { kind: "component", type: CustomFilterComponent, selector: "custom-table-filter" }] });
975
865
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FilterComponent, decorators: [{
976
866
  type: Component,
977
867
  args: [{ selector: 'ng2-smart-table-filter', template: `
@@ -1001,7 +891,6 @@ const FILTER_COMPONENTS = [
1001
891
  DefaultFilterComponent,
1002
892
  CustomFilterComponent,
1003
893
  CheckboxFilterComponent,
1004
- CompleterFilterComponent,
1005
894
  InputFilterComponent,
1006
895
  SelectFilterComponent,
1007
896
  ];
@@ -1014,7 +903,6 @@ FilterModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "
1014
903
  DefaultFilterComponent,
1015
904
  CustomFilterComponent,
1016
905
  CheckboxFilterComponent,
1017
- CompleterFilterComponent,
1018
906
  InputFilterComponent,
1019
907
  SelectFilterComponent], imports: [CommonModule,
1020
908
  FormsModule,
@@ -1024,7 +912,6 @@ FilterModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "
1024
912
  DefaultFilterComponent,
1025
913
  CustomFilterComponent,
1026
914
  CheckboxFilterComponent,
1027
- CompleterFilterComponent,
1028
915
  InputFilterComponent,
1029
916
  SelectFilterComponent] });
1030
917
  FilterModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FilterModule, imports: [CommonModule,
@@ -1051,16 +938,23 @@ class PagerComponent {
1051
938
  constructor() {
1052
939
  this.perPageSelect = [];
1053
940
  this.changePage = new EventEmitter();
941
+ this.currentPerPage = 0;
942
+ this.pages = [];
943
+ this.page = 1;
1054
944
  this.count = 0;
945
+ this.perPage = 0;
1055
946
  }
1056
947
  ngOnChanges(changes) {
1057
- if (changes.source) {
1058
- if (!changes.source.firstChange) {
948
+ if (changes['source']) {
949
+ if (!changes['source'].firstChange && this.dataChangedSub) {
1059
950
  this.dataChangedSub.unsubscribe();
1060
951
  }
1061
952
  this.dataChangedSub = this.source.onChanged().subscribe((dataChanges) => {
1062
- this.page = this.source.getPaging().page;
1063
- this.perPage = this.source.getPaging().perPage;
953
+ const paging = this.source.getPaging();
954
+ if (paging) {
955
+ this.page = paging.page;
956
+ this.perPage = paging.perPage;
957
+ }
1064
958
  this.currentPerPage = this.perPage;
1065
959
  this.count = this.source.count();
1066
960
  if (this.isPageOutOfBounce()) {
@@ -1128,17 +1022,13 @@ class PagerComponent {
1128
1022
  }
1129
1023
  }
1130
1024
  }
1131
- onChangePerPage(event) {
1132
- if (this.currentPerPage) {
1133
- if (typeof this.currentPerPage === 'string' && this.currentPerPage.toLowerCase() === 'all') {
1134
- this.source.getPaging().perPage = null;
1135
- }
1136
- else {
1137
- this.source.getPaging().perPage = this.currentPerPage * 1;
1138
- this.source.refresh();
1139
- }
1140
- this.initPages();
1025
+ onChangePerPage() {
1026
+ const paging = this.source.getPaging();
1027
+ if (paging) {
1028
+ paging.perPage = this.currentPerPage * 1;
1141
1029
  }
1030
+ this.source.refresh();
1031
+ this.initPages();
1142
1032
  }
1143
1033
  }
1144
1034
  PagerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: PagerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
@@ -1191,7 +1081,7 @@ PagerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version
1191
1081
  <label for="per-page">
1192
1082
  Per Page:
1193
1083
  </label>
1194
- <select (change)="onChangePerPage($event)" [(ngModel)]="currentPerPage" id="per-page">
1084
+ <select (change)="onChangePerPage()" [(ngModel)]="currentPerPage" id="per-page">
1195
1085
  <option *ngFor="let item of perPageSelect" [value]="item">{{ item }}</option>
1196
1086
  </select>
1197
1087
  </nav>
@@ -1247,7 +1137,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
1247
1137
  <label for="per-page">
1248
1138
  Per Page:
1249
1139
  </label>
1250
- <select (change)="onChangePerPage($event)" [(ngModel)]="currentPerPage" id="per-page">
1140
+ <select (change)="onChangePerPage()" [(ngModel)]="currentPerPage" id="per-page">
1251
1141
  <option *ngFor="let item of perPageSelect" [value]="item">{{ item }}</option>
1252
1142
  </select>
1253
1143
  </nav>
@@ -1284,6 +1174,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
1284
1174
  }] });
1285
1175
 
1286
1176
  class TbodyCreateCancelComponent {
1177
+ constructor() {
1178
+ this.cancelButtonContent = '';
1179
+ this.saveButtonContent = '';
1180
+ }
1287
1181
  onSave(event) {
1288
1182
  event.preventDefault();
1289
1183
  event.stopPropagation();
@@ -1296,8 +1190,8 @@ class TbodyCreateCancelComponent {
1296
1190
  this.row.isInEditing = false;
1297
1191
  }
1298
1192
  ngOnChanges() {
1299
- this.saveButtonContent = this.grid.getSetting('edit.saveButtonContent');
1300
- this.cancelButtonContent = this.grid.getSetting('edit.cancelButtonContent');
1193
+ this.saveButtonContent = this.grid.getSetting('edit.saveButtonContent', 'save');
1194
+ this.cancelButtonContent = this.grid.getSetting('edit.cancelButtonContent', 'cancel');
1301
1195
  }
1302
1196
  }
1303
1197
  TbodyCreateCancelComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: TbodyCreateCancelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
@@ -1333,6 +1227,10 @@ class TbodyEditDeleteComponent {
1333
1227
  this.edit = new EventEmitter();
1334
1228
  this.delete = new EventEmitter();
1335
1229
  this.editRowSelect = new EventEmitter();
1230
+ this.isActionEdit = false;
1231
+ this.isActionDelete = false;
1232
+ this.editRowButtonContent = '';
1233
+ this.deleteRowButtonContent = '';
1336
1234
  }
1337
1235
  onEdit(event) {
1338
1236
  event.preventDefault();
@@ -1448,6 +1346,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
1448
1346
 
1449
1347
  class Ng2SmartTableTbodyComponent {
1450
1348
  constructor() {
1349
+ this.rowClassFunction = () => '';
1451
1350
  this.save = new EventEmitter();
1452
1351
  this.cancel = new EventEmitter();
1453
1352
  this.edit = new EventEmitter();
@@ -1459,6 +1358,15 @@ class Ng2SmartTableTbodyComponent {
1459
1358
  this.userClickedRow = new EventEmitter();
1460
1359
  this.editRowSelect = new EventEmitter();
1461
1360
  this.multipleSelectRow = new EventEmitter();
1361
+ this.isMultiSelectVisible = false;
1362
+ this.showActionColumnLeft = false;
1363
+ this.showActionColumnRight = false;
1364
+ this.mode = 'inline';
1365
+ this.editInputClass = '';
1366
+ this.isActionAdd = false;
1367
+ this.isActionEdit = false;
1368
+ this.isActionDelete = false;
1369
+ this.noDataMessage = false;
1462
1370
  }
1463
1371
  get tableColumnsCount() {
1464
1372
  const actionColumns = this.isActionAdd || this.isActionEdit || this.isActionDelete ? 1 : 0;
@@ -1467,23 +1375,26 @@ class Ng2SmartTableTbodyComponent {
1467
1375
  ngOnChanges() {
1468
1376
  this.isMultiSelectVisible = this.grid.isMultiSelectVisible();
1469
1377
  this.showActionColumnLeft = this.grid.showActionColumn('left');
1470
- this.mode = this.grid.getSetting('mode');
1471
- this.editInputClass = this.grid.getSetting('edit.inputClass');
1378
+ this.mode = this.grid.getSetting('mode', 'inline');
1379
+ this.editInputClass = this.grid.getSetting('edit.inputClass', '');
1472
1380
  this.showActionColumnRight = this.grid.showActionColumn('right');
1473
- this.isActionAdd = this.grid.getSetting('actions.add');
1474
- this.isActionEdit = this.grid.getSetting('actions.edit');
1475
- this.isActionDelete = this.grid.getSetting('actions.delete');
1381
+ this.isActionAdd = this.grid.getSetting('actions.add', false);
1382
+ this.isActionEdit = this.grid.getSetting('actions.edit', false);
1383
+ this.isActionDelete = this.grid.getSetting('actions.delete', false);
1476
1384
  this.noDataMessage = this.grid.getSetting('noDataMessage');
1477
1385
  }
1478
1386
  getVisibleCells(cells) {
1479
1387
  return (cells || []).filter((cell) => !cell.getColumn().hide);
1480
1388
  }
1389
+ trackByIdOrIndex(index, item) {
1390
+ return (item === null || item === void 0 ? void 0 : item.id) || index;
1391
+ }
1481
1392
  }
1482
1393
  Ng2SmartTableTbodyComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: Ng2SmartTableTbodyComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1483
- Ng2SmartTableTbodyComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: Ng2SmartTableTbodyComponent, selector: "[ng2-st-tbody]", inputs: { grid: "grid", source: "source", deleteConfirm: "deleteConfirm", editConfirm: "editConfirm", rowClassFunction: "rowClassFunction" }, outputs: { save: "save", cancel: "cancel", edit: "edit", editCancel: "editCancel", delete: "delete", custom: "custom", edited: "edited", userSelectRow: "userSelectRow", userClickedRow: "userClickedRow", editRowSelect: "editRowSelect", multipleSelectRow: "multipleSelectRow" }, usesOnChanges: true, ngImport: i0, template: "<tr *ngFor=\"let row of grid.getRows()\" (click)=\"userClickedRow.emit(row)\" class=\"ng2-smart-row\" [className]=\"rowClassFunction(row)\" [ngClass]=\"{selected: row.isSelected}\">\n <td *ngIf=\"isMultiSelectVisible\" class=\"ng2-smart-actions ng2-smart-action-multiple-select\" (click)=\"multipleSelectRow.emit(row); $event.stopPropagation();\">\n <input type=\"checkbox\" class=\"form-control\" [ngModel]=\"row.isSelected\">\n </td>\n <td *ngIf=\"!row.isInEditing && showActionColumnLeft\" class=\"ng2-smart-actions\" (click)=\"$event.stopPropagation()\">\n <ng2-st-tbody-custom [grid]=\"grid\" (custom)=\"custom.emit($event)\" [row]=\"row\" [source]=\"source\"></ng2-st-tbody-custom>\n\n <ng2-st-tbody-edit-delete [grid]=\"grid\"\n [deleteConfirm]=\"deleteConfirm\"\n [editConfirm]=\"editConfirm\"\n (edit)=\"edit.emit(row)\"\n (delete)=\"delete.emit(row)\"\n (editRowSelect)=\"editRowSelect.emit($event)\"\n [row]=\"row\"\n [source]=\"source\">\n </ng2-st-tbody-edit-delete>\n </td>\n <td *ngIf=\"row.isInEditing && showActionColumnLeft\" class=\"ng2-smart-actions\">\n <ng2-st-tbody-create-cancel [grid]=\"grid\" [row]=\"row\" [editConfirm]=\"editConfirm\" [editCancel]=\"editCancel\"></ng2-st-tbody-create-cancel>\n </td>\n <td *ngFor=\"let cell of getVisibleCells(row.cells)\">\n <ng2-smart-table-cell [cell]=\"cell\"\n [grid]=\"grid\"\n [row]=\"row\"\n [isNew]=\"false\"\n [mode]=\"mode\"\n [editConfirm]=\"editConfirm\"\n [inputClass]=\"editInputClass\"\n [isInEditing]=\"row.isInEditing\">\n </ng2-smart-table-cell>\n </td>\n\n <td *ngIf=\"row.isInEditing && showActionColumnRight\" class=\"ng2-smart-actions\">\n <ng2-st-tbody-create-cancel [grid]=\"grid\" [row]=\"row\" [editConfirm]=\"editConfirm\"></ng2-st-tbody-create-cancel>\n </td>\n\n <td *ngIf=\"!row.isInEditing && showActionColumnRight\" class=\"ng2-smart-actions\">\n <ng2-st-tbody-custom [grid]=\"grid\" (custom)=\"custom.emit($event)\" [row]=\"row\" [source]=\"source\"></ng2-st-tbody-custom>\n\n <ng2-st-tbody-edit-delete [grid]=\"grid\"\n [deleteConfirm]=\"deleteConfirm\"\n [editConfirm]=\"editConfirm\"\n [row]=\"row\"\n [source]=\"source\"\n (edit)=\"edit.emit(row)\"\n (delete)=\"delete.emit(row)\"\n (editRowSelect)=\"editRowSelect.emit($event)\">\n </ng2-st-tbody-edit-delete>\n </td>\n</tr>\n\n<tr *ngIf=\"grid.getRows().length == 0\">\n <td [attr.colspan]=\"tableColumnsCount\">\n {{ noDataMessage }}\n </td>\n</tr>\n", styles: [":host .ng2-smart-row.selected{background:rgba(0,0,0,.05)}: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: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: CellComponent, selector: "ng2-smart-table-cell", inputs: ["grid", "row", "editConfirm", "createConfirm", "isNew", "cell", "inputClass", "mode", "isInEditing"], outputs: ["edited"] }, { kind: "component", type: TbodyCreateCancelComponent, selector: "ng2-st-tbody-create-cancel", inputs: ["grid", "row", "editConfirm", "editCancel"] }, { kind: "component", type: TbodyEditDeleteComponent, selector: "ng2-st-tbody-edit-delete", inputs: ["grid", "row", "source", "deleteConfirm", "editConfirm"], outputs: ["edit", "delete", "editRowSelect"] }, { kind: "component", type: TbodyCustomComponent, selector: "ng2-st-tbody-custom", inputs: ["grid", "row", "source"], outputs: ["custom"] }] });
1394
+ Ng2SmartTableTbodyComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: Ng2SmartTableTbodyComponent, selector: "[ng2-st-tbody]", inputs: { grid: "grid", source: "source", deleteConfirm: "deleteConfirm", editConfirm: "editConfirm", rowClassFunction: "rowClassFunction" }, outputs: { save: "save", cancel: "cancel", edit: "edit", editCancel: "editCancel", delete: "delete", custom: "custom", edited: "edited", userSelectRow: "userSelectRow", userClickedRow: "userClickedRow", editRowSelect: "editRowSelect", multipleSelectRow: "multipleSelectRow" }, usesOnChanges: true, ngImport: i0, template: "<tr *ngFor=\"let row of grid.getRows(); trackBy: trackByIdOrIndex\" (click)=\"userClickedRow.emit(row)\" class=\"ng2-smart-row\" [className]=\"rowClassFunction(row)\" [ngClass]=\"{selected: row.isSelected}\">\n <td *ngIf=\"isMultiSelectVisible\" class=\"ng2-smart-actions ng2-smart-action-multiple-select\" (click)=\"multipleSelectRow.emit(row); $event.stopPropagation();\">\n <input type=\"checkbox\" class=\"form-control\" [ngModel]=\"row.isSelected\">\n </td>\n <td *ngIf=\"!row.isInEditing && showActionColumnLeft\" class=\"ng2-smart-actions\" (click)=\"$event.stopPropagation()\">\n <ng2-st-tbody-custom [grid]=\"grid\" (custom)=\"custom.emit($event)\" [row]=\"row\" [source]=\"source\"></ng2-st-tbody-custom>\n\n <ng2-st-tbody-edit-delete [grid]=\"grid\"\n [deleteConfirm]=\"deleteConfirm\"\n [editConfirm]=\"editConfirm\"\n (edit)=\"edit.emit(row)\"\n (delete)=\"delete.emit(row)\"\n (editRowSelect)=\"editRowSelect.emit($event)\"\n [row]=\"row\"\n [source]=\"source\">\n </ng2-st-tbody-edit-delete>\n </td>\n <td *ngIf=\"row.isInEditing && showActionColumnLeft\" class=\"ng2-smart-actions\">\n <ng2-st-tbody-create-cancel [grid]=\"grid\" [row]=\"row\" [editConfirm]=\"editConfirm\" [editCancel]=\"editCancel\"></ng2-st-tbody-create-cancel>\n </td>\n <td *ngFor=\"let cell of getVisibleCells(row.cells)\">\n <ng2-smart-table-cell [cell]=\"cell\"\n [grid]=\"grid\"\n [row]=\"row\"\n [isNew]=\"false\"\n [mode]=\"mode\"\n [editConfirm]=\"editConfirm\"\n [inputClass]=\"editInputClass\"\n [isInEditing]=\"row.isInEditing\">\n </ng2-smart-table-cell>\n </td>\n\n <td *ngIf=\"row.isInEditing && showActionColumnRight\" class=\"ng2-smart-actions\">\n <ng2-st-tbody-create-cancel [grid]=\"grid\" [row]=\"row\" [editConfirm]=\"editConfirm\"></ng2-st-tbody-create-cancel>\n </td>\n\n <td *ngIf=\"!row.isInEditing && showActionColumnRight\" class=\"ng2-smart-actions\">\n <ng2-st-tbody-custom [grid]=\"grid\" (custom)=\"custom.emit($event)\" [row]=\"row\" [source]=\"source\"></ng2-st-tbody-custom>\n\n <ng2-st-tbody-edit-delete [grid]=\"grid\"\n [deleteConfirm]=\"deleteConfirm\"\n [editConfirm]=\"editConfirm\"\n [row]=\"row\"\n [source]=\"source\"\n (edit)=\"edit.emit(row)\"\n (delete)=\"delete.emit(row)\"\n (editRowSelect)=\"editRowSelect.emit($event)\">\n </ng2-st-tbody-edit-delete>\n </td>\n</tr>\n\n<tr *ngIf=\"grid.getRows().length == 0\">\n <td [attr.colspan]=\"tableColumnsCount\">\n {{ noDataMessage }}\n </td>\n</tr>\n", styles: [":host .ng2-smart-row.selected{background:rgba(0,0,0,.05)}: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: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: CellComponent, selector: "ng2-smart-table-cell", inputs: ["grid", "row", "editConfirm", "createConfirm", "isNew", "cell", "inputClass", "mode", "isInEditing"], outputs: ["edited"] }, { kind: "component", type: TbodyCreateCancelComponent, selector: "ng2-st-tbody-create-cancel", inputs: ["grid", "row", "editConfirm", "editCancel"] }, { kind: "component", type: TbodyEditDeleteComponent, selector: "ng2-st-tbody-edit-delete", inputs: ["grid", "row", "source", "deleteConfirm", "editConfirm"], outputs: ["edit", "delete", "editRowSelect"] }, { kind: "component", type: TbodyCustomComponent, selector: "ng2-st-tbody-custom", inputs: ["grid", "row", "source"], outputs: ["custom"] }] });
1484
1395
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: Ng2SmartTableTbodyComponent, decorators: [{
1485
1396
  type: Component,
1486
- args: [{ selector: '[ng2-st-tbody]', template: "<tr *ngFor=\"let row of grid.getRows()\" (click)=\"userClickedRow.emit(row)\" class=\"ng2-smart-row\" [className]=\"rowClassFunction(row)\" [ngClass]=\"{selected: row.isSelected}\">\n <td *ngIf=\"isMultiSelectVisible\" class=\"ng2-smart-actions ng2-smart-action-multiple-select\" (click)=\"multipleSelectRow.emit(row); $event.stopPropagation();\">\n <input type=\"checkbox\" class=\"form-control\" [ngModel]=\"row.isSelected\">\n </td>\n <td *ngIf=\"!row.isInEditing && showActionColumnLeft\" class=\"ng2-smart-actions\" (click)=\"$event.stopPropagation()\">\n <ng2-st-tbody-custom [grid]=\"grid\" (custom)=\"custom.emit($event)\" [row]=\"row\" [source]=\"source\"></ng2-st-tbody-custom>\n\n <ng2-st-tbody-edit-delete [grid]=\"grid\"\n [deleteConfirm]=\"deleteConfirm\"\n [editConfirm]=\"editConfirm\"\n (edit)=\"edit.emit(row)\"\n (delete)=\"delete.emit(row)\"\n (editRowSelect)=\"editRowSelect.emit($event)\"\n [row]=\"row\"\n [source]=\"source\">\n </ng2-st-tbody-edit-delete>\n </td>\n <td *ngIf=\"row.isInEditing && showActionColumnLeft\" class=\"ng2-smart-actions\">\n <ng2-st-tbody-create-cancel [grid]=\"grid\" [row]=\"row\" [editConfirm]=\"editConfirm\" [editCancel]=\"editCancel\"></ng2-st-tbody-create-cancel>\n </td>\n <td *ngFor=\"let cell of getVisibleCells(row.cells)\">\n <ng2-smart-table-cell [cell]=\"cell\"\n [grid]=\"grid\"\n [row]=\"row\"\n [isNew]=\"false\"\n [mode]=\"mode\"\n [editConfirm]=\"editConfirm\"\n [inputClass]=\"editInputClass\"\n [isInEditing]=\"row.isInEditing\">\n </ng2-smart-table-cell>\n </td>\n\n <td *ngIf=\"row.isInEditing && showActionColumnRight\" class=\"ng2-smart-actions\">\n <ng2-st-tbody-create-cancel [grid]=\"grid\" [row]=\"row\" [editConfirm]=\"editConfirm\"></ng2-st-tbody-create-cancel>\n </td>\n\n <td *ngIf=\"!row.isInEditing && showActionColumnRight\" class=\"ng2-smart-actions\">\n <ng2-st-tbody-custom [grid]=\"grid\" (custom)=\"custom.emit($event)\" [row]=\"row\" [source]=\"source\"></ng2-st-tbody-custom>\n\n <ng2-st-tbody-edit-delete [grid]=\"grid\"\n [deleteConfirm]=\"deleteConfirm\"\n [editConfirm]=\"editConfirm\"\n [row]=\"row\"\n [source]=\"source\"\n (edit)=\"edit.emit(row)\"\n (delete)=\"delete.emit(row)\"\n (editRowSelect)=\"editRowSelect.emit($event)\">\n </ng2-st-tbody-edit-delete>\n </td>\n</tr>\n\n<tr *ngIf=\"grid.getRows().length == 0\">\n <td [attr.colspan]=\"tableColumnsCount\">\n {{ noDataMessage }}\n </td>\n</tr>\n", styles: [":host .ng2-smart-row.selected{background:rgba(0,0,0,.05)}: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"] }]
1397
+ args: [{ selector: '[ng2-st-tbody]', template: "<tr *ngFor=\"let row of grid.getRows(); trackBy: trackByIdOrIndex\" (click)=\"userClickedRow.emit(row)\" class=\"ng2-smart-row\" [className]=\"rowClassFunction(row)\" [ngClass]=\"{selected: row.isSelected}\">\n <td *ngIf=\"isMultiSelectVisible\" class=\"ng2-smart-actions ng2-smart-action-multiple-select\" (click)=\"multipleSelectRow.emit(row); $event.stopPropagation();\">\n <input type=\"checkbox\" class=\"form-control\" [ngModel]=\"row.isSelected\">\n </td>\n <td *ngIf=\"!row.isInEditing && showActionColumnLeft\" class=\"ng2-smart-actions\" (click)=\"$event.stopPropagation()\">\n <ng2-st-tbody-custom [grid]=\"grid\" (custom)=\"custom.emit($event)\" [row]=\"row\" [source]=\"source\"></ng2-st-tbody-custom>\n\n <ng2-st-tbody-edit-delete [grid]=\"grid\"\n [deleteConfirm]=\"deleteConfirm\"\n [editConfirm]=\"editConfirm\"\n (edit)=\"edit.emit(row)\"\n (delete)=\"delete.emit(row)\"\n (editRowSelect)=\"editRowSelect.emit($event)\"\n [row]=\"row\"\n [source]=\"source\">\n </ng2-st-tbody-edit-delete>\n </td>\n <td *ngIf=\"row.isInEditing && showActionColumnLeft\" class=\"ng2-smart-actions\">\n <ng2-st-tbody-create-cancel [grid]=\"grid\" [row]=\"row\" [editConfirm]=\"editConfirm\" [editCancel]=\"editCancel\"></ng2-st-tbody-create-cancel>\n </td>\n <td *ngFor=\"let cell of getVisibleCells(row.cells)\">\n <ng2-smart-table-cell [cell]=\"cell\"\n [grid]=\"grid\"\n [row]=\"row\"\n [isNew]=\"false\"\n [mode]=\"mode\"\n [editConfirm]=\"editConfirm\"\n [inputClass]=\"editInputClass\"\n [isInEditing]=\"row.isInEditing\">\n </ng2-smart-table-cell>\n </td>\n\n <td *ngIf=\"row.isInEditing && showActionColumnRight\" class=\"ng2-smart-actions\">\n <ng2-st-tbody-create-cancel [grid]=\"grid\" [row]=\"row\" [editConfirm]=\"editConfirm\"></ng2-st-tbody-create-cancel>\n </td>\n\n <td *ngIf=\"!row.isInEditing && showActionColumnRight\" class=\"ng2-smart-actions\">\n <ng2-st-tbody-custom [grid]=\"grid\" (custom)=\"custom.emit($event)\" [row]=\"row\" [source]=\"source\"></ng2-st-tbody-custom>\n\n <ng2-st-tbody-edit-delete [grid]=\"grid\"\n [deleteConfirm]=\"deleteConfirm\"\n [editConfirm]=\"editConfirm\"\n [row]=\"row\"\n [source]=\"source\"\n (edit)=\"edit.emit(row)\"\n (delete)=\"delete.emit(row)\"\n (editRowSelect)=\"editRowSelect.emit($event)\">\n </ng2-st-tbody-edit-delete>\n </td>\n</tr>\n\n<tr *ngIf=\"grid.getRows().length == 0\">\n <td [attr.colspan]=\"tableColumnsCount\">\n {{ noDataMessage }}\n </td>\n</tr>\n", styles: [":host .ng2-smart-row.selected{background:rgba(0,0,0,.05)}: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"] }]
1487
1398
  }], propDecorators: { grid: [{
1488
1399
  type: Input
1489
1400
  }], source: [{
@@ -1560,6 +1471,8 @@ class AddButtonComponent {
1560
1471
  constructor(ref) {
1561
1472
  this.ref = ref;
1562
1473
  this.create = new EventEmitter();
1474
+ this.isActionAdd = false;
1475
+ this.addNewButtonContent = '';
1563
1476
  }
1564
1477
  ngAfterViewInit() {
1565
1478
  this.ref.nativeElement.classList.add('ng2-smart-actions-title', 'ng2-smart-actions-title-add');
@@ -1607,12 +1520,16 @@ class TheadFitlersRowComponent {
1607
1520
  constructor() {
1608
1521
  this.create = new EventEmitter();
1609
1522
  this.filter = new EventEmitter();
1523
+ this.isMultiSelectVisible = false;
1524
+ this.showActionColumnLeft = false;
1525
+ this.showActionColumnRight = false;
1526
+ this.filterInputClass = '';
1610
1527
  }
1611
1528
  ngOnChanges() {
1612
1529
  this.isMultiSelectVisible = this.grid.isMultiSelectVisible();
1613
1530
  this.showActionColumnLeft = this.grid.showActionColumn('left');
1614
1531
  this.showActionColumnRight = this.grid.showActionColumn('right');
1615
- this.filterInputClass = this.grid.getSetting('filter.inputClass');
1532
+ this.filterInputClass = this.grid.getSetting('filter.inputClass', '');
1616
1533
  }
1617
1534
  getVisibleColumns(columns) {
1618
1535
  return (columns || []).filter((column) => !column.hide);
@@ -1675,6 +1592,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
1675
1592
  class ActionsComponent {
1676
1593
  constructor() {
1677
1594
  this.create = new EventEmitter();
1595
+ this.createButtonContent = '';
1596
+ this.cancelButtonContent = '';
1678
1597
  }
1679
1598
  ngOnChanges() {
1680
1599
  this.createButtonContent = this.grid.getSetting('add.createButtonContent');
@@ -1712,6 +1631,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
1712
1631
  class TheadFormRowComponent {
1713
1632
  constructor() {
1714
1633
  this.create = new EventEmitter();
1634
+ this.isMultiSelectVisible = false;
1635
+ this.showActionColumnLeft = false;
1636
+ this.showActionColumnRight = false;
1637
+ this.addInputClass = '';
1715
1638
  }
1716
1639
  onCreate(event) {
1717
1640
  event.stopPropagation();
@@ -1721,7 +1644,7 @@ class TheadFormRowComponent {
1721
1644
  this.isMultiSelectVisible = this.grid.isMultiSelectVisible();
1722
1645
  this.showActionColumnLeft = this.grid.showActionColumn('left');
1723
1646
  this.showActionColumnRight = this.grid.showActionColumn('right');
1724
- this.addInputClass = this.grid.getSetting('add.inputClass');
1647
+ this.addInputClass = this.grid.getSetting('add.inputClass', '');
1725
1648
  }
1726
1649
  getVisibleCells(cells) {
1727
1650
  return (cells || []).filter((cell) => !cell.getColumn().hide);
@@ -1784,6 +1707,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
1784
1707
  class ActionsTitleComponent {
1785
1708
  constructor(ref) {
1786
1709
  this.ref = ref;
1710
+ this.actionsColumnTitle = '';
1787
1711
  }
1788
1712
  ngAfterViewInit() {
1789
1713
  this.ref.nativeElement.classList.add('ng2-smart-actions');
@@ -1832,10 +1756,11 @@ class TitleComponent {
1832
1756
  constructor() {
1833
1757
  this.currentDirection = '';
1834
1758
  this.sort = new EventEmitter();
1759
+ this.dataChangedSub = false;
1835
1760
  }
1836
1761
  ngOnChanges(changes) {
1837
- if (changes.source) {
1838
- if (!changes.source.firstChange) {
1762
+ if (changes['source']) {
1763
+ if (!changes['source'].firstChange && this.dataChangedSub) {
1839
1764
  this.dataChangedSub.unsubscribe();
1840
1765
  }
1841
1766
  this.dataChangedSub = this.source.onChanged().subscribe((dataChanges) => {
@@ -1846,8 +1771,6 @@ class TitleComponent {
1846
1771
  else {
1847
1772
  this.currentDirection = '';
1848
1773
  }
1849
- sortConf.forEach((fieldConf) => {
1850
- });
1851
1774
  });
1852
1775
  }
1853
1776
  }
@@ -1857,7 +1780,7 @@ class TitleComponent {
1857
1780
  this.source.setSort([
1858
1781
  {
1859
1782
  field: this.column.id,
1860
- direction: this.currentDirection,
1783
+ direction: this.currentDirection === 'desc' ? 'desc' : 'asc',
1861
1784
  compare: this.column.getCompareFunction(),
1862
1785
  },
1863
1786
  ]);
@@ -1936,6 +1859,9 @@ class TheadTitlesRowComponent {
1936
1859
  constructor() {
1937
1860
  this.sort = new EventEmitter();
1938
1861
  this.selectAllRows = new EventEmitter();
1862
+ this.isMultiSelectVisible = false;
1863
+ this.showActionColumnLeft = false;
1864
+ this.showActionColumnRight = false;
1939
1865
  }
1940
1866
  ngOnChanges() {
1941
1867
  this.isMultiSelectVisible = this.grid.isMultiSelectVisible();
@@ -1998,10 +1924,12 @@ class Ng2SmartTableTheadComponent {
1998
1924
  this.selectAllRows = new EventEmitter();
1999
1925
  this.create = new EventEmitter();
2000
1926
  this.filter = new EventEmitter();
1927
+ this.isHideHeader = false;
1928
+ this.isHideSubHeader = false;
2001
1929
  }
2002
1930
  ngOnChanges() {
2003
- this.isHideHeader = this.grid.getSetting('hideHeader');
2004
- this.isHideSubHeader = this.grid.getSetting('hideSubHeader');
1931
+ this.isHideHeader = this.grid.getSetting('hideHeader', false);
1932
+ this.isHideSubHeader = this.grid.getSetting('hideSubHeader', false);
2005
1933
  }
2006
1934
  }
2007
1935
  Ng2SmartTableTheadComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: Ng2SmartTableTheadComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
@@ -2152,7 +2080,7 @@ class Deferred {
2152
2080
  }
2153
2081
  }
2154
2082
  // getDeepFromObject({result: {data: 1}}, 'result.data', 2); // returns 1
2155
- function getDeepFromObject(object = {}, name, defaultValue) {
2083
+ function getDeepFromObject(object = {}, name, defaultValue = null) {
2156
2084
  const keys = name.split('.');
2157
2085
  // clone the object
2158
2086
  let level = deepExtend({}, object);
@@ -2260,7 +2188,7 @@ class Column {
2260
2188
  this.settings = settings;
2261
2189
  this.dataSet = dataSet;
2262
2190
  this.title = '';
2263
- this.type = '';
2191
+ this.type = 'text';
2264
2192
  this.class = '';
2265
2193
  this.width = '';
2266
2194
  this.hide = false;
@@ -2268,16 +2196,12 @@ class Column {
2268
2196
  this.isEditable = true;
2269
2197
  this.isAddable = true;
2270
2198
  this.isFilterable = false;
2271
- this.sortDirection = '';
2272
- this.defaultSortDirection = '';
2273
- this.editor = { type: '', config: {}, component: null };
2274
- this.filter = { type: '', config: {}, component: null };
2275
- this.renderComponent = null;
2199
+ this.sortDirection = 'asc';
2200
+ this.defaultSortDirection = false;
2201
+ this.editor = false;
2202
+ this.filter = false;
2276
2203
  this.process();
2277
2204
  }
2278
- getOnComponentInitFunction() {
2279
- return this.onComponentInitFunction;
2280
- }
2281
2205
  getCompareFunction() {
2282
2206
  return this.compareFunction;
2283
2207
  }
@@ -2288,44 +2212,50 @@ class Column {
2288
2212
  return this.filterFunction;
2289
2213
  }
2290
2214
  getConfig() {
2291
- return this.editor && this.editor.config;
2215
+ var _a;
2216
+ if (this.editor && (this.editor.type === 'checkbox' || this.editor.type === 'custom' || this.editor.type === 'list')) {
2217
+ return (_a = this.editor) === null || _a === void 0 ? void 0 : _a.config;
2218
+ }
2219
+ return false;
2292
2220
  }
2293
2221
  getFilterType() {
2294
2222
  return this.filter && this.filter.type;
2295
2223
  }
2296
2224
  getFilterConfig() {
2297
- return this.filter && this.filter.config;
2225
+ var _a;
2226
+ if (this.filter && (this.filter.type === 'checkbox' || this.filter.type === 'custom' || this.filter.type === 'list')) {
2227
+ return (_a = this.filter) === null || _a === void 0 ? void 0 : _a.config;
2228
+ }
2229
+ return false;
2298
2230
  }
2299
2231
  process() {
2300
- this.title = this.settings['title'];
2301
- this.class = this.settings['class'];
2302
- this.width = this.settings['width'];
2303
- this.hide = !!this.settings['hide'];
2304
- this.type = this.prepareType();
2305
- this.editor = this.settings['editor'];
2306
- this.filter = this.settings['filter'];
2307
- this.renderComponent = this.settings['renderComponent'];
2308
- this.isFilterable = typeof this.settings['filter'] === 'undefined' ? true : !!this.settings['filter'];
2309
- this.defaultSortDirection = ['asc', 'desc']
2310
- .indexOf(this.settings['sortDirection']) !== -1 ? this.settings['sortDirection'] : '';
2311
- this.isSortable = typeof this.settings['sort'] === 'undefined' ? true : !!this.settings['sort'];
2312
- this.isEditable = typeof this.settings['editable'] === 'undefined' ? true : !!this.settings['editable'];
2313
- this.isAddable = typeof this.settings['addable'] === 'undefined' ? true : !!this.settings['addable'];
2232
+ var _a, _b, _c;
2233
+ this.title = this.settings.title;
2234
+ this.class = this.settings.class || '';
2235
+ this.width = this.settings.width || '';
2236
+ this.hide = !!this.settings.hide;
2237
+ this.type = this.settings.type;
2238
+ if ((_a = this.settings) === null || _a === void 0 ? void 0 : _a.editor) {
2239
+ this.editor = this.settings.editor;
2240
+ }
2241
+ if ((_b = this.settings) === null || _b === void 0 ? void 0 : _b.filter) {
2242
+ this.filter = this.settings.filter;
2243
+ }
2244
+ if (this.settings.type === 'custom' && this.settings.renderComponent) {
2245
+ this.renderComponent = this.settings.renderComponent;
2246
+ }
2247
+ this.isFilterable = typeof this.settings.filter === 'undefined' ? true : !!this.settings['filter'];
2248
+ this.defaultSortDirection = ((_c = this.settings) === null || _c === void 0 ? void 0 : _c.sortDirection) || false;
2249
+ this.isSortable = typeof this.settings.sort === 'undefined' ? true : this.settings.sort;
2250
+ this.isEditable = typeof this.settings.editable === 'undefined' ? true : this.settings.editable;
2251
+ this.isAddable = typeof this.settings.addable === 'undefined' ? true : this.settings.addable;
2314
2252
  this.sortDirection = this.prepareSortDirection();
2315
- this.compareFunction = this.settings['compareFunction'];
2316
- this.valuePrepareFunction = this.settings['valuePrepareFunction'];
2317
- this.filterFunction = this.settings['filterFunction'];
2318
- this.onComponentInitFunction = this.settings['onComponentInitFunction'];
2319
- }
2320
- prepareType() {
2321
- return this.settings['type'] || this.determineType();
2253
+ this.compareFunction = this.settings.compareFunction;
2254
+ this.valuePrepareFunction = this.settings.valuePrepareFunction;
2255
+ this.filterFunction = this.settings.filterFunction;
2322
2256
  }
2323
2257
  prepareSortDirection() {
2324
- return this.settings['sort'] === 'desc' ? 'desc' : 'asc';
2325
- }
2326
- determineType() {
2327
- // TODO: determine type by data
2328
- return 'text';
2258
+ return this.defaultSortDirection === 'desc' ? 'desc' : 'asc';
2329
2259
  }
2330
2260
  }
2331
2261
 
@@ -2448,7 +2378,8 @@ class Grid {
2448
2378
  return position == this.getSetting('actions.position');
2449
2379
  }
2450
2380
  isActionsVisible() {
2451
- return this.getSetting('actions.add') || this.getSetting('actions.edit') || this.getSetting('actions.delete') || this.getSetting('actions.custom').length;
2381
+ var _a;
2382
+ return this.getSetting('actions.add', false) || this.getSetting('actions.edit', false) || this.getSetting('actions.delete', false) || !!((_a = this.getSetting('actions.custom', [])) === null || _a === void 0 ? void 0 : _a.length);
2452
2383
  }
2453
2384
  isMultiSelectVisible() {
2454
2385
  return this.getSetting('selectMode') === 'multi';
@@ -2472,7 +2403,9 @@ class Grid {
2472
2403
  this.sourceOnChangedSubscription = this.source.onChanged().subscribe((changes) => this.processDataChange(changes));
2473
2404
  this.sourceOnUpdatedSubscription = this.source.onUpdated().subscribe((data) => {
2474
2405
  const changedRow = this.dataSet.findRowByData(data);
2475
- changedRow.setData(data);
2406
+ if (changedRow) {
2407
+ changedRow.setData(data);
2408
+ }
2476
2409
  });
2477
2410
  }
2478
2411
  getSetting(name, defaultValue) {
@@ -2592,26 +2525,26 @@ class Grid {
2592
2525
  return false;
2593
2526
  }
2594
2527
  prepareSource(source) {
2595
- const initialSource = this.getInitialSort();
2596
- if (initialSource && initialSource['field'] && initialSource['direction']) {
2597
- source.setSort([initialSource], false);
2528
+ const initialSort = this.getInitialSort();
2529
+ if (initialSort) {
2530
+ source.setSort([initialSort], false);
2598
2531
  }
2599
2532
  if (this.getSetting('pager.display') === true) {
2600
- source.setPaging(this.getPageToSelect(source), this.getSetting('pager.perPage'), false);
2533
+ source.setPaging(1, this.getSetting('pager.perPage'), false);
2601
2534
  }
2602
2535
  source.refresh();
2603
2536
  return source;
2604
2537
  }
2605
2538
  getInitialSort() {
2606
- const sortConf = {};
2607
- this.getColumns().forEach((column) => {
2608
- if (column.isSortable && column.defaultSortDirection) {
2609
- sortConf['field'] = column.id;
2610
- sortConf['direction'] = column.defaultSortDirection;
2611
- sortConf['compare'] = column.getCompareFunction();
2612
- }
2613
- });
2614
- return sortConf;
2539
+ const defaultSortColumn = this.getColumns().find((column) => column.isSortable && column.defaultSortDirection);
2540
+ if (!defaultSortColumn) {
2541
+ return false;
2542
+ }
2543
+ return {
2544
+ field: defaultSortColumn.id,
2545
+ direction: defaultSortColumn.defaultSortDirection || 'asc',
2546
+ compare: defaultSortColumn.getCompareFunction(),
2547
+ };
2615
2548
  }
2616
2549
  getSelectedRowsData() {
2617
2550
  return this.dataSet.getRows();
@@ -2625,20 +2558,43 @@ class Grid {
2625
2558
  getLastRow() {
2626
2559
  return this.dataSet.getLastRow();
2627
2560
  }
2628
- getSelectionInfo() {
2629
- const switchPageToSelectedRowPage = this.getSetting('switchPageToSelectedRowPage');
2630
- const selectedRowIndex = Number(this.getSetting('selectedRowIndex', 0)) || 0;
2631
- const { perPage, page } = this.getSetting('pager');
2632
- return { perPage, page, selectedRowIndex, switchPageToSelectedRowPage };
2561
+ }
2562
+
2563
+ function compareValues(direction, a, b) {
2564
+ if (a < b) {
2565
+ return -1 * direction;
2566
+ }
2567
+ if (a > b) {
2568
+ return direction;
2633
2569
  }
2634
- getPageToSelect(source) {
2635
- const { switchPageToSelectedRowPage, selectedRowIndex, perPage, page } = this.getSelectionInfo();
2636
- let pageToSelect = Math.max(1, page);
2637
- if (switchPageToSelectedRowPage && selectedRowIndex >= 0) {
2638
- pageToSelect = getPageForRowIndex(selectedRowIndex, perPage);
2639
- }
2640
- const maxPageAmount = Math.ceil(source.count() / perPage);
2641
- return maxPageAmount ? Math.min(pageToSelect, maxPageAmount) : pageToSelect;
2570
+ return 0;
2571
+ }
2572
+ class LocalSorter {
2573
+ static sort(data, field, direction, customCompare) {
2574
+ const dir = (direction === 'asc') ? 1 : -1;
2575
+ const compare = customCompare ? customCompare : compareValues;
2576
+ return data.sort((a, b) => {
2577
+ return compare.call(null, dir, a[field], b[field]);
2578
+ });
2579
+ }
2580
+ }
2581
+
2582
+ function filterValues(value, search) {
2583
+ return value.toString().toLowerCase().includes(search.toString().toLowerCase());
2584
+ }
2585
+ class LocalFilter {
2586
+ static filter(data, field, search, customFilter) {
2587
+ const filter = customFilter ? customFilter : filterValues;
2588
+ return data.filter((el) => {
2589
+ const value = typeof el[field] === 'undefined' || el[field] === null ? '' : el[field];
2590
+ return filter.call(null, value, search);
2591
+ });
2592
+ }
2593
+ }
2594
+
2595
+ class LocalPager {
2596
+ static paginate(data, page, perPage) {
2597
+ return data.slice(perPage * (page - 1), perPage * page);
2642
2598
  }
2643
2599
  }
2644
2600
 
@@ -2668,7 +2624,7 @@ class DataSource {
2668
2624
  refresh() {
2669
2625
  this.emitOnChanged(SmartTableOnChangedEventName.refresh);
2670
2626
  }
2671
- load(data) {
2627
+ loadEmit() {
2672
2628
  this.emitOnChanged(SmartTableOnChangedEventName.load);
2673
2629
  return Promise.resolve(true);
2674
2630
  }
@@ -2684,59 +2640,49 @@ class DataSource {
2684
2640
  onRemoved() {
2685
2641
  return this.onRemovedSource.asObservable();
2686
2642
  }
2687
- prepend(element) {
2643
+ prependEmit(element) {
2688
2644
  this.emitOnAdded(element);
2689
2645
  this.emitOnChanged(SmartTableOnChangedEventName.prepend);
2690
2646
  return Promise.resolve(true);
2691
2647
  }
2692
- append(element) {
2648
+ appendEmit(element) {
2693
2649
  this.emitOnAdded(element);
2694
2650
  this.emitOnChanged(SmartTableOnChangedEventName.append);
2695
2651
  return Promise.resolve(true);
2696
2652
  }
2697
- add(element) {
2653
+ addEmit(element) {
2698
2654
  this.emitOnAdded(element);
2699
2655
  this.emitOnChanged(SmartTableOnChangedEventName.add);
2700
2656
  return Promise.resolve(true);
2701
2657
  }
2702
- remove(element) {
2658
+ removeEmit(element) {
2703
2659
  this.emitOnRemoved(element);
2704
2660
  this.emitOnChanged(SmartTableOnChangedEventName.remove);
2705
2661
  return Promise.resolve(true);
2706
2662
  }
2707
- update(element, values) {
2663
+ updateEmit(element) {
2708
2664
  this.emitOnUpdated(element);
2709
2665
  this.emitOnChanged(SmartTableOnChangedEventName.update);
2710
2666
  return Promise.resolve(true);
2711
2667
  }
2712
- empty() {
2668
+ emptyEmit() {
2713
2669
  this.emitOnChanged(SmartTableOnChangedEventName.empty);
2714
2670
  return Promise.resolve(true);
2715
2671
  }
2716
- setSort(conf, doEmit) {
2717
- if (doEmit) {
2718
- this.emitOnChanged(SmartTableOnChangedEventName.sort);
2719
- }
2672
+ setSortEmit() {
2673
+ this.emitOnChanged(SmartTableOnChangedEventName.sort);
2720
2674
  }
2721
- setFilter(conf, andOperator, doEmit) {
2722
- if (doEmit) {
2723
- this.emitOnChanged(SmartTableOnChangedEventName.filter);
2724
- }
2675
+ setFilterEmit() {
2676
+ this.emitOnChanged(SmartTableOnChangedEventName.filter);
2725
2677
  }
2726
- addFilter(fieldConf, andOperator, doEmit) {
2727
- if (doEmit) {
2728
- this.emitOnChanged(SmartTableOnChangedEventName.filter);
2729
- }
2678
+ addFilterEmit() {
2679
+ this.emitOnChanged(SmartTableOnChangedEventName.filter);
2730
2680
  }
2731
- setPaging(page, perPage, doEmit) {
2732
- if (doEmit) {
2733
- this.emitOnChanged(SmartTableOnChangedEventName.paging);
2734
- }
2681
+ setPagingEmit() {
2682
+ this.emitOnChanged(SmartTableOnChangedEventName.paging);
2735
2683
  }
2736
- setPage(page, doEmit) {
2737
- if (doEmit) {
2738
- this.emitOnChanged(SmartTableOnChangedEventName.page);
2739
- }
2684
+ setPageEmit() {
2685
+ this.emitOnChanged(SmartTableOnChangedEventName.page);
2740
2686
  }
2741
2687
  emitOnRemoved(element) {
2742
2688
  this.onRemovedSource.next(element);
@@ -2758,44 +2704,6 @@ class DataSource {
2758
2704
  }
2759
2705
  }
2760
2706
 
2761
- function compareValues(direction, a, b) {
2762
- if (a < b) {
2763
- return -1 * direction;
2764
- }
2765
- if (a > b) {
2766
- return direction;
2767
- }
2768
- return 0;
2769
- }
2770
- class LocalSorter {
2771
- static sort(data, field, direction, customCompare) {
2772
- const dir = (direction === 'asc') ? 1 : -1;
2773
- const compare = customCompare ? customCompare : compareValues;
2774
- return data.sort((a, b) => {
2775
- return compare.call(null, dir, a[field], b[field]);
2776
- });
2777
- }
2778
- }
2779
-
2780
- function filterValues(value, search) {
2781
- return value.toString().toLowerCase().includes(search.toString().toLowerCase());
2782
- }
2783
- class LocalFilter {
2784
- static filter(data, field, search, customFilter) {
2785
- const filter = customFilter ? customFilter : filterValues;
2786
- return data.filter((el) => {
2787
- const value = typeof el[field] === 'undefined' || el[field] === null ? '' : el[field];
2788
- return filter.call(null, value, search);
2789
- });
2790
- }
2791
- }
2792
-
2793
- class LocalPager {
2794
- static paginate(data, page, perPage) {
2795
- return data.slice(perPage * (page - 1), perPage * page);
2796
- }
2797
- }
2798
-
2799
2707
  class LocalDataSource extends DataSource {
2800
2708
  constructor(data = []) {
2801
2709
  super();
@@ -2806,39 +2714,41 @@ class LocalDataSource extends DataSource {
2806
2714
  filters: [],
2807
2715
  andOperator: true,
2808
2716
  };
2809
- this.pagingConf = {
2810
- page: 1,
2811
- perPage: 1,
2812
- };
2717
+ this.pagingConf = false;
2813
2718
  this.data = data;
2814
2719
  }
2815
2720
  load(data) {
2816
2721
  this.data = data;
2817
- return super.load(data);
2722
+ return super.loadEmit();
2818
2723
  }
2819
2724
  prepend(element) {
2820
2725
  this.reset(true);
2821
2726
  this.data.unshift(element);
2822
- return super.prepend(element);
2727
+ return super.prependEmit(element);
2728
+ }
2729
+ appendMany(elements) {
2730
+ this.reset(true);
2731
+ this.data = [...this.data, ...elements];
2732
+ return super.loadEmit();
2823
2733
  }
2824
2734
  append(element) {
2825
2735
  this.reset(true);
2826
2736
  this.data.push(element);
2827
- return super.append(element);
2737
+ return super.appendEmit(element);
2828
2738
  }
2829
2739
  add(element) {
2830
2740
  this.data.push(element);
2831
- return super.add(element);
2741
+ return super.addEmit(element);
2832
2742
  }
2833
2743
  remove(element) {
2834
2744
  this.data = this.data.filter(el => el !== element);
2835
- return super.remove(element);
2745
+ return super.removeEmit(element);
2836
2746
  }
2837
2747
  update(element, values) {
2838
2748
  return new Promise((resolve, reject) => {
2839
2749
  this.find(element).then((found) => {
2840
2750
  found = deepExtend(found, values);
2841
- super.update(found, values).then(resolve).catch(reject);
2751
+ super.updateEmit(found).then(resolve).catch(reject);
2842
2752
  }).catch(reject);
2843
2753
  });
2844
2754
  }
@@ -2869,17 +2779,21 @@ class LocalDataSource extends DataSource {
2869
2779
  andOperator: true,
2870
2780
  };
2871
2781
  this.sortConf = [];
2872
- this.pagingConf.page = 1;
2782
+ if (this.pagingConf) {
2783
+ this.pagingConf.page = 1;
2784
+ }
2873
2785
  }
2874
2786
  else {
2875
2787
  this.setFilter([], true, false);
2876
2788
  this.setSort([], false);
2877
- this.setPage(1);
2789
+ if (this.pagingConf) {
2790
+ this.setPage(1);
2791
+ }
2878
2792
  }
2879
2793
  }
2880
2794
  empty() {
2881
2795
  this.data = [];
2882
- return super.empty();
2796
+ return super.emptyEmit();
2883
2797
  }
2884
2798
  count() {
2885
2799
  return this.filteredAndSorted.length;
@@ -2903,7 +2817,9 @@ class LocalDataSource extends DataSource {
2903
2817
  });
2904
2818
  this.sortConf = conf;
2905
2819
  }
2906
- super.setSort(conf, doEmit);
2820
+ if (doEmit) {
2821
+ super.setSortEmit();
2822
+ }
2907
2823
  return this;
2908
2824
  }
2909
2825
  /**
@@ -2930,8 +2846,12 @@ class LocalDataSource extends DataSource {
2930
2846
  };
2931
2847
  }
2932
2848
  this.filterConf.andOperator = andOperator;
2933
- this.pagingConf.page = 1;
2934
- super.setFilter(conf, andOperator, doEmit);
2849
+ if (this.pagingConf) {
2850
+ this.pagingConf.page = 1;
2851
+ }
2852
+ if (doEmit) {
2853
+ super.setFilterEmit();
2854
+ }
2935
2855
  return this;
2936
2856
  }
2937
2857
  addFilter(fieldConf, andOperator = true, doEmit = true) {
@@ -2949,19 +2869,35 @@ class LocalDataSource extends DataSource {
2949
2869
  this.filterConf.filters.push(fieldConf);
2950
2870
  }
2951
2871
  this.filterConf.andOperator = andOperator;
2952
- super.addFilter(fieldConf, andOperator, doEmit);
2872
+ if (doEmit) {
2873
+ super.addFilterEmit();
2874
+ }
2953
2875
  return this;
2954
2876
  }
2955
- setPaging(page, perPage, doEmit = true) {
2956
- this.pagingConf.page = page;
2957
- this.pagingConf.perPage = perPage;
2958
- super.setPaging(page, perPage, doEmit);
2959
- return this;
2877
+ setPaging(page = 1, perPage, doEmit = true) {
2878
+ if (this.pagingConf) {
2879
+ this.pagingConf.page = page;
2880
+ this.pagingConf.perPage = perPage;
2881
+ }
2882
+ else {
2883
+ this.pagingConf = {
2884
+ page, perPage
2885
+ };
2886
+ }
2887
+ if (doEmit) {
2888
+ super.setPagingEmit();
2889
+ }
2890
+ return;
2960
2891
  }
2961
2892
  setPage(page, doEmit = true) {
2893
+ if (!this.pagingConf) {
2894
+ return;
2895
+ }
2962
2896
  this.pagingConf.page = page;
2963
- super.setPage(page, doEmit);
2964
- return this;
2897
+ if (doEmit) {
2898
+ super.setPageEmit();
2899
+ }
2900
+ return;
2965
2901
  }
2966
2902
  getSort() {
2967
2903
  return this.sortConf;
@@ -2976,7 +2912,11 @@ class LocalDataSource extends DataSource {
2976
2912
  data = this.filter(data);
2977
2913
  data = this.sort(data);
2978
2914
  this.filteredAndSorted = data.slice(0);
2979
- return this.paginate(data);
2915
+ if (this.pagingConf) {
2916
+ return this.paginate(data);
2917
+ }
2918
+ else
2919
+ return data;
2980
2920
  }
2981
2921
  sort(data) {
2982
2922
  if (this.sortConf) {
@@ -3028,6 +2968,7 @@ class Ng2SmartTableComponent {
3028
2968
  constructor() {
3029
2969
  this.multiRowSelect = new EventEmitter();
3030
2970
  this.rowClicked = new EventEmitter();
2971
+ this.listScrollEnd = new EventEmitter();
3031
2972
  this.delete = new EventEmitter();
3032
2973
  this.edit = new EventEmitter();
3033
2974
  this.editCancel = new EventEmitter();
@@ -3037,16 +2978,20 @@ class Ng2SmartTableComponent {
3037
2978
  this.editConfirm = new EventEmitter();
3038
2979
  this.createConfirm = new EventEmitter();
3039
2980
  this.rowHover = new EventEmitter();
2981
+ this.tableClass = '';
2982
+ this.tableId = '';
2983
+ this.perPageSelect = [];
2984
+ this.isHideHeader = false;
2985
+ this.isHideSubHeader = false;
2986
+ this.isPagerDisplay = false;
2987
+ this.rowClassFunction = () => '';
2988
+ this.currentScrollTop = 0;
3040
2989
  this.defaultSettings = {
3041
2990
  mode: 'inline',
3042
2991
  selectMode: 'single',
3043
- /**
3044
- * Points to an element in all data
3045
- *
3046
- * when < 0 all lines must be deselected
3047
- */
3048
- selectedRowIndex: 0,
2992
+ selectedRowIndex: -1,
3049
2993
  switchPageToSelectedRowPage: false,
2994
+ bodyHeight: '85vh',
3050
2995
  hideHeader: false,
3051
2996
  hideSubHeader: false,
3052
2997
  actions: {
@@ -3084,11 +3029,7 @@ class Ng2SmartTableComponent {
3084
3029
  },
3085
3030
  noDataMessage: 'No data found',
3086
3031
  columns: {},
3087
- pager: {
3088
- display: true,
3089
- page: 1,
3090
- perPage: 10,
3091
- },
3032
+ pager: false,
3092
3033
  rowClassFunction: () => '',
3093
3034
  };
3094
3035
  }
@@ -3109,10 +3050,9 @@ class Ng2SmartTableComponent {
3109
3050
  this.tableClass = this.grid.getSetting('attr.class');
3110
3051
  this.isHideHeader = this.grid.getSetting('hideHeader');
3111
3052
  this.isHideSubHeader = this.grid.getSetting('hideSubHeader');
3112
- this.isPagerDisplay = this.grid.getSetting('pager.display');
3113
- this.isPagerDisplay = this.grid.getSetting('pager.display');
3053
+ this.isPagerDisplay = this.grid.getSetting('pager.display', false);
3114
3054
  this.perPageSelect = this.grid.getSetting('pager.perPageSelect');
3115
- this.rowClassFunction = this.grid.getSetting('rowClassFunction');
3055
+ this.rowClassFunction = this.grid.getSetting('rowClassFunction', () => '');
3116
3056
  }
3117
3057
  multipleSelectRow(row) {
3118
3058
  this.grid.multipleSelectRow(row);
@@ -3126,12 +3066,26 @@ class Ng2SmartTableComponent {
3126
3066
  onSelectRow(row, state) {
3127
3067
  this.grid.selectRow(row, state);
3128
3068
  }
3069
+ emitUserRowClicked(row) {
3070
+ this.rowClicked.emit({
3071
+ data: row ? row.getData() : null,
3072
+ source: this.source,
3073
+ });
3074
+ }
3075
+ onScroll(event) {
3076
+ const { scrollHeight, scrollTop, clientHeight } = event.target;
3077
+ const isListEnd = (clientHeight + Math.round(scrollTop)) >= scrollHeight;
3078
+ if (isListEnd && this.currentScrollTop < scrollTop) {
3079
+ this.listScrollEnd.emit(true);
3080
+ }
3081
+ this.currentScrollTop = scrollTop;
3082
+ }
3129
3083
  initGrid() {
3130
3084
  this.source = this.prepareSource();
3131
3085
  this.grid = new Grid(this.source, this.prepareSettings());
3132
3086
  }
3133
3087
  prepareSource() {
3134
- if (this.source instanceof DataSource) {
3088
+ if (this.source instanceof LocalDataSource) {
3135
3089
  return this.source;
3136
3090
  }
3137
3091
  return new LocalDataSource();
@@ -3142,23 +3096,17 @@ class Ng2SmartTableComponent {
3142
3096
  emitUserSelectRow(row) {
3143
3097
  this.multiRowSelect.emit({
3144
3098
  data: row ? row.getData() : null,
3145
- isSelected: row ? row.getIsSelected() : null,
3099
+ isSelected: row ? row.getIsSelected() : false,
3146
3100
  source: this.source,
3147
3101
  selected: this.grid.dataSet.getSelectedRowsData(),
3148
3102
  });
3149
3103
  }
3150
- emitUserRowClicked(row) {
3151
- this.rowClicked.emit({
3152
- data: row ? row.getData() : null,
3153
- source: this.source,
3154
- });
3155
- }
3156
3104
  }
3157
3105
  Ng2SmartTableComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: Ng2SmartTableComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
3158
- Ng2SmartTableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: Ng2SmartTableComponent, selector: "ng2-smart-table", inputs: { source: "source", settings: "settings" }, outputs: { multiRowSelect: "multiRowSelect", rowClicked: "rowClicked", delete: "delete", edit: "edit", editCancel: "editCancel", create: "create", custom: "custom", deleteConfirm: "deleteConfirm", editConfirm: "editConfirm", createConfirm: "createConfirm", rowHover: "rowHover" }, usesOnChanges: true, ngImport: i0, template: "<table [id]=\"tableId\" [ngClass]=\"tableClass\">\n\n <thead ng2-st-thead *ngIf=\"!isHideHeader || !isHideSubHeader\"\n [grid]=\"grid\"\n [source]=\"source\"\n [createConfirm]=\"createConfirm\"\n (create)=\"create.emit($event)\"\n (selectAllRows)=\"onSelectAllRows()\">\n </thead>\n\n <tbody ng2-st-tbody [grid]=\"grid\"\n [source]=\"source\"\n [deleteConfirm]=\"deleteConfirm\"\n [editConfirm]=\"editConfirm\"\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\n</table>\n\n<ng2-smart-table-pager *ngIf=\"isPagerDisplay\"\n [source]=\"source\"\n [perPageSelect]=\"perPageSelect\">\n</ng2-smart-table-pager>\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%;overflow:auto;word-break:normal;word-break:keep-all}: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: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: PagerComponent, selector: "ng2-smart-table-pager", inputs: ["source", "perPageSelect"], outputs: ["changePage"] }, { kind: "component", type: Ng2SmartTableTbodyComponent, selector: "[ng2-st-tbody]", inputs: ["grid", "source", "deleteConfirm", "editConfirm", "rowClassFunction"], outputs: ["save", "cancel", "edit", "editCancel", "delete", "custom", "edited", "userSelectRow", "userClickedRow", "editRowSelect", "multipleSelectRow"] }, { kind: "component", type: Ng2SmartTableTheadComponent, selector: "[ng2-st-thead]", inputs: ["grid", "source", "createConfirm"], outputs: ["sort", "selectAllRows", "create", "filter"] }] });
3106
+ Ng2SmartTableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: Ng2SmartTableComponent, selector: "ng2-smart-table", inputs: { source: "source", settings: "settings" }, outputs: { multiRowSelect: "multiRowSelect", rowClicked: "rowClicked", listScrollEnd: "listScrollEnd", delete: "delete", edit: "edit", editCancel: "editCancel", create: "create", custom: "custom", deleteConfirm: "deleteConfirm", editConfirm: "editConfirm", createConfirm: "createConfirm", rowHover: "rowHover" }, usesOnChanges: true, ngImport: i0, template: "<table [id]=\"tableId\" [ngClass]=\"tableClass\">\n\n <thead ng2-st-thead *ngIf=\"!isHideHeader || !isHideSubHeader\"\n [grid]=\"grid\"\n [source]=\"source\"\n [createConfirm]=\"createConfirm\"\n (create)=\"create.emit($event)\"\n (selectAllRows)=\"onSelectAllRows()\">\n </thead>\n\n <tbody ng2-st-tbody [ngStyle]=\"{'max-height': this.grid.getSetting('bodyHeight', '85vh')}\"\n [grid]=\"grid\"\n [source]=\"source\"\n [deleteConfirm]=\"deleteConfirm\"\n [editConfirm]=\"editConfirm\"\n [rowClassFunction]=\"rowClassFunction\"\n (edit)=\"edit.emit($event)\"\n (editCancel)=\"editCancel.emit($event)\"\n (delete)=\"delete.emit($event)\"\n (custom)=\"custom.emit($event)\"\n (scroll)=\"onScroll($any($event))\"\n (userClickedRow)=\"emitUserRowClicked($event)\"\n (multipleSelectRow)=\"multipleSelectRow($event)\">\n </tbody>\n\n</table>\n\n<ng2-smart-table-pager *ngIf=\"isPagerDisplay\"\n [source]=\"source\"\n [perPageSelect]=\"perPageSelect\">\n</ng2-smart-table-pager>\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}:host ::ng-deep table tbody{display:block;max-height:85vh;overflow-y:scroll}:host ::ng-deep table tr{display:table;width:100%;table-layout:fixed}: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: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "component", type: PagerComponent, selector: "ng2-smart-table-pager", inputs: ["source", "perPageSelect"], outputs: ["changePage"] }, { kind: "component", type: Ng2SmartTableTbodyComponent, selector: "[ng2-st-tbody]", inputs: ["grid", "source", "deleteConfirm", "editConfirm", "rowClassFunction"], outputs: ["save", "cancel", "edit", "editCancel", "delete", "custom", "edited", "userSelectRow", "userClickedRow", "editRowSelect", "multipleSelectRow"] }, { kind: "component", type: Ng2SmartTableTheadComponent, selector: "[ng2-st-thead]", inputs: ["grid", "source", "createConfirm"], outputs: ["sort", "selectAllRows", "create", "filter"] }] });
3159
3107
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: Ng2SmartTableComponent, decorators: [{
3160
3108
  type: Component,
3161
- args: [{ selector: 'ng2-smart-table', template: "<table [id]=\"tableId\" [ngClass]=\"tableClass\">\n\n <thead ng2-st-thead *ngIf=\"!isHideHeader || !isHideSubHeader\"\n [grid]=\"grid\"\n [source]=\"source\"\n [createConfirm]=\"createConfirm\"\n (create)=\"create.emit($event)\"\n (selectAllRows)=\"onSelectAllRows()\">\n </thead>\n\n <tbody ng2-st-tbody [grid]=\"grid\"\n [source]=\"source\"\n [deleteConfirm]=\"deleteConfirm\"\n [editConfirm]=\"editConfirm\"\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\n</table>\n\n<ng2-smart-table-pager *ngIf=\"isPagerDisplay\"\n [source]=\"source\"\n [perPageSelect]=\"perPageSelect\">\n</ng2-smart-table-pager>\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%;overflow:auto;word-break:normal;word-break:keep-all}: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"] }]
3109
+ args: [{ selector: 'ng2-smart-table', template: "<table [id]=\"tableId\" [ngClass]=\"tableClass\">\n\n <thead ng2-st-thead *ngIf=\"!isHideHeader || !isHideSubHeader\"\n [grid]=\"grid\"\n [source]=\"source\"\n [createConfirm]=\"createConfirm\"\n (create)=\"create.emit($event)\"\n (selectAllRows)=\"onSelectAllRows()\">\n </thead>\n\n <tbody ng2-st-tbody [ngStyle]=\"{'max-height': this.grid.getSetting('bodyHeight', '85vh')}\"\n [grid]=\"grid\"\n [source]=\"source\"\n [deleteConfirm]=\"deleteConfirm\"\n [editConfirm]=\"editConfirm\"\n [rowClassFunction]=\"rowClassFunction\"\n (edit)=\"edit.emit($event)\"\n (editCancel)=\"editCancel.emit($event)\"\n (delete)=\"delete.emit($event)\"\n (custom)=\"custom.emit($event)\"\n (scroll)=\"onScroll($any($event))\"\n (userClickedRow)=\"emitUserRowClicked($event)\"\n (multipleSelectRow)=\"multipleSelectRow($event)\">\n </tbody>\n\n</table>\n\n<ng2-smart-table-pager *ngIf=\"isPagerDisplay\"\n [source]=\"source\"\n [perPageSelect]=\"perPageSelect\">\n</ng2-smart-table-pager>\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}:host ::ng-deep table tbody{display:block;max-height:85vh;overflow-y:scroll}:host ::ng-deep table tr{display:table;width:100%;table-layout:fixed}: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"] }]
3162
3110
  }], propDecorators: { source: [{
3163
3111
  type: Input
3164
3112
  }], settings: [{
@@ -3167,6 +3115,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
3167
3115
  type: Output
3168
3116
  }], rowClicked: [{
3169
3117
  type: Output
3118
+ }], listScrollEnd: [{
3119
+ type: Output
3170
3120
  }], delete: [{
3171
3121
  type: Output
3172
3122
  }], edit: [{
@@ -3228,117 +3178,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
3228
3178
  }]
3229
3179
  }] });
3230
3180
 
3231
- class ServerSourceConf {
3232
- constructor({ endPoint = '', sortFieldKey = '', sortDirKey = '', pagerPageKey = '', pagerLimitKey = '', filterFieldKey = '', totalKey = '', dataKey = '' } = {}) {
3233
- this.endPoint = endPoint ? endPoint : '';
3234
- this.sortFieldKey = sortFieldKey ? sortFieldKey : ServerSourceConf.SORT_FIELD_KEY;
3235
- this.sortDirKey = sortDirKey ? sortDirKey : ServerSourceConf.SORT_DIR_KEY;
3236
- this.pagerPageKey = pagerPageKey ? pagerPageKey : ServerSourceConf.PAGER_PAGE_KEY;
3237
- this.pagerLimitKey = pagerLimitKey ? pagerLimitKey : ServerSourceConf.PAGER_LIMIT_KEY;
3238
- this.filterFieldKey = filterFieldKey ? filterFieldKey : ServerSourceConf.FILTER_FIELD_KEY;
3239
- this.totalKey = totalKey ? totalKey : ServerSourceConf.TOTAL_KEY;
3240
- this.dataKey = dataKey ? dataKey : ServerSourceConf.DATA_KEY;
3241
- }
3242
- }
3243
- ServerSourceConf.SORT_FIELD_KEY = '_sort';
3244
- ServerSourceConf.SORT_DIR_KEY = '_order';
3245
- ServerSourceConf.PAGER_PAGE_KEY = '_page';
3246
- ServerSourceConf.PAGER_LIMIT_KEY = '_limit';
3247
- ServerSourceConf.FILTER_FIELD_KEY = '#field#_like';
3248
- ServerSourceConf.TOTAL_KEY = 'x-total-count';
3249
- ServerSourceConf.DATA_KEY = '';
3250
-
3251
- class ServerDataSource extends LocalDataSource {
3252
- constructor(http, conf = {}) {
3253
- super();
3254
- this.http = http;
3255
- this.lastRequestCount = 0;
3256
- this.conf = new ServerSourceConf(conf);
3257
- if (!this.conf.endPoint) {
3258
- throw new Error('At least endPoint must be specified as a configuration of the server data source.');
3259
- }
3260
- }
3261
- count() {
3262
- return this.lastRequestCount;
3263
- }
3264
- getElements() {
3265
- return this.requestElements()
3266
- .pipe(map(res => {
3267
- this.lastRequestCount = this.extractTotalFromResponse(res);
3268
- this.data = this.extractDataFromResponse(res);
3269
- return this.data;
3270
- })).toPromise();
3271
- }
3272
- /**
3273
- * Extracts array of data from server response
3274
- * @param res
3275
- * @returns {any}
3276
- */
3277
- extractDataFromResponse(res) {
3278
- const rawData = res.body;
3279
- const data = !!this.conf.dataKey ? getDeepFromObject(rawData, this.conf.dataKey, []) : rawData;
3280
- if (data instanceof Array) {
3281
- return data;
3282
- }
3283
- throw new Error(`Data must be an array.
3284
- Please check that data extracted from the server response by the key '${this.conf.dataKey}' exists and is array.`);
3285
- }
3286
- /**
3287
- * Extracts total rows count from the server response
3288
- * Looks for the count in the heders first, then in the response body
3289
- * @param res
3290
- * @returns {any}
3291
- */
3292
- extractTotalFromResponse(res) {
3293
- if (res.headers.has(this.conf.totalKey)) {
3294
- return +res.headers.get(this.conf.totalKey);
3295
- }
3296
- else {
3297
- const rawData = res.body;
3298
- return getDeepFromObject(rawData, this.conf.totalKey, 0);
3299
- }
3300
- }
3301
- requestElements() {
3302
- let httpParams = this.createRequesParams();
3303
- return this.http.get(this.conf.endPoint, { params: httpParams, observe: 'response' });
3304
- }
3305
- createRequesParams() {
3306
- let httpParams = new HttpParams();
3307
- httpParams = this.addSortRequestParams(httpParams);
3308
- httpParams = this.addFilterRequestParams(httpParams);
3309
- return this.addPagerRequestParams(httpParams);
3310
- }
3311
- addSortRequestParams(httpParams) {
3312
- if (this.sortConf) {
3313
- this.sortConf.forEach((fieldConf) => {
3314
- httpParams = httpParams.set(this.conf.sortFieldKey, fieldConf.field);
3315
- httpParams = httpParams.set(this.conf.sortDirKey, fieldConf.direction.toUpperCase());
3316
- });
3317
- }
3318
- return httpParams;
3319
- }
3320
- addFilterRequestParams(httpParams) {
3321
- if (this.filterConf.filters) {
3322
- this.filterConf.filters.forEach((fieldConf) => {
3323
- if (fieldConf['search']) {
3324
- httpParams = httpParams.set(this.conf.filterFieldKey.replace('#field#', fieldConf['field']), fieldConf['search']);
3325
- }
3326
- });
3327
- }
3328
- return httpParams;
3329
- }
3330
- addPagerRequestParams(httpParams) {
3331
- if (this.pagingConf && this.pagingConf['page'] && this.pagingConf['perPage']) {
3332
- httpParams = httpParams.set(this.conf.pagerPageKey, this.pagingConf['page']);
3333
- httpParams = httpParams.set(this.conf.pagerLimitKey, this.pagingConf['perPage']);
3334
- }
3335
- return httpParams;
3336
- }
3337
- }
3338
-
3339
3181
  /**
3340
3182
  * Generated bundle index. Do not edit.
3341
3183
  */
3342
3184
 
3343
- export { Cell, DefaultEditor, DefaultFilter, LocalDataSource, Ng2SmartTableComponent, Ng2SmartTableModule, ServerDataSource };
3185
+ export { Cell, DefaultEditor, DefaultFilter, LocalDataSource, Ng2SmartTableComponent, Ng2SmartTableModule };
3344
3186
  //# sourceMappingURL=den4ik92-ng2-smart-table.mjs.map