@progress/kendo-angular-grid 19.0.0-develop.32 → 19.0.0-develop.33

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,425 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2025 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ import { Component, ElementRef, EventEmitter, HostBinding, Output, Input, HostListener, ViewChildren, QueryList, NgZone } from '@angular/core';
6
+ import { NgFor, NgIf } from '@angular/common';
7
+ import { IconWrapperComponent } from '@progress/kendo-angular-icons';
8
+ import { chevronUpIcon, chevronDownIcon, xCircleIcon, plusCircleIcon, xIcon } from '@progress/kendo-svg-icons';
9
+ import { KENDO_BUTTON } from '@progress/kendo-angular-buttons';
10
+ import { take } from 'rxjs/operators';
11
+ import { isPresent } from '@progress/kendo-angular-common';
12
+ import * as i0 from "@angular/core";
13
+ import * as i1 from "@progress/kendo-angular-buttons";
14
+ /**
15
+ * @hidden
16
+ */
17
+ export class GroupToolbarToolComponent {
18
+ element;
19
+ ngZone;
20
+ hostClass = true;
21
+ get lgClass() {
22
+ return this.adaptive;
23
+ }
24
+ get mdClass() {
25
+ return !this.adaptive;
26
+ }
27
+ onEscKeyDown(event) {
28
+ event.preventDefault();
29
+ this.hostButton?.focus(event);
30
+ this.close.emit();
31
+ }
32
+ set groupItems(items) {
33
+ this._groupItems = items;
34
+ if (items?.first && (!isPresent(this.currentFocusedItemIndex) || this.currentFocusedItemIndex >= items.length || this.currentFocusedItemIndex < 0)) {
35
+ this.ngZone.onStable.pipe(take(1)).subscribe(() => {
36
+ this.currentFocusedItemIndex = 0;
37
+ this.groupItems.first.nativeElement.focus();
38
+ });
39
+ return;
40
+ }
41
+ if (items?.first) {
42
+ items.get(this.currentFocusedItemIndex).nativeElement.focus();
43
+ }
44
+ }
45
+ get groupItems() {
46
+ return this._groupItems;
47
+ }
48
+ _groupItems;
49
+ adaptive = false;
50
+ close = new EventEmitter();
51
+ groupClear = new EventEmitter();
52
+ currentFocusedItemIndex;
53
+ group = new Array();
54
+ columns = [];
55
+ iconSize = 'medium';
56
+ upIcon = chevronUpIcon;
57
+ downIcon = chevronDownIcon;
58
+ removeIcon = xCircleIcon;
59
+ addIcon = plusCircleIcon;
60
+ clearIcon = xIcon;
61
+ _ctx;
62
+ set ctx(ctx) {
63
+ if (!ctx || !ctx.grid) {
64
+ return;
65
+ }
66
+ this._ctx = ctx;
67
+ this.group = ctx.grid.group;
68
+ this.subscription = ctx.grid.groupChange.subscribe((group) => {
69
+ this.group = group;
70
+ this.updateGroupedColumns();
71
+ });
72
+ this.ngZone.onStable.pipe(take(1)).subscribe(() => {
73
+ this.updateGroupedColumns();
74
+ });
75
+ }
76
+ get ctx() {
77
+ return this._ctx;
78
+ }
79
+ groupedColumns = [];
80
+ ungroupedColumns = [];
81
+ subscription;
82
+ hostButton;
83
+ constructor(element, ngZone) {
84
+ this.element = element;
85
+ this.ngZone = ngZone;
86
+ }
87
+ ngOnInit() {
88
+ this.iconSize = this.adaptive ? 'large' : 'medium';
89
+ }
90
+ ngOnDestroy() {
91
+ if (this.subscription) {
92
+ this.subscription.unsubscribe();
93
+ }
94
+ }
95
+ addGroup(column, ev) {
96
+ ev.stopImmediatePropagation();
97
+ const index = this.group.length;
98
+ const groups = this.group.filter(x => x.field !== column?.field);
99
+ if (groups.length || this.group.length === 0) {
100
+ this.group = [...groups.slice(0, index), { field: column?.field }, ...groups.slice(index)];
101
+ this.ctx.grid.groupChange.emit(this.group);
102
+ this.updateGroupedColumns();
103
+ this.ngZone.onStable.pipe(take(1)).subscribe(() => {
104
+ const newIndex = this.groupedColumns.length - 1;
105
+ const newItem = this.groupItems.get(newIndex);
106
+ if (newItem) {
107
+ this.currentFocusedItemIndex = (this.groupedColumns?.length || 0) + newIndex;
108
+ newItem.nativeElement.focus();
109
+ }
110
+ });
111
+ }
112
+ }
113
+ removeGroup(column, ev) {
114
+ ev.stopImmediatePropagation();
115
+ this.group = this.group.filter(x => x.field !== column?.field);
116
+ this.ctx.grid.groupChange.emit(this.group);
117
+ this.updateGroupedColumns();
118
+ this.ngZone.onStable.pipe(take(1)).subscribe(() => {
119
+ const newIndex = this.ungroupedColumns.findIndex(ungroupedColumn => ungroupedColumn?.field === column?.field);
120
+ const newItem = this.groupItems.get(newIndex + this.groupedColumns.length);
121
+ if (newItem) {
122
+ newItem.nativeElement.focus();
123
+ }
124
+ });
125
+ }
126
+ moveGroupUp(column, ev) {
127
+ ev.stopImmediatePropagation();
128
+ const index = this.group.findIndex(x => x.field === column?.field);
129
+ if (index > 0) {
130
+ const groupToMove = this.group[index];
131
+ this.group.splice(index, 1);
132
+ this.group.splice(index - 1, 0, groupToMove);
133
+ this.ctx.grid.groupChange.emit(this.group);
134
+ this.updateGroupedColumns();
135
+ this.ngZone.onStable.pipe(take(1)).subscribe(() => {
136
+ const newItem = this.groupItems.get(index - 1);
137
+ if (newItem) {
138
+ newItem.nativeElement.focus();
139
+ this.currentFocusedItemIndex = index - 1;
140
+ }
141
+ });
142
+ }
143
+ }
144
+ moveGroupDown(column, ev) {
145
+ ev.stopImmediatePropagation();
146
+ const index = this.group.findIndex(x => x.field === column?.field);
147
+ if (index < this.group.length - 1) {
148
+ const groupToMove = this.group[index];
149
+ this.group.splice(index, 1);
150
+ this.group.splice(index + 1, 0, groupToMove);
151
+ this.ctx.grid.groupChange.emit(this.group);
152
+ this.updateGroupedColumns();
153
+ this.ngZone.onStable.pipe(take(1)).subscribe(() => {
154
+ const newItem = this.groupItems.get(index + 1);
155
+ if (newItem) {
156
+ newItem.nativeElement.focus();
157
+ this.currentFocusedItemIndex = index + 1;
158
+ }
159
+ });
160
+ }
161
+ }
162
+ clear() {
163
+ this.group = [];
164
+ this.ctx.grid.groupChange.emit(this.group);
165
+ this.groupClear.emit(this.group);
166
+ }
167
+ getColumnComponent(column) {
168
+ return column;
169
+ }
170
+ onItemFocus(groupIndex, index) {
171
+ const currentIndex = (typeof groupIndex === 'number' ? groupIndex : this.groupedColumns?.length || 0) + index;
172
+ this.currentFocusedItemIndex = currentIndex;
173
+ }
174
+ handleGroupedKeydown(column, index, ev) {
175
+ if (ev.code === 'Enter' || ev.code === 'Backspace' || ev.code === 'Delete') {
176
+ this.removeGroup(column, ev);
177
+ }
178
+ else if (ev.code === 'ArrowUp' && ev.shiftKey) {
179
+ this.moveGroupUp(column, ev);
180
+ }
181
+ else if (ev.code === 'ArrowDown' && ev.shiftKey) {
182
+ this.moveGroupDown(column, ev);
183
+ }
184
+ else if (ev.code === 'ArrowUp') {
185
+ this.navigateToPreviousItem();
186
+ }
187
+ else if (ev.code === 'ArrowDown') {
188
+ this.navigateToNextItem();
189
+ }
190
+ }
191
+ handleUngroupedKeydown(column, index, ev) {
192
+ if (ev.code === 'Enter') {
193
+ this.addGroup(column, ev);
194
+ }
195
+ else if (ev.code === 'ArrowUp') {
196
+ this.navigateToPreviousItem();
197
+ }
198
+ else if (ev.code === 'ArrowDown') {
199
+ this.navigateToNextItem();
200
+ }
201
+ }
202
+ updateGroupedColumns() {
203
+ this.groupedColumns = this.group
204
+ .map(group => this.ctx.grid.columns.find(column => column?.field === group.field))
205
+ .filter(column => !!column);
206
+ this.ungroupedColumns = this.ctx.grid.columns.filter(column => column?.groupable &&
207
+ !this.groupedColumns.some(gc => gc?.field === column?.field));
208
+ }
209
+ navigateToNextItem() {
210
+ if (this.currentFocusedItemIndex < this.groupItems.length - 1) {
211
+ this.currentFocusedItemIndex++;
212
+ this.groupItems.get(this.currentFocusedItemIndex).nativeElement.focus();
213
+ }
214
+ else if (this.currentFocusedItemIndex === this.groupItems.length - 1) {
215
+ this.currentFocusedItemIndex = 0;
216
+ this.groupItems.get(this.currentFocusedItemIndex).nativeElement.focus();
217
+ }
218
+ }
219
+ navigateToPreviousItem() {
220
+ if (this.currentFocusedItemIndex > 0) {
221
+ this.currentFocusedItemIndex--;
222
+ this.groupItems.get(this.currentFocusedItemIndex).nativeElement.focus();
223
+ }
224
+ else if (this.currentFocusedItemIndex === 0) {
225
+ this.currentFocusedItemIndex = this.groupItems.length - 1;
226
+ this.groupItems.get(this.currentFocusedItemIndex).nativeElement.focus();
227
+ }
228
+ }
229
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: GroupToolbarToolComponent, deps: [{ token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
230
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: GroupToolbarToolComponent, isStandalone: true, selector: "kendo-group-toolbar-tool", inputs: { adaptive: "adaptive" }, outputs: { close: "close", groupClear: "groupClear" }, host: { listeners: { "keydown.escape": "onEscKeyDown($event)" }, properties: { "class.k-group-menu": "this.hostClass", "class.k-group-menu-lg": "this.lgClass", "class.k-group-menu-md": "this.mdClass" } }, viewQueries: [{ propertyName: "groupItems", predicate: ["groupItem"], descendants: true, read: ElementRef }], ngImport: i0, template: `
231
+ <div *ngIf="groupedColumns.length" class="k-group-menu-item-wrap">
232
+ <div *ngFor="let column of groupedColumns; let i = index"
233
+ #groupItem
234
+ role="button"
235
+ class="k-group-menu-item"
236
+ tabindex="0"
237
+ (keydown)="handleGroupedKeydown(column, i, $event)"
238
+ (focus)="onItemFocus(i, 0)"
239
+ >
240
+ <span class="k-group-menu-item-actions" *ngIf="groupedColumns.length > 1">
241
+ <span
242
+ class="k-group-menu-item-action k-group-menu-item-up-action"
243
+ (click)="moveGroupUp(column, $event)"
244
+ [attr.aria-disabled]="i === 0"
245
+ [class.k-disabled]="i === 0"
246
+ >
247
+ <kendo-icon-wrapper
248
+ name="arrow-chevron-up"
249
+ [svgIcon]="upIcon"
250
+ [size]="iconSize"
251
+ ></kendo-icon-wrapper>
252
+ </span>
253
+ <span
254
+ class="k-group-menu-item-action k-group-menu-item-down-action"
255
+ (click)="moveGroupDown(column, $event)"
256
+ [attr.aria-disabled]="i === groupedColumns.length - 1"
257
+ [class.k-disabled]="i === groupedColumns.length - 1"
258
+ >
259
+ <kendo-icon-wrapper
260
+ name="arrow-chevron-down"
261
+ [svgIcon]="downIcon"
262
+ [size]="iconSize"
263
+ ></kendo-icon-wrapper>
264
+ </span>
265
+ </span>
266
+ <span class="k-group-item-text">{{column.title || getColumnComponent(column).field}}</span>
267
+ <span class="k-spacer"></span>
268
+ <span class="k-group-menu-item-actions">
269
+ <span class="k-group-menu-item-action k-group-menu-item-remove-action" (click)="removeGroup(column, $event)">
270
+ <kendo-icon-wrapper
271
+ name="x-circle"
272
+ [svgIcon]="removeIcon"
273
+ [size]="iconSize"
274
+ ></kendo-icon-wrapper>
275
+ </span>
276
+ </span>
277
+ </div>
278
+ </div>
279
+
280
+ <div *ngIf="ungroupedColumns.length" class="k-group-menu-item-wrap">
281
+ <div *ngFor="let column of ungroupedColumns; let i = index"
282
+ #groupItem
283
+ role="button"
284
+ class="k-group-menu-item"
285
+ tabindex="0"
286
+ (keydown)="handleUngroupedKeydown(column, i, $event)"
287
+ (focus)="onItemFocus(null, i)"
288
+ >
289
+ <span class="k-group-item-text">{{column.title || getColumnComponent(column).field}}</span>
290
+ <span class="k-spacer"></span>
291
+ <span class="k-group-menu-item-actions">
292
+ <span class="k-group-menu-item-action k-group-menu-item-add-action" (click)="addGroup(column, $event)">
293
+ <kendo-icon-wrapper
294
+ name="plus-circle"
295
+ [svgIcon]="addIcon"
296
+ [size]="iconSize"
297
+ ></kendo-icon-wrapper>
298
+ </span>
299
+ </span>
300
+ </div>
301
+ </div>
302
+
303
+ <div *ngIf="!adaptive" class="k-actions k-actions-stretched k-actions-horizontal k-column-menu-footer">
304
+ <button kendoButton
305
+ [svgIcon]="clearIcon"
306
+ (click)="clear()"
307
+ icon="x"
308
+ >
309
+ {{ctx?.localization.get('groupClearButton')}}
310
+ </button>
311
+ </div>
312
+ `, isInline: true, dependencies: [{ kind: "directive", type: NgFor, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: IconWrapperComponent, selector: "kendo-icon-wrapper", inputs: ["name", "svgIcon", "innerCssClass", "customFontClass", "size"], exportAs: ["kendoIconWrapper"] }, { kind: "component", type: i1.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"] }] });
313
+ }
314
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: GroupToolbarToolComponent, decorators: [{
315
+ type: Component,
316
+ args: [{
317
+ selector: 'kendo-group-toolbar-tool',
318
+ template: `
319
+ <div *ngIf="groupedColumns.length" class="k-group-menu-item-wrap">
320
+ <div *ngFor="let column of groupedColumns; let i = index"
321
+ #groupItem
322
+ role="button"
323
+ class="k-group-menu-item"
324
+ tabindex="0"
325
+ (keydown)="handleGroupedKeydown(column, i, $event)"
326
+ (focus)="onItemFocus(i, 0)"
327
+ >
328
+ <span class="k-group-menu-item-actions" *ngIf="groupedColumns.length > 1">
329
+ <span
330
+ class="k-group-menu-item-action k-group-menu-item-up-action"
331
+ (click)="moveGroupUp(column, $event)"
332
+ [attr.aria-disabled]="i === 0"
333
+ [class.k-disabled]="i === 0"
334
+ >
335
+ <kendo-icon-wrapper
336
+ name="arrow-chevron-up"
337
+ [svgIcon]="upIcon"
338
+ [size]="iconSize"
339
+ ></kendo-icon-wrapper>
340
+ </span>
341
+ <span
342
+ class="k-group-menu-item-action k-group-menu-item-down-action"
343
+ (click)="moveGroupDown(column, $event)"
344
+ [attr.aria-disabled]="i === groupedColumns.length - 1"
345
+ [class.k-disabled]="i === groupedColumns.length - 1"
346
+ >
347
+ <kendo-icon-wrapper
348
+ name="arrow-chevron-down"
349
+ [svgIcon]="downIcon"
350
+ [size]="iconSize"
351
+ ></kendo-icon-wrapper>
352
+ </span>
353
+ </span>
354
+ <span class="k-group-item-text">{{column.title || getColumnComponent(column).field}}</span>
355
+ <span class="k-spacer"></span>
356
+ <span class="k-group-menu-item-actions">
357
+ <span class="k-group-menu-item-action k-group-menu-item-remove-action" (click)="removeGroup(column, $event)">
358
+ <kendo-icon-wrapper
359
+ name="x-circle"
360
+ [svgIcon]="removeIcon"
361
+ [size]="iconSize"
362
+ ></kendo-icon-wrapper>
363
+ </span>
364
+ </span>
365
+ </div>
366
+ </div>
367
+
368
+ <div *ngIf="ungroupedColumns.length" class="k-group-menu-item-wrap">
369
+ <div *ngFor="let column of ungroupedColumns; let i = index"
370
+ #groupItem
371
+ role="button"
372
+ class="k-group-menu-item"
373
+ tabindex="0"
374
+ (keydown)="handleUngroupedKeydown(column, i, $event)"
375
+ (focus)="onItemFocus(null, i)"
376
+ >
377
+ <span class="k-group-item-text">{{column.title || getColumnComponent(column).field}}</span>
378
+ <span class="k-spacer"></span>
379
+ <span class="k-group-menu-item-actions">
380
+ <span class="k-group-menu-item-action k-group-menu-item-add-action" (click)="addGroup(column, $event)">
381
+ <kendo-icon-wrapper
382
+ name="plus-circle"
383
+ [svgIcon]="addIcon"
384
+ [size]="iconSize"
385
+ ></kendo-icon-wrapper>
386
+ </span>
387
+ </span>
388
+ </div>
389
+ </div>
390
+
391
+ <div *ngIf="!adaptive" class="k-actions k-actions-stretched k-actions-horizontal k-column-menu-footer">
392
+ <button kendoButton
393
+ [svgIcon]="clearIcon"
394
+ (click)="clear()"
395
+ icon="x"
396
+ >
397
+ {{ctx?.localization.get('groupClearButton')}}
398
+ </button>
399
+ </div>
400
+ `,
401
+ standalone: true,
402
+ imports: [NgFor, NgIf, IconWrapperComponent, KENDO_BUTTON]
403
+ }]
404
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { hostClass: [{
405
+ type: HostBinding,
406
+ args: ['class.k-group-menu']
407
+ }], lgClass: [{
408
+ type: HostBinding,
409
+ args: ['class.k-group-menu-lg']
410
+ }], mdClass: [{
411
+ type: HostBinding,
412
+ args: ['class.k-group-menu-md']
413
+ }], onEscKeyDown: [{
414
+ type: HostListener,
415
+ args: ['keydown.escape', ['$event']]
416
+ }], groupItems: [{
417
+ type: ViewChildren,
418
+ args: ['groupItem', { read: ElementRef }]
419
+ }], adaptive: [{
420
+ type: Input
421
+ }], close: [{
422
+ type: Output
423
+ }], groupClear: [{
424
+ type: Output
425
+ }] } });