@progress/kendo-angular-grid 13.0.0-develop.13 → 13.0.0-develop.15

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.
@@ -0,0 +1,58 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2023 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ /**
6
+ * Represents the available cell selection aggregates.
7
+ */
8
+ export interface SelectionAggregates {
9
+ /**
10
+ * The sum of all numbers in all selected cells bound to numeric fields.
11
+ * Other selected cells that represent different data types do not affect the value.
12
+ */
13
+ sum?: number;
14
+ /**
15
+ * The smallest number in all selected cells bound to numeric fields.
16
+ * Other selected cells that represent different data types do not affect the value.
17
+ */
18
+ min?: number;
19
+ /**
20
+ * The greatest number in all selected cells bound to numeric fields.
21
+ * Other selected cells that represent different data types do not affect the value.
22
+ */
23
+ max?: number;
24
+ /**
25
+ * The average of all numbers in all selected cells bound to numeric fields.
26
+ * Other selected cells that represent different data types do not affect the value.
27
+ */
28
+ average?: number;
29
+ /**
30
+ * The total number of all selected cells.
31
+ */
32
+ count?: number;
33
+ /**
34
+ * The total number of selected cells bound to a `true` boolean value.
35
+ * Other selected cells that represent different data types do not affect the value.
36
+ */
37
+ isTrue?: number;
38
+ /**
39
+ * The total number of selected cells bound to a `false` boolean value.
40
+ * Other selected cells that represent different data types do not affect the value
41
+ */
42
+ isFalse?: number;
43
+ /**
44
+ * The earliest date in all selected cells bound to `Date` fields.
45
+ * Other selected cells that represent different data types do not affect the value.
46
+ */
47
+ earliest?: Date;
48
+ /**
49
+ * The latest date in all selected cells bound to `Date` fields.
50
+ * Other selected cells that represent different data types do not affect the value.
51
+ */
52
+ latest?: Date;
53
+ }
54
+ /**
55
+ * Represents the available selection aggregate calculations.
56
+ * Use in combination with [cellAggregates]({% slug api_grid_selectablesettings %}) to determine which aggregates will be calculated.
57
+ */
58
+ export declare type SelectionAggregate = 'sum' | 'min' | 'max' | 'average' | 'count' | 'earliest' | 'latest' | 'isTrue' | 'isFalse';
@@ -0,0 +1,19 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2023 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ import { TemplateRef } from '@angular/core';
6
+ import * as i0 from "@angular/core";
7
+ /**
8
+ * Represents the status bar template of the Grid. Allows you to visualize the aggregates using custom rendering inside the template.
9
+ * The template context has the following field:
10
+ * - `aggregates`—The [SelectionAggregates]({% slug api_grid_selectionaggregates %}) object that contains all calculated aggregates.
11
+ * Use the Angular [ngFor](link:site.data.urls.angular['ngfor']) structural directive combined with the [KeyValuePipe](https://angular.io/api/common/KeyValuePipe)
12
+ * to loop through the aggregates as key-value pairs.
13
+ */
14
+ export declare class StatusBarTemplateDirective {
15
+ templateRef: TemplateRef<any>;
16
+ constructor(templateRef: TemplateRef<any>);
17
+ static ɵfac: i0.ɵɵFactoryDeclaration<StatusBarTemplateDirective, never>;
18
+ static ɵdir: i0.ɵɵDirectiveDeclaration<StatusBarTemplateDirective, "[kendoGridStatusBarTemplate]", never, {}, {}, never>;
19
+ }
@@ -0,0 +1,53 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2023 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ import { OnDestroy, OnInit } from '@angular/core';
6
+ import { ContextService } from '../common/provider.service';
7
+ import { SelectionService } from '../selection/selection.service';
8
+ import { CellSelectionService } from '../selection/cell-selection.service';
9
+ import { SelectionAggregates } from './aggregate-types';
10
+ import { StatusBarTemplateDirective } from './status-bar-template.directive';
11
+ import { LocalDataChangesService } from '../editing/local-data-changes.service';
12
+ import { SelectableSettings } from '../selection/types';
13
+ import { ColumnInfoService } from '../common/column-info.service';
14
+ import * as i0 from "@angular/core";
15
+ interface GroupedAggregates {
16
+ dates?: Array<any>;
17
+ numbers?: Array<number>;
18
+ booleans?: Array<boolean>;
19
+ }
20
+ /**
21
+ * @hidden
22
+ */
23
+ export declare class StatusBarComponent implements OnInit, OnDestroy {
24
+ private ctx;
25
+ private selectionService;
26
+ private dataChanges;
27
+ private columnInfoService;
28
+ private cellSelectionService;
29
+ hostClasses: boolean;
30
+ get isStatusBarTemplate(): string;
31
+ selectableSettings: SelectableSettings | boolean;
32
+ statusBarTemplate: StatusBarTemplateDirective;
33
+ groupedAggregates: GroupedAggregates;
34
+ aggregates: SelectionAggregates;
35
+ private data;
36
+ private subs;
37
+ private selectedItems;
38
+ private selectService;
39
+ constructor(ctx: ContextService, selectionService: SelectionService, dataChanges: LocalDataChangesService, columnInfoService: ColumnInfoService, cellSelectionService: CellSelectionService);
40
+ ngOnInit(): void;
41
+ ngOnDestroy(): void;
42
+ private onSelectionChange;
43
+ private handleAggregateChanges;
44
+ private groupAggregates;
45
+ private calculateAggregates;
46
+ private handleSelectedItems;
47
+ private isAggregateIncluded;
48
+ private nullifyAggregates;
49
+ private get isRowSelection();
50
+ static ɵfac: i0.ɵɵFactoryDeclaration<StatusBarComponent, never>;
51
+ static ɵcmp: i0.ɵɵComponentDeclaration<StatusBarComponent, "kendo-grid-status-bar", never, { "selectableSettings": "selectableSettings"; "statusBarTemplate": "statusBarTemplate"; }, {}, never, never>;
52
+ }
53
+ export {};
@@ -0,0 +1,6 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2023 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ ;
6
+ export {};
@@ -0,0 +1,26 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2023 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ import { Directive, TemplateRef } from '@angular/core';
6
+ import * as i0 from "@angular/core";
7
+ /**
8
+ * Represents the status bar template of the Grid. Allows you to visualize the aggregates using custom rendering inside the template.
9
+ * The template context has the following field:
10
+ * - `aggregates`&mdash;The [SelectionAggregates]({% slug api_grid_selectionaggregates %}) object that contains all calculated aggregates.
11
+ * Use the Angular [ngFor](link:site.data.urls.angular['ngfor']) structural directive combined with the [KeyValuePipe](https://angular.io/api/common/KeyValuePipe)
12
+ * to loop through the aggregates as key-value pairs.
13
+ */
14
+ export class StatusBarTemplateDirective {
15
+ constructor(templateRef) {
16
+ this.templateRef = templateRef;
17
+ }
18
+ }
19
+ StatusBarTemplateDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: StatusBarTemplateDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
20
+ StatusBarTemplateDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.12", type: StatusBarTemplateDirective, selector: "[kendoGridStatusBarTemplate]", ngImport: i0 });
21
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: StatusBarTemplateDirective, decorators: [{
22
+ type: Directive,
23
+ args: [{
24
+ selector: '[kendoGridStatusBarTemplate]'
25
+ }]
26
+ }], ctorParameters: function () { return [{ type: i0.TemplateRef }]; } });
@@ -0,0 +1,236 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2023 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ /* eslint-disable @typescript-eslint/no-explicit-any */
6
+ import { Component, HostBinding, Input } from '@angular/core';
7
+ import { Subscription } from 'rxjs';
8
+ import { ContextService } from '../common/provider.service';
9
+ import { SelectionService } from '../selection/selection.service';
10
+ import { CellSelectionService } from '../selection/cell-selection.service';
11
+ import { StatusBarTemplateDirective } from './status-bar-template.directive';
12
+ import { LocalDataChangesService } from '../editing/local-data-changes.service';
13
+ import { ColumnInfoService } from '../common/column-info.service';
14
+ import * as i0 from "@angular/core";
15
+ import * as i1 from "../common/provider.service";
16
+ import * as i2 from "../selection/selection.service";
17
+ import * as i3 from "../editing/local-data-changes.service";
18
+ import * as i4 from "../common/column-info.service";
19
+ import * as i5 from "../selection/cell-selection.service";
20
+ import * as i6 from "@angular/common";
21
+ ;
22
+ /**
23
+ * @hidden
24
+ */
25
+ export class StatusBarComponent {
26
+ constructor(ctx, selectionService, dataChanges, columnInfoService, cellSelectionService) {
27
+ this.ctx = ctx;
28
+ this.selectionService = selectionService;
29
+ this.dataChanges = dataChanges;
30
+ this.columnInfoService = columnInfoService;
31
+ this.cellSelectionService = cellSelectionService;
32
+ this.hostClasses = true;
33
+ this.groupedAggregates = { dates: [], numbers: [], booleans: [] };
34
+ this.aggregates = {
35
+ sum: null,
36
+ average: null,
37
+ min: null,
38
+ max: null,
39
+ count: null,
40
+ isTrue: null,
41
+ isFalse: null,
42
+ earliest: null,
43
+ latest: null
44
+ };
45
+ this.subs = new Subscription();
46
+ this.selectedItems = [];
47
+ }
48
+ get isStatusBarTemplate() {
49
+ return this.statusBarTemplate ? '' : 'none';
50
+ }
51
+ ngOnInit() {
52
+ if (this.selectableSettings.cellAggregates) {
53
+ this.data = this.dataChanges.data ? this.dataChanges.data : this.ctx.grid.data;
54
+ this.selectService = this.isRowSelection ? this.selectionService : this.cellSelectionService;
55
+ if (this.isAggregateIncluded('count')) {
56
+ this.aggregates['count'] = 0;
57
+ }
58
+ const selectionDirective = this.ctx.grid.selectionDirective;
59
+ if (selectionDirective && !this.isRowSelection) {
60
+ this.selectedItems = selectionDirective.selectedKeys;
61
+ }
62
+ this.subs.add(this.selectService.aggregateChanges.subscribe((selectionArgs) => this.onSelectionChange(selectionArgs)));
63
+ }
64
+ }
65
+ ngOnDestroy() {
66
+ this.subs.unsubscribe();
67
+ }
68
+ onSelectionChange(selectionArgs) {
69
+ this.handleSelectedItems(selectionArgs);
70
+ this.nullifyAggregates();
71
+ this.handleAggregateChanges();
72
+ this.selectService.aggregates = this.aggregates;
73
+ }
74
+ handleAggregateChanges() {
75
+ const lockedColumns = this.columnInfoService.lockedLeafColumns.toArray();
76
+ const nonLockedColumns = this.columnInfoService.nonLockedLeafColumns.toArray();
77
+ const selectedItemsLength = this.selectedItems.length;
78
+ const columns = [...lockedColumns, ...nonLockedColumns];
79
+ const fields = columns.map(col => col.field);
80
+ if (this.isAggregateIncluded('count')) {
81
+ this.aggregates['count'] = this.isRowSelection ? (selectedItemsLength * columns.length) : selectedItemsLength;
82
+ }
83
+ this.selectedItems.forEach((item) => {
84
+ if (this.isRowSelection) {
85
+ fields.forEach((field) => {
86
+ const cellValue = item.dataItem;
87
+ if (cellValue && cellValue.hasOwnProperty(field)) {
88
+ const cellValue = item.dataItem[field];
89
+ this.groupAggregates(cellValue);
90
+ }
91
+ });
92
+ }
93
+ else if (this.selectService.options.cell) {
94
+ const itemKey = this.data[item.itemKey];
95
+ const field = fields[item.columnKey];
96
+ if (itemKey && itemKey.hasOwnProperty(field)) {
97
+ const cellValue = itemKey[fields[item.columnKey]];
98
+ this.groupAggregates(cellValue);
99
+ }
100
+ }
101
+ });
102
+ this.calculateAggregates();
103
+ }
104
+ groupAggregates(aggregate) {
105
+ if (typeof aggregate === 'number') {
106
+ this.groupedAggregates.numbers.push(aggregate);
107
+ }
108
+ else if (typeof aggregate === 'boolean') {
109
+ this.groupedAggregates.booleans.push(aggregate);
110
+ }
111
+ else if (aggregate instanceof Date) {
112
+ this.groupedAggregates.dates.push(aggregate);
113
+ }
114
+ }
115
+ calculateAggregates() {
116
+ if (this.groupedAggregates.numbers.length > 0) {
117
+ if (this.isAggregateIncluded('min')) {
118
+ this.aggregates['min'] = Math.min(...this.groupedAggregates.numbers);
119
+ }
120
+ if (this.isAggregateIncluded('max')) {
121
+ this.aggregates['max'] = Math.max(...this.groupedAggregates.numbers);
122
+ }
123
+ if (this.isAggregateIncluded('sum')) {
124
+ this.aggregates['sum'] = this.groupedAggregates.numbers.reduce((acc, curr) => acc += curr, 0);
125
+ }
126
+ if (this.isAggregateIncluded('average')) {
127
+ this.aggregates['average'] = this.aggregates['sum'] / this.groupedAggregates.numbers.length;
128
+ }
129
+ }
130
+ if (this.groupedAggregates.booleans.length > 0) {
131
+ if (this.isAggregateIncluded('isTrue')) {
132
+ const isTrueCount = this.groupedAggregates.booleans.filter(bool => bool).length;
133
+ this.aggregates['isTrue'] = isTrueCount > 0 ? isTrueCount : null;
134
+ }
135
+ if (this.isAggregateIncluded('isFalse')) {
136
+ const isFalseCount = this.groupedAggregates.booleans.length - this.aggregates['isTrue'];
137
+ this.aggregates['isFalse'] = isFalseCount > 0 ? isFalseCount : null;
138
+ }
139
+ }
140
+ if (this.groupedAggregates.dates.length > 0) {
141
+ if (this.isAggregateIncluded('earliest')) {
142
+ this.aggregates['earliest'] = new Date(Math.min(...this.groupedAggregates.dates));
143
+ }
144
+ if (this.isAggregateIncluded('latest')) {
145
+ this.aggregates['latest'] = new Date(Math.max(...this.groupedAggregates.dates));
146
+ }
147
+ }
148
+ }
149
+ handleSelectedItems(selectionArgs) {
150
+ const rowOrCellSelect = `${this.isRowSelection ? 'selectedRows' : 'selectedCells'}`;
151
+ const rowOrCellDeselect = `${this.isRowSelection ? 'deselectedRows' : 'deselectedCells'}`;
152
+ const selectedItems = selectionArgs[rowOrCellSelect];
153
+ const deselectedItems = selectionArgs[rowOrCellDeselect];
154
+ if (!this.isRowSelection) {
155
+ // Needed when we have column groups with cell selection, the deselected items are duplicated
156
+ deselectedItems.forEach((item, index) => {
157
+ if (index + 1 < deselectedItems.length) {
158
+ if (item.itemKey === deselectedItems[index + 1].itemKey
159
+ && item.columnKey === deselectedItems[index + 1].columnKey) {
160
+ deselectedItems.splice(index, 1);
161
+ }
162
+ }
163
+ });
164
+ }
165
+ if (selectedItems.length > 0) {
166
+ selectedItems.forEach((item) => {
167
+ this.selectedItems = [...this.selectedItems, item];
168
+ });
169
+ }
170
+ if (deselectedItems.length > 0) {
171
+ if (this.isRowSelection) {
172
+ deselectedItems.forEach((row) => {
173
+ this.selectedItems = this.selectedItems.filter((elem) => elem.dataItem !== row.dataItem);
174
+ });
175
+ }
176
+ else {
177
+ deselectedItems.forEach((cell) => {
178
+ const index = this.selectedItems.findIndex((elem) => elem.itemKey === cell.itemKey && elem.columnKey === cell.columnKey);
179
+ this.selectedItems.splice(index, 1);
180
+ });
181
+ }
182
+ }
183
+ }
184
+ isAggregateIncluded(aggregate) {
185
+ const { cellAggregates } = this.selectService.options;
186
+ if (typeof cellAggregates !== 'boolean') {
187
+ return cellAggregates.includes(aggregate);
188
+ }
189
+ return true;
190
+ }
191
+ nullifyAggregates() {
192
+ this.groupedAggregates = { dates: [], numbers: [], booleans: [] };
193
+ this.aggregates['count'] = null;
194
+ this.aggregates['sum'] = this.aggregates['average'] = null;
195
+ this.aggregates['max'] = this.aggregates['min'] = null;
196
+ this.aggregates['isFalse'] = this.aggregates['isTrue'] = null;
197
+ this.aggregates['earliest'] = this.aggregates['latest'] = null;
198
+ }
199
+ get isRowSelection() {
200
+ return typeof this.selectableSettings === 'boolean' || !this.selectableSettings.cell;
201
+ }
202
+ }
203
+ StatusBarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: StatusBarComponent, deps: [{ token: i1.ContextService }, { token: i2.SelectionService }, { token: i3.LocalDataChangesService }, { token: i4.ColumnInfoService }, { token: i5.CellSelectionService }], target: i0.ɵɵFactoryTarget.Component });
204
+ StatusBarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: StatusBarComponent, selector: "kendo-grid-status-bar", inputs: { selectableSettings: "selectableSettings", statusBarTemplate: "statusBarTemplate" }, host: { properties: { "class.k-selection-aggregates": "this.hostClasses", "class.k-grid-selection-aggregates": "this.hostClasses", "style.display": "this.isStatusBarTemplate" } }, ngImport: i0, template: `
205
+ <ng-template
206
+ *ngIf="statusBarTemplate"
207
+ [ngTemplateOutlet]="statusBarTemplate?.templateRef"
208
+ [ngTemplateOutletContext]="{ aggregates: aggregates }">
209
+ </ng-template>
210
+ `, isInline: true, directives: [{ type: i6.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i6.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }] });
211
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: StatusBarComponent, decorators: [{
212
+ type: Component,
213
+ args: [{
214
+ selector: 'kendo-grid-status-bar',
215
+ template: `
216
+ <ng-template
217
+ *ngIf="statusBarTemplate"
218
+ [ngTemplateOutlet]="statusBarTemplate?.templateRef"
219
+ [ngTemplateOutletContext]="{ aggregates: aggregates }">
220
+ </ng-template>
221
+ `
222
+ }]
223
+ }], ctorParameters: function () { return [{ type: i1.ContextService }, { type: i2.SelectionService }, { type: i3.LocalDataChangesService }, { type: i4.ColumnInfoService }, { type: i5.CellSelectionService }]; }, propDecorators: { hostClasses: [{
224
+ type: HostBinding,
225
+ args: ['class.k-selection-aggregates']
226
+ }, {
227
+ type: HostBinding,
228
+ args: ['class.k-grid-selection-aggregates']
229
+ }], isStatusBarTemplate: [{
230
+ type: HostBinding,
231
+ args: ['style.display']
232
+ }], selectableSettings: [{
233
+ type: Input
234
+ }], statusBarTemplate: [{
235
+ type: Input
236
+ }] } });