@progress/kendo-angular-pivotgrid 0.1.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 (38) hide show
  1. package/LICENSE.md +11 -0
  2. package/NOTICE.txt +654 -0
  3. package/README.md +31 -0
  4. package/bundles/kendo-angular-pivotgrid.umd.js +5 -0
  5. package/data-binding/base-binding-directive.d.ts +38 -0
  6. package/data-binding/local-binding.directive.d.ts +35 -0
  7. package/data-binding/olap-binding.directive.d.ts +30 -0
  8. package/data-binding/pivotgrid-data.service.d.ts +38 -0
  9. package/esm2015/data-binding/base-binding-directive.js +81 -0
  10. package/esm2015/data-binding/local-binding.directive.js +66 -0
  11. package/esm2015/data-binding/olap-binding.directive.js +57 -0
  12. package/esm2015/data-binding/pivotgrid-data.service.js +42 -0
  13. package/esm2015/kendo-angular-pivotgrid.js +8 -0
  14. package/esm2015/main.js +14 -0
  15. package/esm2015/models/expanded-state-action.js +5 -0
  16. package/esm2015/models/loader-settings.js +5 -0
  17. package/esm2015/package-metadata.js +15 -0
  18. package/esm2015/pivotgrid.component.js +152 -0
  19. package/esm2015/pivotgrid.module.js +60 -0
  20. package/esm2015/rendering/pivotgrid-cell.directive.js +90 -0
  21. package/esm2015/rendering/pivotgrid-table.component.js +89 -0
  22. package/esm2015/util.js +49 -0
  23. package/fesm2015/kendo-angular-pivotgrid.js +639 -0
  24. package/kendo-angular-pivotgrid.d.ts +9 -0
  25. package/main.d.ts +11 -0
  26. package/models/expanded-state-action.d.ts +16 -0
  27. package/models/loader-settings.d.ts +47 -0
  28. package/package-metadata.d.ts +9 -0
  29. package/package.json +86 -0
  30. package/pivotgrid.component.d.ts +39 -0
  31. package/pivotgrid.module.d.ts +21 -0
  32. package/rendering/pivotgrid-cell.directive.d.ts +26 -0
  33. package/rendering/pivotgrid-table.component.d.ts +22 -0
  34. package/schematics/collection.json +12 -0
  35. package/schematics/ngAdd/index.js +17 -0
  36. package/schematics/ngAdd/index.js.map +1 -0
  37. package/schematics/ngAdd/schema.json +28 -0
  38. package/util.d.ts +18 -0
