@marcura/marcura-grid 6.1.2 → 19.0.0-dev.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/README.md +24 -24
  2. package/fesm2022/marcura-marcura-grid.mjs +541 -0
  3. package/fesm2022/marcura-marcura-grid.mjs.map +1 -0
  4. package/lib/components/cell/cell.component.d.ts +1 -1
  5. package/lib/components/column-cell/column-cell.component.d.ts +1 -1
  6. package/lib/components/columns-form/columns-form.component.d.ts +1 -1
  7. package/lib/components/continuous-grid/continuous-grid.component.d.ts +1 -1
  8. package/lib/components/grid/grid.component.d.ts +1 -1
  9. package/lib/components/load-more/load-more.component.d.ts +1 -1
  10. package/lib/components/paginated-grid/paginated-grid.component.d.ts +1 -1
  11. package/package.json +15 -23
  12. package/esm2020/lib/components/cell/cell.component.mjs +0 -19
  13. package/esm2020/lib/components/column-cell/column-cell.component.mjs +0 -53
  14. package/esm2020/lib/components/columns-form/columns-form.component.mjs +0 -63
  15. package/esm2020/lib/components/continuous-grid/continuous-grid.component.mjs +0 -35
  16. package/esm2020/lib/components/grid/grid.component.mjs +0 -51
  17. package/esm2020/lib/components/load-more/load-more.component.mjs +0 -30
  18. package/esm2020/lib/components/paginated-grid/paginated-grid.component.mjs +0 -24
  19. package/esm2020/lib/grid.module.mjs +0 -52
  20. package/esm2020/lib/model/cell-vertical-alignment.enum.mjs +0 -7
  21. package/esm2020/lib/model/column.mjs +0 -64
  22. package/esm2020/lib/model/continuous-grid.mjs +0 -35
  23. package/esm2020/lib/model/grid.mjs +0 -87
  24. package/esm2020/lib/model/paginated-grid.mjs +0 -33
  25. package/esm2020/lib/model/selection.mjs +0 -23
  26. package/esm2020/lib/model/sort-direction.enum.mjs +0 -6
  27. package/esm2020/marcura-marcura-grid.mjs +0 -5
  28. package/esm2020/public-api.mjs +0 -16
  29. package/fesm2015/marcura-marcura-grid.mjs +0 -542
  30. package/fesm2015/marcura-marcura-grid.mjs.map +0 -1
  31. package/fesm2020/marcura-marcura-grid.mjs +0 -540
  32. package/fesm2020/marcura-marcura-grid.mjs.map +0 -1
package/README.md CHANGED
@@ -1,24 +1,24 @@
1
- # Marcura Grid
2
-
3
- This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 7.2.0.
4
-
5
- ## Code scaffolding
6
-
7
- Run `ng generate component component-name --project marcura-common` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project marcura-common`.
8
- > Note: Don't forget to add `--project marcura-common` or else it will be added to the default project in your `angular.json` file.
9
-
10
- ## Build
11
-
12
- Run `ng build marcura-common` to build the project. The build artifacts will be stored in the `dist/` directory.
13
-
14
- ## Publishing
15
-
16
- After building your library with `ng build marcura-common`, go to the dist folder `cd dist/marcura-common` and run `npm publish`.
17
-
18
- ## Running unit tests
19
-
20
- Run `ng test marcura-common` to execute the unit tests via [Karma](https://karma-runner.github.io).
21
-
22
- ## Further help
23
-
24
- To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
1
+ # Marcura Grid
2
+
3
+ This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 7.2.0.
4
+
5
+ ## Code scaffolding
6
+
7
+ Run `ng generate component component-name --project marcura-common` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project marcura-common`.
8
+ > Note: Don't forget to add `--project marcura-common` or else it will be added to the default project in your `angular.json` file.
9
+
10
+ ## Build
11
+
12
+ Run `ng build marcura-common` to build the project. The build artifacts will be stored in the `dist/` directory.
13
+
14
+ ## Publishing
15
+
16
+ After building your library with `ng build marcura-common`, go to the dist folder `cd dist/marcura-common` and run `npm publish`.
17
+
18
+ ## Running unit tests
19
+
20
+ Run `ng test marcura-common` to execute the unit tests via [Karma](https://karma-runner.github.io).
21
+
22
+ ## Further help
23
+
24
+ To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
@@ -0,0 +1,541 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Input, Component, EventEmitter, Output, HostBinding, ChangeDetectionStrategy, NgModule } from '@angular/core';
3
+ import * as i2 from '@angular/forms';
4
+ import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
5
+ import { getValue, Assert, AtLeastOneSelectedFormGuard, Observer, Worker, Is } from '@marcura/marcura-common';
6
+ import { Subject, BehaviorSubject, combineLatest } from 'rxjs';
7
+ import * as i1 from '@angular/common';
8
+ import { CommonModule } from '@angular/common';
9
+ import * as i3 from '@marcura/marcura-checkbox';
10
+ import { CheckboxModule } from '@marcura/marcura-checkbox';
11
+ import * as i4 from '@marcura/marcura-field';
12
+ import { FieldModule } from '@marcura/marcura-field';
13
+ import { skip, map } from 'rxjs/operators';
14
+ import * as i2$2 from '@progress/kendo-angular-grid';
15
+ import { GridModule as GridModule$1 } from '@progress/kendo-angular-grid';
16
+ import * as i2$1 from '@progress/kendo-angular-buttons';
17
+ import { ButtonModule } from '@progress/kendo-angular-buttons';
18
+
19
+ var SortDirection;
20
+ (function (SortDirection) {
21
+ SortDirection["Asc"] = "asc";
22
+ SortDirection["Desc"] = "desc";
23
+ })(SortDirection || (SortDirection = {}));
24
+
25
+ class Column {
26
+ get isLocked() {
27
+ return this._isLocked;
28
+ }
29
+ get isSortable() {
30
+ return this._isSortable;
31
+ }
32
+ get isHidden() {
33
+ return this._isHidden;
34
+ }
35
+ constructor(width, cellType, minWidth = 50) {
36
+ this.cellType = cellType;
37
+ this.action = new Subject();
38
+ this._isHidden = new BehaviorSubject(false);
39
+ this.isVisibleControl = new FormControl(true, { nonNullable: true });
40
+ this.isDefaultSortColumn = false;
41
+ this.defaultSortDirection = SortDirection.Asc;
42
+ this.title = '';
43
+ this.field = '';
44
+ this.isVisibilityFormControlVisible = true;
45
+ this.width = new BehaviorSubject(Math.max(width, minWidth));
46
+ this.minWidth = new BehaviorSubject(minWidth);
47
+ this._isLocked = new BehaviorSubject(false);
48
+ this._isSortable = new BehaviorSubject(false);
49
+ this.isVisibleControl.valueChanges.subscribe((isVisible) => this._isHidden.next(!isVisible));
50
+ }
51
+ forField(field) {
52
+ this.field = field;
53
+ return this;
54
+ }
55
+ withTitle(title) {
56
+ this.title = title;
57
+ return this;
58
+ }
59
+ locked() {
60
+ this._isLocked.next(true);
61
+ return this;
62
+ }
63
+ sortable() {
64
+ this._isSortable.next(true);
65
+ return this;
66
+ }
67
+ hidden() {
68
+ this.isVisibleControl.setValue(false);
69
+ return this;
70
+ }
71
+ defaultSortColumn(direction = SortDirection.Asc) {
72
+ this.isDefaultSortColumn = true;
73
+ this.defaultSortDirection = direction;
74
+ return this;
75
+ }
76
+ hiddenVisibilityFormControl() {
77
+ this.isVisibilityFormControlVisible = false;
78
+ return this;
79
+ }
80
+ getValue(data) {
81
+ return this.field ? getValue(data, this.field) : null;
82
+ }
83
+ }
84
+
85
+ class CellComponent {
86
+ get value() {
87
+ return this.row && this.column && this.column.getValue(this.row);
88
+ }
89
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: CellComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
90
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.4", type: CellComponent, isStandalone: false, selector: "sg-grid-cell", inputs: { row: "row", column: "column" }, ngImport: i0, template: "<span class=\"c-body c-body--1 u-font-weight--inherit\">{{ value }}</span>\r\n" }); }
91
+ }
92
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: CellComponent, decorators: [{
93
+ type: Component,
94
+ args: [{ selector: 'sg-grid-cell', standalone: false, template: "<span class=\"c-body c-body--1 u-font-weight--inherit\">{{ value }}</span>\r\n" }]
95
+ }], propDecorators: { row: [{
96
+ type: Input
97
+ }], column: [{
98
+ type: Input
99
+ }] } });
100
+
101
+ class ColumnCellComponent {
102
+ get column() {
103
+ return Assert.defined(this._column);
104
+ }
105
+ set column(value) {
106
+ this._column = value;
107
+ if (this._componentReference) {
108
+ this._componentReference.destroy();
109
+ }
110
+ const factory = this._factoryResolver.resolveComponentFactory(this._column.cellType);
111
+ this._componentReference = this._viewContainerReference.createComponent(factory);
112
+ this._updateComponentValue();
113
+ }
114
+ get row() {
115
+ return Assert.defined(this._row);
116
+ }
117
+ set row(value) {
118
+ this._row = value;
119
+ this._updateComponentValue();
120
+ }
121
+ constructor(_viewContainerReference, _factoryResolver) {
122
+ this._viewContainerReference = _viewContainerReference;
123
+ this._factoryResolver = _factoryResolver;
124
+ this._componentReference = null;
125
+ this._column = null;
126
+ this._row = null;
127
+ }
128
+ _updateComponentValue() {
129
+ if (this._componentReference && this._row) {
130
+ const component = this._componentReference.instance;
131
+ component.column = this.column;
132
+ component.row = this.row;
133
+ }
134
+ }
135
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: ColumnCellComponent, deps: [{ token: i0.ViewContainerRef }, { token: i0.ComponentFactoryResolver }], target: i0.ɵɵFactoryTarget.Component }); }
136
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.4", type: ColumnCellComponent, isStandalone: false, selector: "sg-grid-column-cell", inputs: { column: "column", row: "row" }, ngImport: i0, template: '', isInline: true }); }
137
+ }
138
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: ColumnCellComponent, decorators: [{
139
+ type: Component,
140
+ args: [{
141
+ selector: 'sg-grid-column-cell',
142
+ template: '',
143
+ standalone: false,
144
+ }]
145
+ }], ctorParameters: () => [{ type: i0.ViewContainerRef }, { type: i0.ComponentFactoryResolver }], propDecorators: { column: [{
146
+ type: Input
147
+ }], row: [{
148
+ type: Input
149
+ }] } });
150
+
151
+ class ColumnsFormComponent {
152
+ constructor() {
153
+ this._atLeastOneSelectedFormGuard = null;
154
+ this._list = [];
155
+ this.columns = [];
156
+ this.prefix = '';
157
+ }
158
+ static { this.MAX_ROWS = 5; }
159
+ get list() {
160
+ return this._list;
161
+ }
162
+ set list(value) {
163
+ this._list = value || [];
164
+ this._list = this._list.filter((column) => {
165
+ return column.isVisibilityFormControlVisible;
166
+ });
167
+ this.updateFormGroup();
168
+ this.updateColumns();
169
+ if (this._atLeastOneSelectedFormGuard) {
170
+ this._atLeastOneSelectedFormGuard.destroy();
171
+ }
172
+ const controls = this._list.map((column) => column.isVisibleControl);
173
+ this._atLeastOneSelectedFormGuard = new AtLeastOneSelectedFormGuard(controls);
174
+ }
175
+ updateFormGroup() {
176
+ const controls = {};
177
+ this.list.forEach((column) => (controls[column.field] = column.isVisibleControl));
178
+ this.form = new FormGroup(controls);
179
+ }
180
+ updateColumns() {
181
+ const columnsCount = Math.ceil(this.list.length / ColumnsFormComponent.MAX_ROWS);
182
+ this.columns = [];
183
+ for (let i = 0; i < columnsCount; i++) {
184
+ const items = this.list.slice(i * ColumnsFormComponent.MAX_ROWS, (i + 1) * ColumnsFormComponent.MAX_ROWS);
185
+ this.columns.push(items);
186
+ }
187
+ }
188
+ ngOnDestroy() {
189
+ if (this._atLeastOneSelectedFormGuard) {
190
+ this._atLeastOneSelectedFormGuard.destroy();
191
+ this._atLeastOneSelectedFormGuard = null;
192
+ }
193
+ }
194
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: ColumnsFormComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
195
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.4", type: ColumnsFormComponent, isStandalone: false, selector: "sg-columns-form", inputs: { list: "list", prefix: "prefix" }, ngImport: i0, template: "<form class=\"u-padding--s\" [formGroup]=\"form\">\r\n <div class=\"o-layout\">\r\n <div\r\n *ngFor=\"let column of columns; let lastColumn = last\"\r\n class=\"o-layout__item o-layout__item--12 o-layout__item--dynamic---m u-margin-bottom--m-none\"\r\n [ngClass]=\"{'u-margin-bottom--m': !lastColumn}\"\r\n >\r\n <div class=\"o-layout o-layout--list\">\r\n <div\r\n *ngFor=\"let item of column; let last = last\"\r\n class=\"o-layout__item o-layout__item--12\"\r\n [ngClass]=\"{'u-margin-bottom--m': !last}\"\r\n >\r\n <sg-field>\r\n <sg-checkbox class=\"u-padding-right--xs\" sgFieldContent [formControl]=\"item.isVisibleControl\">{{\r\n item.title\r\n }}</sg-checkbox>\r\n </sg-field>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n</form>\r\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: i2.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i2.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: i3.CheckboxComponent, selector: "sg-checkbox", inputs: ["id"] }, { kind: "component", type: i4.FieldComponent, selector: "sg-field", inputs: ["labelHidden", "inline", "size"] }] }); }
196
+ }
197
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: ColumnsFormComponent, decorators: [{
198
+ type: Component,
199
+ args: [{ selector: 'sg-columns-form', standalone: false, template: "<form class=\"u-padding--s\" [formGroup]=\"form\">\r\n <div class=\"o-layout\">\r\n <div\r\n *ngFor=\"let column of columns; let lastColumn = last\"\r\n class=\"o-layout__item o-layout__item--12 o-layout__item--dynamic---m u-margin-bottom--m-none\"\r\n [ngClass]=\"{'u-margin-bottom--m': !lastColumn}\"\r\n >\r\n <div class=\"o-layout o-layout--list\">\r\n <div\r\n *ngFor=\"let item of column; let last = last\"\r\n class=\"o-layout__item o-layout__item--12\"\r\n [ngClass]=\"{'u-margin-bottom--m': !last}\"\r\n >\r\n <sg-field>\r\n <sg-checkbox class=\"u-padding-right--xs\" sgFieldContent [formControl]=\"item.isVisibleControl\">{{\r\n item.title\r\n }}</sg-checkbox>\r\n </sg-field>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n</form>\r\n" }]
200
+ }], propDecorators: { list: [{
201
+ type: Input
202
+ }], prefix: [{
203
+ type: Input
204
+ }] } });
205
+
206
+ var CellVerticalAlignment;
207
+ (function (CellVerticalAlignment) {
208
+ CellVerticalAlignment["Top"] = "top";
209
+ CellVerticalAlignment["Center"] = "center";
210
+ CellVerticalAlignment["Bottom"] = "bottom";
211
+ })(CellVerticalAlignment || (CellVerticalAlignment = {}));
212
+
213
+ class Selection {
214
+ constructor() {
215
+ this._items = new BehaviorSubject([]);
216
+ this.keys = [];
217
+ this.selectBy = (context) => {
218
+ return context.dataItem;
219
+ };
220
+ this.onChange = () => {
221
+ requestAnimationFrame(() => {
222
+ this._items.next(this.keys);
223
+ });
224
+ };
225
+ this.reset = () => {
226
+ this.keys = [];
227
+ this.onChange();
228
+ };
229
+ }
230
+ get items() {
231
+ return this._items;
232
+ }
233
+ }
234
+
235
+ class GridComponent {
236
+ get selection() {
237
+ return this._selection;
238
+ }
239
+ set selection(value) {
240
+ this._selection = value || this._rowClickSelection;
241
+ }
242
+ constructor(_changeDetectorRef) {
243
+ this._changeDetectorRef = _changeDetectorRef;
244
+ this._observer = new Observer();
245
+ this.cellVerticalAlignment = CellVerticalAlignment.Top;
246
+ this.resizable = false;
247
+ this.rowClicked = new EventEmitter();
248
+ this._rowClickSelection = new Selection();
249
+ this._selection = this._rowClickSelection;
250
+ this._onRowClickSelectionChange = (selection) => {
251
+ if (selection.length > 0) {
252
+ this.rowClicked.emit(selection[0]);
253
+ this.selection.reset();
254
+ this._changeDetectorRef.detectChanges();
255
+ }
256
+ };
257
+ this._observer.listen(this._rowClickSelection.items.pipe(skip(1)), this._onRowClickSelectionChange);
258
+ }
259
+ ngOnDestroy() {
260
+ this._observer.destroy();
261
+ }
262
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: GridComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
263
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.4", type: GridComponent, isStandalone: false, selector: "ng-component", inputs: { cellVerticalAlignment: "cellVerticalAlignment", grid: "grid", resizable: "resizable", selection: "selection" }, outputs: { rowClicked: "rowClicked" }, ngImport: i0, template: '', isInline: true }); }
264
+ }
265
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: GridComponent, decorators: [{
266
+ type: Component,
267
+ args: [{ template: '',
268
+ standalone: false, }]
269
+ }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }], propDecorators: { cellVerticalAlignment: [{
270
+ type: Input
271
+ }], grid: [{
272
+ type: Input
273
+ }], resizable: [{
274
+ type: Input
275
+ }], rowClicked: [{
276
+ type: Output
277
+ }], selection: [{
278
+ type: Input
279
+ }] } });
280
+
281
+ class LoadMoreComponent {
282
+ constructor() {
283
+ this.hasCssClass = true;
284
+ this.isDisabled = false;
285
+ this.clicked = new EventEmitter();
286
+ }
287
+ onClicked() {
288
+ if (!this.isDisabled) {
289
+ this.clicked.emit();
290
+ }
291
+ }
292
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: LoadMoreComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
293
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.4", type: LoadMoreComponent, isStandalone: false, selector: "sg-load-more", inputs: { isDisabled: "isDisabled" }, outputs: { clicked: "clicked" }, host: { properties: { "class.sg-load-more": "this.hasCssClass" } }, ngImport: i0, template: "<button kendoButton [look]=\"'flat'\" [disabled]=\"isDisabled\" (click)=\"onClicked()\">\r\n <span #content><ng-content></ng-content></span>\r\n <ng-container *ngIf=\"!content.innerHTML.trim()\">Load More</ng-container>\r\n</button>\r\n", dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i2$1.ButtonComponent, selector: "button[kendoButton]", inputs: ["arrowIcon", "toggleable", "togglable", "selected", "tabIndex", "imageUrl", "iconClass", "icon", "disabled", "size", "rounded", "fillMode", "themeColor", "svgIcon", "primary", "look"], outputs: ["selectedChange", "click"], exportAs: ["kendoButton"] }] }); }
294
+ }
295
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: LoadMoreComponent, decorators: [{
296
+ type: Component,
297
+ args: [{ selector: 'sg-load-more', standalone: false, template: "<button kendoButton [look]=\"'flat'\" [disabled]=\"isDisabled\" (click)=\"onClicked()\">\r\n <span #content><ng-content></ng-content></span>\r\n <ng-container *ngIf=\"!content.innerHTML.trim()\">Load More</ng-container>\r\n</button>\r\n" }]
298
+ }], propDecorators: { hasCssClass: [{
299
+ type: HostBinding,
300
+ args: ['class.sg-load-more']
301
+ }], isDisabled: [{
302
+ type: Input
303
+ }], clicked: [{
304
+ type: Output
305
+ }] } });
306
+
307
+ class ContinuousGridComponent extends GridComponent {
308
+ constructor(changeDetectorRef) {
309
+ super(changeDetectorRef);
310
+ // Hack: after upgrade to kendo-angular-grid 5.5.X, they expect [field] to always target existing property in schema,
311
+ // while we have some cases of columns for row, not any specific property
312
+ this.FIELD_INPUT_FALLBACK = '_';
313
+ this.hasCssClass = true;
314
+ this.secondary = false;
315
+ this.loadMoreLabel = '';
316
+ this.rowClassFactory = () => '';
317
+ }
318
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: ContinuousGridComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
319
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.4", type: ContinuousGridComponent, isStandalone: false, selector: "sg-continuous-grid", inputs: { secondary: "secondary", loadMoreLabel: "loadMoreLabel", rowClassFactory: "rowClassFactory" }, host: { properties: { "class.sg-continuous-grid": "this.hasCssClass" } }, usesInheritance: true, ngImport: i0, template: "<div class=\"sg-grid\">\r\n <div class=\"sg-blocker sg-blocker--content\" [class.sg-blocker--active]=\"grid.observable.isLoading | async\">\r\n <div class=\"sg-blocker__sticky-container u-align--center\"><span class=\"fa fa-spinner fa-pulse\"></span></div>\r\n </div>\r\n <kendo-grid\r\n [class]=\"'k-grid--only-horizontal-scroll k-grid--cell-alignment-' + cellVerticalAlignment\"\r\n [data]=\"grid.observable.rows | async\"\r\n [sortable]=\"{\r\n allowUnsort: true,\r\n mode: 'single'\r\n }\"\r\n [resizable]=\"resizable\"\r\n [navigable]=\"true\"\r\n [selectable]=\"true\"\r\n [selectedKeys]=\"selection.keys\"\r\n [kendoGridSelectBy]=\"selection.selectBy\"\r\n [rowClass]=\"rowClassFactory\"\r\n (selectionChange)=\"selection.onChange()\"\r\n [sort]=\"grid.observable.sortDescriptor | async\"\r\n (sortChange)=\"grid.onSortDescriptorChanged($event)\"\r\n (columnResize)=\"grid.onColumnResized($event)\"\r\n [class.k-grid--secondary]=\"secondary\"\r\n [class.k-grid--clickable]=\"rowClicked.observers.length > 0\"\r\n >\r\n <kendo-grid-column media=\"(max-width: 49rem)\" [field]=\"FIELD_INPUT_FALLBACK\">\r\n <ng-template kendoGridCellTemplate let-dataItem>\r\n <ul>\r\n <li *ngFor=\"let column of grid.columns\">\r\n <div [hidden]=\"column.isHidden | async\">\r\n <span class=\"u-color-text--secondary\">{{ column.title }} - </span>\r\n <sg-grid-column-cell [column]=\"column\" [row]=\"dataItem\"></sg-grid-column-cell>\r\n </div>\r\n </li>\r\n </ul>\r\n </ng-template>\r\n </kendo-grid-column>\r\n\r\n <kendo-grid-column\r\n *ngFor=\"let column of grid.columns\"\r\n media=\"(min-width: 49rem)\"\r\n [title]=\"column.title\"\r\n [field]=\"column.field || FIELD_INPUT_FALLBACK\"\r\n [width]=\"column.width | async\"\r\n [locked]=\"column.isLocked | async\"\r\n [hidden]=\"column.isHidden | async\"\r\n [sortable]=\"column.isSortable | async\"\r\n [minResizableWidth]=\"column.minWidth | async\"\r\n >\r\n <ng-template kendoGridCellTemplate let-dataItem>\r\n <sg-grid-column-cell [column]=\"column\" [row]=\"dataItem\"></sg-grid-column-cell>\r\n </ng-template>\r\n </kendo-grid-column>\r\n </kendo-grid>\r\n</div>\r\n<sg-load-more\r\n *ngIf=\"grid.hasMoreRows | async\"\r\n (clicked)=\"grid.loadMore()\"\r\n [isDisabled]=\"grid.observable.isLoading | async\"\r\n>\r\n {{ loadMoreLabel }}\r\n</sg-load-more>\r\n", dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i2$2.GridComponent, selector: "kendo-grid", inputs: ["data", "pageSize", "height", "rowHeight", "detailRowHeight", "skip", "scrollable", "selectable", "sort", "size", "trackBy", "filter", "group", "virtualColumns", "filterable", "sortable", "pageable", "groupable", "rowReorderable", "navigable", "navigatable", "autoSize", "rowClass", "rowSticky", "rowSelected", "isRowSelectable", "cellSelected", "resizable", "reorderable", "loading", "columnMenu", "hideHeader", "isDetailExpanded", "isGroupExpanded"], outputs: ["filterChange", "pageChange", "groupChange", "sortChange", "selectionChange", "rowReorder", "dataStateChange", "groupExpand", "groupCollapse", "detailExpand", "detailCollapse", "edit", "cancel", "save", "remove", "add", "cellClose", "cellClick", "pdfExport", "excelExport", "columnResize", "columnReorder", "columnVisibilityChange", "columnLockedChange", "columnStickyChange", "scrollBottom", "contentScroll"], exportAs: ["kendoGrid"] }, { kind: "directive", type: i2$2.SelectionDirective, selector: "[kendoGridSelectBy]" }, { kind: "component", type: i2$2.ColumnComponent, selector: "kendo-grid-column", inputs: ["field", "format", "sortable", "groupable", "editor", "filter", "filterable", "editable"] }, { kind: "directive", type: i2$2.CellTemplateDirective, selector: "[kendoGridCellTemplate]" }, { kind: "component", type: LoadMoreComponent, selector: "sg-load-more", inputs: ["isDisabled"], outputs: ["clicked"] }, { kind: "component", type: ColumnCellComponent, selector: "sg-grid-column-cell", inputs: ["column", "row"] }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
320
+ }
321
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: ContinuousGridComponent, decorators: [{
322
+ type: Component,
323
+ args: [{ selector: 'sg-continuous-grid', changeDetection: ChangeDetectionStrategy.OnPush, standalone: false, template: "<div class=\"sg-grid\">\r\n <div class=\"sg-blocker sg-blocker--content\" [class.sg-blocker--active]=\"grid.observable.isLoading | async\">\r\n <div class=\"sg-blocker__sticky-container u-align--center\"><span class=\"fa fa-spinner fa-pulse\"></span></div>\r\n </div>\r\n <kendo-grid\r\n [class]=\"'k-grid--only-horizontal-scroll k-grid--cell-alignment-' + cellVerticalAlignment\"\r\n [data]=\"grid.observable.rows | async\"\r\n [sortable]=\"{\r\n allowUnsort: true,\r\n mode: 'single'\r\n }\"\r\n [resizable]=\"resizable\"\r\n [navigable]=\"true\"\r\n [selectable]=\"true\"\r\n [selectedKeys]=\"selection.keys\"\r\n [kendoGridSelectBy]=\"selection.selectBy\"\r\n [rowClass]=\"rowClassFactory\"\r\n (selectionChange)=\"selection.onChange()\"\r\n [sort]=\"grid.observable.sortDescriptor | async\"\r\n (sortChange)=\"grid.onSortDescriptorChanged($event)\"\r\n (columnResize)=\"grid.onColumnResized($event)\"\r\n [class.k-grid--secondary]=\"secondary\"\r\n [class.k-grid--clickable]=\"rowClicked.observers.length > 0\"\r\n >\r\n <kendo-grid-column media=\"(max-width: 49rem)\" [field]=\"FIELD_INPUT_FALLBACK\">\r\n <ng-template kendoGridCellTemplate let-dataItem>\r\n <ul>\r\n <li *ngFor=\"let column of grid.columns\">\r\n <div [hidden]=\"column.isHidden | async\">\r\n <span class=\"u-color-text--secondary\">{{ column.title }} - </span>\r\n <sg-grid-column-cell [column]=\"column\" [row]=\"dataItem\"></sg-grid-column-cell>\r\n </div>\r\n </li>\r\n </ul>\r\n </ng-template>\r\n </kendo-grid-column>\r\n\r\n <kendo-grid-column\r\n *ngFor=\"let column of grid.columns\"\r\n media=\"(min-width: 49rem)\"\r\n [title]=\"column.title\"\r\n [field]=\"column.field || FIELD_INPUT_FALLBACK\"\r\n [width]=\"column.width | async\"\r\n [locked]=\"column.isLocked | async\"\r\n [hidden]=\"column.isHidden | async\"\r\n [sortable]=\"column.isSortable | async\"\r\n [minResizableWidth]=\"column.minWidth | async\"\r\n >\r\n <ng-template kendoGridCellTemplate let-dataItem>\r\n <sg-grid-column-cell [column]=\"column\" [row]=\"dataItem\"></sg-grid-column-cell>\r\n </ng-template>\r\n </kendo-grid-column>\r\n </kendo-grid>\r\n</div>\r\n<sg-load-more\r\n *ngIf=\"grid.hasMoreRows | async\"\r\n (clicked)=\"grid.loadMore()\"\r\n [isDisabled]=\"grid.observable.isLoading | async\"\r\n>\r\n {{ loadMoreLabel }}\r\n</sg-load-more>\r\n" }]
324
+ }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }], propDecorators: { hasCssClass: [{
325
+ type: HostBinding,
326
+ args: ['class.sg-continuous-grid']
327
+ }], secondary: [{
328
+ type: Input
329
+ }], loadMoreLabel: [{
330
+ type: Input
331
+ }], rowClassFactory: [{
332
+ type: Input
333
+ }] } });
334
+
335
+ class PaginatedGridComponent extends GridComponent {
336
+ constructor(changeDetectorRef) {
337
+ super(changeDetectorRef);
338
+ // Hack: after upgrade to kendo-angular-grid 5.5.X, they expect [field] to always target existing property in schema,
339
+ // while we have some cases of columns for row, not any specific property
340
+ this.FIELD_INPUT_FALLBACK = '_';
341
+ this.secondary = false;
342
+ }
343
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: PaginatedGridComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
344
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.4", type: PaginatedGridComponent, isStandalone: false, selector: "sg-paginated-grid", inputs: { secondary: "secondary" }, usesInheritance: true, ngImport: i0, template: "<div class=\"sg-grid\">\r\n <div class=\"sg-blocker sg-blocker--content\" [class.sg-blocker--active]=\"grid.observable.isLoading | async\">\r\n <div class=\"sg-blocker__sticky-container u-align--center\"><span class=\"fa fa-spinner fa-pulse\"></span></div>\r\n </div>\r\n <kendo-grid\r\n [data]=\"grid.dataResult | async\"\r\n [sortable]=\"{\r\n allowUnsort: true,\r\n mode: 'single'\r\n }\"\r\n [resizable]=\"resizable\"\r\n [skip]=\"grid.observable.skip | async\"\r\n [pageSize]=\"grid.observable.pageSize | async\"\r\n [pageable]=\"grid.pageable\"\r\n [scrollable]=\"'scrollable'\"\r\n [navigable]=\"true\"\r\n (pageChange)=\"grid.pageChange($event)\"\r\n [selectable]=\"true\"\r\n [selectedKeys]=\"selection.keys\"\r\n [kendoGridSelectBy]=\"selection.selectBy\"\r\n (selectionChange)=\"selection.onChange()\"\r\n [sort]=\"grid.observable.sortDescriptor | async\"\r\n (sortChange)=\"grid.onSortDescriptorChanged($event)\"\r\n (columnResize)=\"grid.onColumnResized($event)\"\r\n [class.k-grid--secondary]=\"secondary\"\r\n [class.k-grid--clickable]=\"rowClicked.observers.length > 0\"\r\n >\r\n <kendo-grid-column media=\"(max-width: 49rem)\" [field]=\"FIELD_INPUT_FALLBACK\">\r\n <ng-template kendoGridCellTemplate let-dataItem>\r\n <ul>\r\n <li *ngFor=\"let column of grid.columns\">\r\n <div [hidden]=\"column.isHidden | async\">\r\n <span class=\"u-color-text--secondary\">{{ column.title }} - </span>\r\n <sg-grid-column-cell [column]=\"column\" [row]=\"dataItem\"></sg-grid-column-cell>\r\n </div>\r\n </li>\r\n </ul>\r\n </ng-template>\r\n </kendo-grid-column>\r\n\r\n <kendo-grid-column\r\n *ngFor=\"let column of grid.columns\"\r\n media=\"(min-width: 49rem)\"\r\n [title]=\"column.title\"\r\n [field]=\"column.field\"\r\n [width]=\"column.width | async\"\r\n [locked]=\"column.isLocked | async\"\r\n [hidden]=\"column.isHidden | async\"\r\n [sortable]=\"column.isSortable | async\"\r\n [minResizableWidth]=\"column.minWidth | async\"\r\n >\r\n <ng-template kendoGridCellTemplate let-dataItem>\r\n <sg-grid-column-cell [column]=\"column\" [row]=\"dataItem\"></sg-grid-column-cell>\r\n </ng-template>\r\n </kendo-grid-column>\r\n </kendo-grid>\r\n</div>\r\n", dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "component", type: i2$2.GridComponent, selector: "kendo-grid", inputs: ["data", "pageSize", "height", "rowHeight", "detailRowHeight", "skip", "scrollable", "selectable", "sort", "size", "trackBy", "filter", "group", "virtualColumns", "filterable", "sortable", "pageable", "groupable", "rowReorderable", "navigable", "navigatable", "autoSize", "rowClass", "rowSticky", "rowSelected", "isRowSelectable", "cellSelected", "resizable", "reorderable", "loading", "columnMenu", "hideHeader", "isDetailExpanded", "isGroupExpanded"], outputs: ["filterChange", "pageChange", "groupChange", "sortChange", "selectionChange", "rowReorder", "dataStateChange", "groupExpand", "groupCollapse", "detailExpand", "detailCollapse", "edit", "cancel", "save", "remove", "add", "cellClose", "cellClick", "pdfExport", "excelExport", "columnResize", "columnReorder", "columnVisibilityChange", "columnLockedChange", "columnStickyChange", "scrollBottom", "contentScroll"], exportAs: ["kendoGrid"] }, { kind: "directive", type: i2$2.SelectionDirective, selector: "[kendoGridSelectBy]" }, { kind: "component", type: i2$2.ColumnComponent, selector: "kendo-grid-column", inputs: ["field", "format", "sortable", "groupable", "editor", "filter", "filterable", "editable"] }, { kind: "directive", type: i2$2.CellTemplateDirective, selector: "[kendoGridCellTemplate]" }, { kind: "component", type: ColumnCellComponent, selector: "sg-grid-column-cell", inputs: ["column", "row"] }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
345
+ }
346
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: PaginatedGridComponent, decorators: [{
347
+ type: Component,
348
+ args: [{ selector: 'sg-paginated-grid', changeDetection: ChangeDetectionStrategy.OnPush, standalone: false, template: "<div class=\"sg-grid\">\r\n <div class=\"sg-blocker sg-blocker--content\" [class.sg-blocker--active]=\"grid.observable.isLoading | async\">\r\n <div class=\"sg-blocker__sticky-container u-align--center\"><span class=\"fa fa-spinner fa-pulse\"></span></div>\r\n </div>\r\n <kendo-grid\r\n [data]=\"grid.dataResult | async\"\r\n [sortable]=\"{\r\n allowUnsort: true,\r\n mode: 'single'\r\n }\"\r\n [resizable]=\"resizable\"\r\n [skip]=\"grid.observable.skip | async\"\r\n [pageSize]=\"grid.observable.pageSize | async\"\r\n [pageable]=\"grid.pageable\"\r\n [scrollable]=\"'scrollable'\"\r\n [navigable]=\"true\"\r\n (pageChange)=\"grid.pageChange($event)\"\r\n [selectable]=\"true\"\r\n [selectedKeys]=\"selection.keys\"\r\n [kendoGridSelectBy]=\"selection.selectBy\"\r\n (selectionChange)=\"selection.onChange()\"\r\n [sort]=\"grid.observable.sortDescriptor | async\"\r\n (sortChange)=\"grid.onSortDescriptorChanged($event)\"\r\n (columnResize)=\"grid.onColumnResized($event)\"\r\n [class.k-grid--secondary]=\"secondary\"\r\n [class.k-grid--clickable]=\"rowClicked.observers.length > 0\"\r\n >\r\n <kendo-grid-column media=\"(max-width: 49rem)\" [field]=\"FIELD_INPUT_FALLBACK\">\r\n <ng-template kendoGridCellTemplate let-dataItem>\r\n <ul>\r\n <li *ngFor=\"let column of grid.columns\">\r\n <div [hidden]=\"column.isHidden | async\">\r\n <span class=\"u-color-text--secondary\">{{ column.title }} - </span>\r\n <sg-grid-column-cell [column]=\"column\" [row]=\"dataItem\"></sg-grid-column-cell>\r\n </div>\r\n </li>\r\n </ul>\r\n </ng-template>\r\n </kendo-grid-column>\r\n\r\n <kendo-grid-column\r\n *ngFor=\"let column of grid.columns\"\r\n media=\"(min-width: 49rem)\"\r\n [title]=\"column.title\"\r\n [field]=\"column.field\"\r\n [width]=\"column.width | async\"\r\n [locked]=\"column.isLocked | async\"\r\n [hidden]=\"column.isHidden | async\"\r\n [sortable]=\"column.isSortable | async\"\r\n [minResizableWidth]=\"column.minWidth | async\"\r\n >\r\n <ng-template kendoGridCellTemplate let-dataItem>\r\n <sg-grid-column-cell [column]=\"column\" [row]=\"dataItem\"></sg-grid-column-cell>\r\n </ng-template>\r\n </kendo-grid-column>\r\n </kendo-grid>\r\n</div>\r\n" }]
349
+ }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }], propDecorators: { secondary: [{
350
+ type: Input
351
+ }] } });
352
+
353
+ const components = [
354
+ LoadMoreComponent,
355
+ GridComponent,
356
+ ContinuousGridComponent,
357
+ PaginatedGridComponent,
358
+ ColumnCellComponent,
359
+ ColumnsFormComponent,
360
+ ];
361
+ const cells = [CellComponent];
362
+ const pages = [];
363
+ const pipes = [];
364
+ class GridModule {
365
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: GridModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
366
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.1.4", ngImport: i0, type: GridModule, declarations: [LoadMoreComponent,
367
+ GridComponent,
368
+ ContinuousGridComponent,
369
+ PaginatedGridComponent,
370
+ ColumnCellComponent,
371
+ ColumnsFormComponent, CellComponent], imports: [CommonModule, GridModule$1, ReactiveFormsModule, CheckboxModule, FieldModule, ButtonModule], exports: [LoadMoreComponent,
372
+ GridComponent,
373
+ ContinuousGridComponent,
374
+ PaginatedGridComponent,
375
+ ColumnCellComponent,
376
+ ColumnsFormComponent] }); }
377
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: GridModule, imports: [CommonModule, GridModule$1, ReactiveFormsModule, CheckboxModule, FieldModule, ButtonModule] }); }
378
+ }
379
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: GridModule, decorators: [{
380
+ type: NgModule,
381
+ args: [{
382
+ declarations: [...components, ...pages, ...pipes, ...cells],
383
+ imports: [CommonModule, GridModule$1, ReactiveFormsModule, CheckboxModule, FieldModule, ButtonModule],
384
+ exports: [...components, ...pages, ...pipes],
385
+ providers: [],
386
+ }]
387
+ }] });
388
+
389
+ class Grid {
390
+ get rows() {
391
+ return this._rows.value;
392
+ }
393
+ set rows(value) {
394
+ this._rows.next(value);
395
+ }
396
+ get skip() {
397
+ return this._skip.value;
398
+ }
399
+ set skip(value) {
400
+ if (!isNaN(value) && this.skip !== value) {
401
+ this._skip.next(value);
402
+ }
403
+ }
404
+ get pageSize() {
405
+ return this._pageSize.value;
406
+ }
407
+ set pageSize(value) {
408
+ if (!isNaN(value) && this.pageSize !== value) {
409
+ this._pageSize.next(value);
410
+ }
411
+ }
412
+ get sortDescriptor() {
413
+ return this._sortDescriptor.value;
414
+ }
415
+ set sortDescriptor(value) {
416
+ this._sortDescriptor.next(value);
417
+ }
418
+ constructor(name, columns) {
419
+ this.name = name;
420
+ this.columns = columns;
421
+ this._worker = new Worker();
422
+ this._rows = new BehaviorSubject([]);
423
+ this._skip = new BehaviorSubject(0);
424
+ this._pageSize = new BehaviorSubject(25);
425
+ this._sortDescriptor = new BehaviorSubject([]);
426
+ this.observable = {
427
+ isLoading: this._worker.isWorking,
428
+ rows: this._rows,
429
+ sortDescriptor: this._sortDescriptor,
430
+ skip: this._skip,
431
+ pageSize: this._pageSize,
432
+ };
433
+ this._loadingFailed = new Subject();
434
+ this.loadingFailed = this._loadingFailed;
435
+ this.reload = () => { };
436
+ this.replace = (item, newItem) => {
437
+ const rows = this.rows.concat();
438
+ const index = rows.indexOf(item);
439
+ if (index > -1) {
440
+ rows[index] = newItem;
441
+ this._rows.next(rows);
442
+ }
443
+ };
444
+ this.onColumnResized = (changes) => {
445
+ changes
446
+ .map((change) => ({ column: change.column, newWidth: change.newWidth }))
447
+ .forEach((change) => {
448
+ const column = this.columns.find((c) => c.field === change.column.field);
449
+ if (column) {
450
+ column.width.next(change.newWidth ?? 0);
451
+ }
452
+ });
453
+ };
454
+ this.onSortDescriptorChanged = (sortDescriptor) => {
455
+ this.sortDescriptor = sortDescriptor;
456
+ this.reload();
457
+ };
458
+ this.onLoadError = (error) => {
459
+ this._loadingFailed.next(error);
460
+ };
461
+ const sortColumn = columns.find((column) => column.isDefaultSortColumn);
462
+ this.sortDescriptor =
463
+ sortColumn !== undefined
464
+ ? [
465
+ {
466
+ field: sortColumn.field,
467
+ dir: sortColumn.defaultSortDirection,
468
+ },
469
+ ]
470
+ : [];
471
+ }
472
+ }
473
+
474
+ class ContinuousGrid extends Grid {
475
+ constructor(name, columns, _loadPage) {
476
+ super(name, columns);
477
+ this._loadPage = _loadPage;
478
+ this._hasMoreRows = new BehaviorSubject(false);
479
+ this.hasMoreRows = this._hasMoreRows;
480
+ this.reload = () => {
481
+ this.skip = 0;
482
+ this._worker.handle(this._loadPage(this.skip, this.pageSize, this.sortDescriptor), this.onLoadSuccess, this.onLoadError);
483
+ };
484
+ this.loadMore = () => {
485
+ this.skip += this.pageSize;
486
+ this._worker.handle(this._loadPage(this.skip, this.pageSize, this.sortDescriptor), this.onLoadMoreSuccess, this.onLoadError);
487
+ };
488
+ this.onLoadSuccess = (dataResult) => {
489
+ this.rows = dataResult.rows;
490
+ this._hasMoreRows.next(!dataResult.isLastPage);
491
+ };
492
+ this.onLoadMoreSuccess = (dataResult) => {
493
+ this.rows = [...this.rows, ...dataResult.rows];
494
+ this._hasMoreRows.next(!dataResult.isLastPage);
495
+ };
496
+ }
497
+ preload(pagesCount) {
498
+ this.rows = [];
499
+ this.skip = 0;
500
+ this.skip = pagesCount > 0 ? (pagesCount - 1) * this.pageSize : 0;
501
+ if (pagesCount > 0) {
502
+ this._worker.handle(this._loadPage(0, pagesCount * this.pageSize, this._sortDescriptor.value), this.onLoadSuccess, this.onLoadError);
503
+ }
504
+ }
505
+ }
506
+
507
+ class PaginatedGrid extends Grid {
508
+ constructor(name, columns, _loadPage) {
509
+ super(name, columns);
510
+ this._loadPage = _loadPage;
511
+ this.pageable = {
512
+ buttonCount: 5,
513
+ info: true,
514
+ type: 'numeric',
515
+ pageSizes: [100, 250, 500],
516
+ previousNext: true,
517
+ };
518
+ this._total = new BehaviorSubject(0);
519
+ this.dataResult = combineLatest([this.observable.rows, this._total]).pipe(map(([rows, total]) => ({ data: rows, total })));
520
+ this.reload = () => {
521
+ this._worker.handle(this._loadPage(this.skip, this.pageSize, this._sortDescriptor.value), this.onLoadSuccess, this.onLoadError);
522
+ };
523
+ this.onLoadSuccess = (result) => {
524
+ this.rows = result.rows;
525
+ this._total.next(result.total);
526
+ };
527
+ this.pageSize = Is.array(this.pageable.pageSizes) ? this.pageable.pageSizes[0] ?? 0 : 0;
528
+ }
529
+ pageChange(event) {
530
+ this.skip = event.skip;
531
+ this.pageSize = event.take;
532
+ this.reload();
533
+ }
534
+ }
535
+
536
+ /**
537
+ * Generated bundle index. Do not edit.
538
+ */
539
+
540
+ export { CellComponent, CellVerticalAlignment, Column, ColumnCellComponent, ColumnsFormComponent, ContinuousGrid, ContinuousGridComponent, Grid, GridComponent, GridModule, LoadMoreComponent, PaginatedGrid, PaginatedGridComponent, Selection, SortDirection };
541
+ //# sourceMappingURL=marcura-marcura-grid.mjs.map