@@ -0,0 +1,639 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ import * as i0 from '@angular/core';
6
+ import { EventEmitter, Injectable, Output, Component, HostBinding, Input, Directive, NgModule } from '@angular/core';
7
+ import { validatePackage } from '@progress/kendo-licensing';
8
+ import * as i3 from '@progress/kendo-angular-common';
9
+ import { isDocumentAvailable, anyChanged, EventsModule } from '@progress/kendo-angular-common';
10
+ import { toTree, toRows, toColumns, toData, HEADERS_ACTION, headersReducer, createDataTree, createLocalDataState, rootFields, fetchData, createDataState } from '@progress/kendo-pivotgrid-common';
11
+ export { averageAggregate, maxAggregate, minAggregate, sumAggregate } from '@progress/kendo-pivotgrid-common';
12
+ import { BehaviorSubject, Subscription } from 'rxjs';
13
+ import * as i2 from '@angular/common';
14
+ import { CommonModule } from '@angular/common';
15
+ import * as i3$1 from '@progress/kendo-angular-indicators';
16
+ import { IndicatorsModule } from '@progress/kendo-angular-indicators';
17
+ import { L10N_PREFIX } from '@progress/kendo-angular-l10n';
18
+
19
+ /**
20
+ * @hidden
21
+ */
22
+ const packageMetadata = {
23
+ name: '@progress/kendo-angular-pivotgrid',
24
+ productName: 'Kendo UI for Angular',
25
+ productCodes: ['KENDOUIANGULAR', 'KENDOUICOMPLETE'],
26
+ publishDate: 1652189168,
27
+ version: '',
28
+ licensingDocsUrl: 'https://www.telerik.com/kendo-angular-ui/my-license/?utm_medium=product&utm_source=kendoangular&utm_campaign=kendo-ui-angular-purchase-license-keys-warning'
29
+ };
30
+
31
+ /**
32
+ * @hidden
33
+ */
34
+ const canCreateElement = () => isDocumentAvailable() && document.createElement;
35
+ /**
36
+ * @hidden
37
+ */
38
+ let cachedScrollbarWidth = null;
39
+ /**
40
+ * @hidden
41
+ */
42
+ const scrollbarWidth = () => {
43
+ if (cachedScrollbarWidth === null && canCreateElement()) {
44
+ const div = document.createElement("div");
45
+ div.style.cssText = "overflow:scroll;overflow-x:hidden;zoom:1;clear:both;display:block";
46
+ div.innerHTML = " ";
47
+ document.body.appendChild(div);
48
+ cachedScrollbarWidth = div.offsetWidth - div.scrollWidth;
49
+ document.body.removeChild(div);
50
+ }
51
+ return cachedScrollbarWidth;
52
+ };
53
+ /**
54
+ * @hidden
55
+ */
56
+ const isPresent = (value) => value !== null && value !== undefined;
57
+ /**
58
+ * @hidden
59
+ * Returns whether two arrays contain the same values.
60
+ * Assumes array elements are primitive types
61
+ */
62
+ const areSameArrays = (a1, a2) => {
63
+ const areArrays = (isPresent(a1) && Array.isArray(a1) && isPresent(a2) && Array.isArray(a2));
64
+ const areOfEqualLength = a1.length === a2.length;
65
+ if (!areArrays || !areOfEqualLength) {
66
+ return false;
67
+ }
68
+ for (let i = 0; i < a1.length; i++) {
69
+ if (a1[i] !== a2[i]) {
70
+ return false;
71
+ }
72
+ }
73
+ return true;
74
+ };
75
+
76
+ /**
77
+ * @hidden
78
+ */
79
+ class PivotGridDataService {
80
+ constructor() {
81
+ this.expandedStateChange = new EventEmitter();
82
+ this.columnHeaderRows = new BehaviorSubject([]);
83
+ this.columnHeaderCols = new BehaviorSubject([]);
84
+ this.rowHeaderCols = new BehaviorSubject([]);
85
+ this.rowHeaderRows = new BehaviorSubject([]);
86
+ this.valuesRows = new BehaviorSubject([]);
87
+ this.loading = new BehaviorSubject(false);
88
+ }
89
+ updateRowsAndCols() {
90
+ const rowsTree = toTree((this.rows || []).slice());
91
+ const [rowHeaderRows, rowHeaderLeaves, rowHeaderDepth, rowHeaderBreadth] = toRows(rowsTree);
92
+ const columnsTree = toTree((this.columns || []).slice());
93
+ const [columnHeaderRows, columnHeaderLeaves, columnHeaderBreadth] = toColumns(columnsTree);
94
+ this.columnHeaderLeaves = columnHeaderLeaves;
95
+ this.columnHeaderCols.next(new Array(columnHeaderBreadth).fill({}));
96
+ this.columnHeaderRows.next(columnHeaderRows);
97
+ this.rowHeaderLeaves = rowHeaderLeaves;
98
+ this.rowHeaderCols.next(new Array(rowHeaderBreadth).fill({}));
99
+ this.rowHeaderRows.next(rowHeaderRows);
100
+ this.valuesRows.next(toData((this.normalizedData || []).slice(), columnHeaderLeaves, rowHeaderLeaves, columnHeaderBreadth, rowHeaderDepth));
101
+ }
102
+ }
103
+ PivotGridDataService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: PivotGridDataService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
104
+ PivotGridDataService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: PivotGridDataService });
105
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: PivotGridDataService, decorators: [{
106
+ type: Injectable
107
+ }], propDecorators: { expandedStateChange: [{
108
+ type: Output
109
+ }] } });
110
+
111
+ /**
112
+ * @hidden
113
+ */
114
+ class PivotGridCellDirective {
115
+ constructor(hostEl, renderer, dataService) {
116
+ this.hostEl = hostEl;
117
+ this.renderer = renderer;
118
+ this.dataService = dataService;
119
+ this.cellClass = true;
120
+ this.handleClick = () => {
121
+ this.dataService.expandedStateChange.emit({
122
+ action: this.expanded ? 'collapse' : 'expand',
123
+ cell: this.kendoPivotGridCell,
124
+ tableType: this.tableType
125
+ });
126
+ };
127
+ }
128
+ get expanded() {
129
+ var _a;
130
+ return ((_a = this.kendoPivotGridCell) === null || _a === void 0 ? void 0 : _a.hasChildren) && this.kendoPivotGridCell.children.length;
131
+ }
132
+ ngOnInit() {
133
+ const nativeElement = this.hostEl.nativeElement;
134
+ this.renderer.setAttribute(nativeElement, 'rowspan', this.kendoPivotGridCell.rowSpan || 1);
135
+ this.renderer.setAttribute(nativeElement, 'colspan', this.kendoPivotGridCell.colSpan || 1);
136
+ const classesToAdd = {
137
+ 'k-pivotgrid-header-total': this.kendoPivotGridCell.total || (this.tableType === 'values'
138
+ && (this.dataService.rowHeaderLeaves[this.rowIndex].total ||
139
+ this.dataService.columnHeaderLeaves[this.colIndex].total)),
140
+ 'k-pivotgrid-header-root': this.kendoPivotGridCell.levelNum === 0,
141
+ 'k-pivotgrid-expanded': this.kendoPivotGridCell.hasChildren && this.kendoPivotGridCell.children.length,
142
+ 'k-first': this.colIndex === 1
143
+ };
144
+ for (let prop in classesToAdd) {
145
+ if (classesToAdd[prop]) {
146
+ this.renderer.addClass(nativeElement, prop);
147
+ }
148
+ }
149
+ }
150
+ }
151
+ PivotGridCellDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: PivotGridCellDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: PivotGridDataService }], target: i0.ɵɵFactoryTarget.Component });
152
+ PivotGridCellDirective.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: PivotGridCellDirective, selector: "[kendoPivotGridCell]", inputs: { kendoPivotGridCell: "kendoPivotGridCell", tableType: "tableType", rowIndex: "rowIndex", colIndex: "colIndex" }, host: { properties: { "class.k-pivotgrid-cell": "this.cellClass" } }, ngImport: i0, template: `
153
+ <span
154
+ *ngIf="kendoPivotGridCell.hasChildren && !kendoPivotGridCell.total"
155
+ class="k-icon"
156
+ [kendoEventsOutsideAngular]="{
157
+ click: handleClick
158
+ }"
159
+ [ngClass]="{
160
+ 'k-i-arrow-chevron-up': expanded,
161
+ 'k-i-arrow-chevron-down': !expanded
162
+ }"></span>{{ kendoPivotGridCell.data ? kendoPivotGridCell.data.fmtValue : kendoPivotGridCell.caption }}`, isInline: true, directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i3.EventsOutsideAngularDirective, selector: "[kendoEventsOutsideAngular]", inputs: ["kendoEventsOutsideAngular", "scope"] }, { type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }] });
163
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: PivotGridCellDirective, decorators: [{
164
+ type: Component,
165
+ args: [{
166
+ // eslint-disable-next-line @angular-eslint/component-selector
167
+ selector: '[kendoPivotGridCell]',
168
+ template: `
169
+ <span
170
+ *ngIf="kendoPivotGridCell.hasChildren && !kendoPivotGridCell.total"
171
+ class="k-icon"
172
+ [kendoEventsOutsideAngular]="{
173
+ click: handleClick
174
+ }"
175
+ [ngClass]="{
176
+ 'k-i-arrow-chevron-up': expanded,
177
+ 'k-i-arrow-chevron-down': !expanded
178
+ }"></span>{{ kendoPivotGridCell.data ? kendoPivotGridCell.data.fmtValue : kendoPivotGridCell.caption }}`
179
+ }]
180
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: PivotGridDataService }]; }, propDecorators: { cellClass: [{
181
+ type: HostBinding,
182
+ args: ['class.k-pivotgrid-cell']
183
+ }], kendoPivotGridCell: [{
184
+ type: Input
185
+ }], tableType: [{
186
+ type: Input
187
+ }], rowIndex: [{
188
+ type: Input
189
+ }], colIndex: [{
190
+ type: Input
191
+ }] } });
192
+
193
+ /**
194
+ * @hidden
195
+ */
196
+ class PivotGridTableComponent {
197
+ constructor(dataService) {
198
+ this.dataService = dataService;
199
+ this.dataChangeSubs = new Subscription();
200
+ }
201
+ ngOnInit() {
202
+ this.dataChangeSubs.add(this.dataService[`${this.tableType}Rows`].subscribe(rows => this.rows = rows));
203
+ this.dataChangeSubs.add(this.tableType === 'values' ?
204
+ this.dataService.columnHeaderCols.subscribe(cols => this.headerItems = cols) :
205
+ this.dataService[`${this.tableType}Cols`].subscribe(cols => this.headerItems = cols));
206
+ }
207
+ ngOnDestroy() {
208
+ this.dataChangeSubs.unsubscribe();
209
+ }
210
+ }
211
+ PivotGridTableComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: PivotGridTableComponent, deps: [{ token: PivotGridDataService }], target: i0.ɵɵFactoryTarget.Component });
212
+ PivotGridTableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: PivotGridTableComponent, selector: "kendo-pivotgrid-table", inputs: { tableType: "tableType" }, ngImport: i0, template: `
213
+ <table class="k-pivotgrid-table">
214
+ <colgroup>
215
+ <col *ngFor="let item of headerItems;" />
216
+ </colgroup>
217
+ <tbody class="k-pivotgrid-tbody">
218
+ <tr *ngFor="let row of rows; index as rowIndex"
219
+ class="k-pivotgrid-row">
220
+ <ng-container *ngFor="let cell of row.cells; index as colIndex">
221
+ <th
222
+ *ngIf="cell && tableType !== 'values'"
223
+ [kendoPivotGridCell]="cell"
224
+ [tableType]="tableType"
225
+ [colIndex]="colIndex"
226
+ [rowIndex]="rowIndex"></th>
227
+ <td
228
+ *ngIf="cell && tableType === 'values'"
229
+ [kendoPivotGridCell]="cell"
230
+ tableType="values"
231
+ [colIndex]="colIndex"
232
+ [rowIndex]="rowIndex"></td>
233
+ </ng-container>
234
+ </tr>
235
+ </tbody>
236
+ </table>
237
+ `, isInline: true, components: [{ type: PivotGridCellDirective, selector: "[kendoPivotGridCell]", inputs: ["kendoPivotGridCell", "tableType", "rowIndex", "colIndex"] }], directives: [{ type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
238
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: PivotGridTableComponent, decorators: [{
239
+ type: Component,
240
+ args: [{
241
+ selector: 'kendo-pivotgrid-table',
242
+ template: `
243
+ <table class="k-pivotgrid-table">
244
+ <colgroup>
245
+ <col *ngFor="let item of headerItems;" />
246
+ </colgroup>
247
+ <tbody class="k-pivotgrid-tbody">
248
+ <tr *ngFor="let row of rows; index as rowIndex"
249
+ class="k-pivotgrid-row">
250
+ <ng-container *ngFor="let cell of row.cells; index as colIndex">
251
+ <th
252
+ *ngIf="cell && tableType !== 'values'"
253
+ [kendoPivotGridCell]="cell"
254
+ [tableType]="tableType"
255
+ [colIndex]="colIndex"
256
+ [rowIndex]="rowIndex"></th>
257
+ <td
258
+ *ngIf="cell && tableType === 'values'"
259
+ [kendoPivotGridCell]="cell"
260
+ tableType="values"
261
+ [colIndex]="colIndex"
262
+ [rowIndex]="rowIndex"></td>
263
+ </ng-container>
264
+ </tr>
265
+ </tbody>
266
+ </table>
267
+ `
268
+ }]
269
+ }], ctorParameters: function () { return [{ type: PivotGridDataService }]; }, propDecorators: { tableType: [{
270
+ type: Input
271
+ }] } });
272
+
273
+ const DEFAULT_LOADER_SETTINGS = {
274
+ type: 'converging-spinner',
275
+ themeColor: 'primary',
276
+ size: 'large'
277
+ };
278
+ /**
279
+ * A sample component
280
+ */
281
+ class PivotGridComponent {
282
+ constructor(hostEl, zone, dataService) {
283
+ this.hostEl = hostEl;
284
+ this.zone = zone;
285
+ this.dataService = dataService;
286
+ this.hostClass = true;
287
+ this.resizeObservers = [];
288
+ this._loaderSettings = DEFAULT_LOADER_SETTINGS;
289
+ this.loadingSubscription = new Subscription();
290
+ this.resizeContainer = (axis, element) => {
291
+ const isRows = axis === 'Rows';
292
+ const wrapper = this.hostEl.nativeElement;
293
+ const size = isRows ? 'offsetHeight' : 'offsetWidth';
294
+ wrapper.style[`gridTemplate${axis}`] = '';
295
+ wrapper.style[`gridTemplate${axis}`] = `${element[size]}px 1fr`;
296
+ };
297
+ validatePackage(packageMetadata);
298
+ }
299
+ get scrollbarWidth() {
300
+ return `${scrollbarWidth()}px`;
301
+ }
302
+ /**
303
+ * Specify the type, size and color of the PivotGrid's loader.
304
+ *
305
+ * The default settings are:
306
+ * * type: `converging-spinner`
307
+ * * color: `primary`
308
+ * * size: `large`
309
+ */
310
+ set loaderSettings(settings) {
311
+ this._loaderSettings = Object.assign({}, DEFAULT_LOADER_SETTINGS, settings);
312
+ }
313
+ ;
314
+ get loaderSettings() {
315
+ return this._loaderSettings;
316
+ }
317
+ ngAfterViewInit() {
318
+ if (isDocumentAvailable()) {
319
+ this.zone.runOutsideAngular(() => {
320
+ const rowHeadersTable = document.querySelector('.k-pivotgrid-row-headers .k-pivotgrid-table');
321
+ const headerColsResizeObserver = new ResizeObserver(() => this.resizeContainer('Columns', rowHeadersTable));
322
+ headerColsResizeObserver.observe(rowHeadersTable);
323
+ const colHeadersTable = document.querySelector('.k-pivotgrid-column-headers .k-pivotgrid-table');
324
+ const headerRowsResizeObserver = new ResizeObserver(() => this.resizeContainer('Rows', colHeadersTable));
325
+ headerRowsResizeObserver.observe(colHeadersTable);
326
+ this.resizeObservers = [headerColsResizeObserver, headerRowsResizeObserver];
327
+ });
328
+ }
329
+ }
330
+ ngAfterContentInit() {
331
+ this.loadingSubscription.add(this.dataService.loading.subscribe(state => this.loading = state));
332
+ }
333
+ ngOnDestroy() {
334
+ this.resizeObservers.forEach(o => o.disconnect());
335
+ this.loadingSubscription.unsubscribe();
336
+ }
337
+ }
338
+ PivotGridComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: PivotGridComponent, deps: [{ token: i0.ElementRef }, { token: i0.NgZone }, { token: PivotGridDataService }], target: i0.ɵɵFactoryTarget.Component });
339
+ PivotGridComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: PivotGridComponent, selector: "kendo-pivotgrid", inputs: { loaderSettings: "loaderSettings" }, host: { properties: { "class.k-pivotgrid": "this.hostClass", "style.--kendo-scrollbar-width": "this.scrollbarWidth" } }, providers: [
340
+ PivotGridDataService
341
+ ], ngImport: i0, template: `
342
+ <span class="k-pivotgrid-empty-cell"></span>
343
+ <kendo-pivotgrid-table
344
+ class="k-pivotgrid-column-headers"
345
+ tableType="columnHeader"></kendo-pivotgrid-table>
346
+ <kendo-pivotgrid-table
347
+ class="k-pivotgrid-row-headers"
348
+ tableType="rowHeader"></kendo-pivotgrid-table>
349
+ <kendo-pivotgrid-table
350
+ class="k-pivotgrid-values"
351
+ tableType="values"></kendo-pivotgrid-table>
352
+
353
+ <div *ngIf="loading" class="k-loader">
354
+ <kendo-loader
355
+ [type]="loaderSettings?.type"
356
+ [themeColor]="loaderSettings?.themeColor"
357
+ [size]="loaderSettings?.size"
358
+ >
359
+ </kendo-loader>
360
+ </div>
361
+ `, isInline: true, styles: ["\n /** TODO: Remove if added to themes */\n div.k-loader {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n }\n "], components: [{ type: PivotGridTableComponent, selector: "kendo-pivotgrid-table", inputs: ["tableType"] }, { type: i3$1.LoaderComponent, selector: "kendo-loader", inputs: ["type", "themeColor", "size"] }], directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
362
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: PivotGridComponent, decorators: [{
363
+ type: Component,
364
+ args: [{
365
+ selector: 'kendo-pivotgrid',
366
+ providers: [
367
+ PivotGridDataService
368
+ ],
369
+ template: `
370
+ <span class="k-pivotgrid-empty-cell"></span>
371
+ <kendo-pivotgrid-table
372
+ class="k-pivotgrid-column-headers"
373
+ tableType="columnHeader"></kendo-pivotgrid-table>
374
+ <kendo-pivotgrid-table
375
+ class="k-pivotgrid-row-headers"
376
+ tableType="rowHeader"></kendo-pivotgrid-table>
377
+ <kendo-pivotgrid-table
378
+ class="k-pivotgrid-values"
379
+ tableType="values"></kendo-pivotgrid-table>
380
+
381
+ <div *ngIf="loading" class="k-loader">
382
+ <kendo-loader
383
+ [type]="loaderSettings?.type"
384
+ [themeColor]="loaderSettings?.themeColor"
385
+ [size]="loaderSettings?.size"
386
+ >
387
+ </kendo-loader>
388
+ </div>
389
+ `,
390
+ styles: [`
391
+ /** TODO: Remove if added to themes */
392
+ div.k-loader {
393
+ position: absolute;
394
+ top: 50%;
395
+ left: 50%;
396
+ transform: translate(-50%, -50%);
397
+ }
398
+ `]
399
+ }]
400
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.NgZone }, { type: PivotGridDataService }]; }, propDecorators: { hostClass: [{
401
+ type: HostBinding,
402
+ args: ['class.k-pivotgrid']
403
+ }], scrollbarWidth: [{
404
+ type: HostBinding,
405
+ args: ['style.--kendo-scrollbar-width']
406
+ }], loaderSettings: [{
407
+ type: Input
408
+ }] } });
409
+
410
+ /**
411
+ * @hidden
412
+ * A directive which binds the PivotGrid to an array of objects.
413
+ */
414
+ class PivotBaseBindingDirective {
415
+ constructor(dataService, zone) {
416
+ this.dataService = dataService;
417
+ this.zone = zone;
418
+ /**
419
+ * Represents the column axes configuration of the PivotGrid.
420
+ */
421
+ this.columnAxes = [];
422
+ /**
423
+ * Represents the row axes configuration of the PivotGrid.
424
+ */
425
+ this.rowAxes = [];
426
+ /**
427
+ * Represents the measure axes configuration of the PivotGrid.
428
+ */
429
+ this.measureAxes = [];
430
+ this.expandedStateSub = new Subscription();
431
+ }
432
+ ngOnInit() {
433
+ this.loadData();
434
+ this.expandedStateSub = this.dataService.expandedStateChange.subscribe((state) => {
435
+ this.zone.run(() => {
436
+ const isCol = state.tableType === 'columnHeader';
437
+ const axes = isCol ? 'columnAxes' : 'rowAxes';
438
+ // Converts current rows state to a tree-like structure (using the PivotGrid Common pkg)
439
+ const tree = toTree((isCol ? this.dataService.columns : this.dataService.rows || []).slice());
440
+ this.updateHeaders(axes, tree, state.cell.path);
441
+ });
442
+ });
443
+ }
444
+ ngOnDestroy() {
445
+ this.expandedStateSub.unsubscribe();
446
+ }
447
+ updateDataServiceFields() {
448
+ this.dataService.normalizedData = this.dataState.data;
449
+ this.dataService.rows = this.dataState.rows;
450
+ this.dataService.columns = this.dataState.columns;
451
+ this.dataService.updateRowsAndCols();
452
+ }
453
+ updateHeaders(axes, tree, path) {
454
+ // Action to determine expand/collapse state
455
+ const action = {
456
+ type: HEADERS_ACTION.toggle,
457
+ payload: path
458
+ };
459
+ // The `headersReducer` method is responsible for udpating
460
+ // the expanded state based on the toggle action (expand/collapse)
461
+ const newHeaders = headersReducer(this[axes].slice(), Object.assign(Object.assign({}, action), { tree }));
462
+ // Update axes and reload data
463
+ this[axes] = newHeaders;
464
+ this.loadData();
465
+ }
466
+ ;
467
+ }
468
+ PivotBaseBindingDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: PivotBaseBindingDirective, deps: [{ token: PivotGridDataService }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
469
+ PivotBaseBindingDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: PivotBaseBindingDirective, selector: "kendo-base-binding-directive", inputs: { columnAxes: "columnAxes", rowAxes: "rowAxes", measureAxes: "measureAxes" }, ngImport: i0 });
470
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: PivotBaseBindingDirective, decorators: [{
471
+ type: Directive,
472
+ args: [{
473
+ selector: 'kendo-base-binding-directive'
474
+ }]
475
+ }], ctorParameters: function () { return [{ type: PivotGridDataService }, { type: i0.NgZone }]; }, propDecorators: { columnAxes: [{
476
+ type: Input
477
+ }], rowAxes: [{
478
+ type: Input
479
+ }], measureAxes: [{
480
+ type: Input
481
+ }] } });
482
+
483
+ const dataField = 'aggregate';
484
+ const columnsData = 'columns';
485
+ const bindingFields = { dataField, columnsData };
486
+ const stringSeparator = '&';
487
+ /**
488
+ * A directive which binds the PivotGrid to local data ([see example]({% slug directives_databinding_local_pivotgrid %})).
489
+ */
490
+ class PivotLocalBindingDirective extends PivotBaseBindingDirective {
491
+ constructor(dataService, zone) {
492
+ super(dataService, zone);
493
+ this.createAxisSettings = (key) => (Object.assign({ key }, this.dimensions[key]));
494
+ }
495
+ ngOnChanges(changes) {
496
+ if (anyChanged(['data', 'dimensions', 'columnAxes', 'rowAxes', 'measureAxes', 'measures'], changes)) {
497
+ this.loadData();
498
+ }
499
+ }
500
+ loadData() {
501
+ const rootColumnAxes = this.getRootAxes(this.columnAxes);
502
+ const rootRowAxes = this.getRootAxes(this.rowAxes);
503
+ const columnSettings = rootColumnAxes.split(stringSeparator).map(this.createAxisSettings);
504
+ const rowSettings = rootRowAxes.split(stringSeparator).map(this.createAxisSettings);
505
+ const measuresSettings = this.measureAxes.map(m => this.measures.find(meas => String(meas.name) === String(m.name))).filter(Boolean);
506
+ const dataTree = createDataTree(this.data, rowSettings, columnSettings, measuresSettings, bindingFields);
507
+ this.dataState = createLocalDataState({
508
+ dataTree,
509
+ rowSettings,
510
+ columnSettings,
511
+ rowAxes: this.rowAxes,
512
+ columnAxes: this.columnAxes,
513
+ measures: measuresSettings,
514
+ sort: [],
515
+ fields: bindingFields
516
+ });
517
+ this.updateDataServiceFields();
518
+ }
519
+ getRootAxes(axes) {
520
+ return Array.from(rootFields(axes).keys()).join(stringSeparator);
521
+ }
522
+ }
523
+ PivotLocalBindingDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: PivotLocalBindingDirective, deps: [{ token: PivotGridDataService }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
524
+ PivotLocalBindingDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: PivotLocalBindingDirective, selector: "[kendoPivotLocalBinding]", inputs: { data: ["kendoPivotLocalBinding", "data"], dimensions: "dimensions", measures: "measures" }, exportAs: ["kendoPivotLocalBinding"], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
525
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: PivotLocalBindingDirective, decorators: [{
526
+ type: Directive,
527
+ args: [{
528
+ selector: '[kendoPivotLocalBinding]',
529
+ exportAs: 'kendoPivotLocalBinding'
530
+ }]
531
+ }], ctorParameters: function () { return [{ type: PivotGridDataService }, { type: i0.NgZone }]; }, propDecorators: { data: [{
532
+ type: Input,
533
+ args: ['kendoPivotLocalBinding']
534
+ }], dimensions: [{
535
+ type: Input
536
+ }], measures: [{
537
+ type: Input
538
+ }] } });
539
+
540
+ /**
541
+ * A directive which binds the PivotGrid to data using an Online Analytical Processing (OLAP) service ([see example]({% slug directives_databinding_remote_pivotgrid %})).
542
+ */
543
+ class PivotOLAPBindingDirective extends PivotBaseBindingDirective {
544
+ constructor(dataService, zone) {
545
+ super(dataService, zone);
546
+ }
547
+ ngOnChanges(changes) {
548
+ if (anyChanged(['url', 'cube', 'catalog', 'columnAxes', 'rowAxes', 'measureAxes'], changes)) {
549
+ this.loadData();
550
+ }
551
+ }
552
+ loadData() {
553
+ this.dataService.loading.next(true);
554
+ const options = {
555
+ connection: {
556
+ catalog: this.catalog,
557
+ cube: this.cube
558
+ },
559
+ columnAxes: this.columnAxes,
560
+ rowAxes: this.rowAxes,
561
+ measureAxes: this.measureAxes
562
+ };
563
+ fetchData({ url: this.url }, JSON.parse(JSON.stringify(options)))
564
+ .then(createDataState)
565
+ .then(newDataState => {
566
+ this.dataState = newDataState;
567
+ this.updateDataServiceFields();
568
+ this.dataService.loading.next(false);
569
+ });
570
+ }
571
+ }
572
+ PivotOLAPBindingDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: PivotOLAPBindingDirective, deps: [{ token: PivotGridDataService }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
573
+ PivotOLAPBindingDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: PivotOLAPBindingDirective, selector: "[kendoPivotOLAPBinding]", inputs: { url: "url", cube: "cube", catalog: "catalog" }, exportAs: ["kendoPivotOLAPBinding"], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
574
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: PivotOLAPBindingDirective, decorators: [{
575
+ type: Directive,
576
+ args: [{
577
+ selector: '[kendoPivotOLAPBinding]',
578
+ exportAs: 'kendoPivotOLAPBinding'
579
+ }]
580
+ }], ctorParameters: function () { return [{ type: PivotGridDataService }, { type: i0.NgZone }]; }, propDecorators: { url: [{
581
+ type: Input
582
+ }], cube: [{
583
+ type: Input
584
+ }], catalog: [{
585
+ type: Input
586
+ }] } });
587
+
588
+ const IMPORTED_MODULES = [
589
+ CommonModule,
590
+ EventsModule,
591
+ IndicatorsModule
592
+ ];
593
+ const DECLARATIONS = [
594
+ PivotGridComponent,
595
+ PivotGridTableComponent,
596
+ PivotGridCellDirective,
597
+ PivotLocalBindingDirective,
598
+ PivotOLAPBindingDirective
599
+ ];
600
+ /**
601
+ * Sample module
602
+ */
603
+ class PivotGridModule {
604
+ }
605
+ PivotGridModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: PivotGridModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
606
+ PivotGridModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: PivotGridModule, declarations: [PivotGridComponent,
607
+ PivotGridTableComponent,
608
+ PivotGridCellDirective,
609
+ PivotLocalBindingDirective,
610
+ PivotOLAPBindingDirective], imports: [CommonModule,
611
+ EventsModule,
612
+ IndicatorsModule], exports: [PivotGridComponent,
613
+ PivotGridTableComponent,
614
+ PivotGridCellDirective,
615
+ PivotLocalBindingDirective,
616
+ PivotOLAPBindingDirective] });
617
+ PivotGridModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: PivotGridModule, providers: [{
618
+ provide: L10N_PREFIX,
619
+ useValue: 'kendo.pivotgrid'
620
+ }], imports: [[...IMPORTED_MODULES]] });
621
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: PivotGridModule, decorators: [{
622
+ type: NgModule,
623
+ args: [{
624
+ imports: [...IMPORTED_MODULES],
625
+ declarations: [...DECLARATIONS],
626
+ exports: [...DECLARATIONS],
627
+ providers: [{
628
+ provide: L10N_PREFIX,
629
+ useValue: 'kendo.pivotgrid'
630
+ }]
631
+ }]
632
+ }] });
633
+
634
+ /**
635
+ * Generated bundle index. Do not edit.
636
+ */
637
+
638
+ export { PivotGridCellDirective, PivotGridComponent, PivotGridModule, PivotGridTableComponent, PivotLocalBindingDirective, PivotOLAPBindingDirective };
639
+
@@ -0,0 +1,9 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ /**
6
+ * Generated bundle index. Do not edit.
7
+ */
8
+ /// <amd-module name="@progress/kendo-angular-pivotgrid" />
9
+ export * from './main';
package/main.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ export { PivotGridComponent } from './pivotgrid.component';
6
+ export { PivotGridModule } from './pivotgrid.module';
7
+ export { PivotGridCellDirective } from './rendering/pivotgrid-cell.directive';
8
+ export { PivotGridTableComponent } from './rendering/pivotgrid-table.component';
9
+ export { PivotLocalBindingDirective } from './data-binding/local-binding.directive';
10
+ export { PivotOLAPBindingDirective } from './data-binding/olap-binding.directive';
11
+ export { Dimension, Measure, PivotGridAxis, Aggregate, PivotGridField, averageAggregate, maxAggregate, minAggregate, sumAggregate } from '@progress/kendo-pivotgrid-common';
@@ -0,0 +1,16 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ /**
6
+ * @hidden
7
+ */
8
+ export declare type ExpandedStateAction = 'expand' | 'collapse';
9
+ /**
10
+ * @hidden
11
+ */
12
+ export declare type ExpandedStateChangeEvent = {
13
+ action: ExpandedStateAction;
14
+ cell: any;
15
+ tableType: string;
16
+ };