@progress/kendo-angular-grid 18.5.2 → 18.6.0-develop.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,222 @@
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, HostListener, ViewChildren, QueryList, NgZone } from '@angular/core';
6
+ import { NgFor, NgIf } from '@angular/common';
7
+ import { IconWrapperComponent } from '@progress/kendo-angular-icons';
8
+ import { sortAscSmallIcon, sortDescSmallIcon, xIcon } from '@progress/kendo-svg-icons';
9
+ import { isPresent } from '@progress/kendo-angular-common';
10
+ import { KENDO_BUTTON } from '@progress/kendo-angular-buttons';
11
+ import { normalize } from '../../../columns/sort-settings';
12
+ import { take } from 'rxjs/operators';
13
+ import * as i0 from "@angular/core";
14
+ import * as i1 from "@progress/kendo-angular-buttons";
15
+ const directions = initialDirection => initialDirection === "asc" ? ["asc", "desc"] : ["desc", "asc"];
16
+ /**
17
+ * @hidden
18
+ */
19
+ export class SortToolbarToolComponent {
20
+ element;
21
+ ngZone;
22
+ sortItems;
23
+ wrapperClasses = true;
24
+ onEscKeyDown(event) {
25
+ event.preventDefault();
26
+ this.hostButton?.focus(event);
27
+ this.close.emit();
28
+ }
29
+ close = new EventEmitter();
30
+ sortClear = new EventEmitter();
31
+ sort = new Array();
32
+ columns = [];
33
+ sortAscSmallIcon = sortAscSmallIcon;
34
+ sortDescSmallIcon = sortDescSmallIcon;
35
+ clearIcon = xIcon;
36
+ _columnInfoService;
37
+ set columnInfoService(columnInfoService) {
38
+ this._columnInfoService = columnInfoService;
39
+ this.columns = this.columnInfoService.leafNamedColumns.filter(column => column?.sortable);
40
+ }
41
+ get columnInfoService() {
42
+ return this._columnInfoService;
43
+ }
44
+ _ctx;
45
+ set ctx(ctx) {
46
+ this._ctx = ctx;
47
+ this.sort = ctx.grid.sort;
48
+ }
49
+ get ctx() {
50
+ return this._ctx;
51
+ }
52
+ _sortService;
53
+ set sortService(sortService) {
54
+ this._sortService = sortService;
55
+ this.subscription = this._sortService.changes.subscribe(sort => {
56
+ this.sort = sort;
57
+ });
58
+ }
59
+ get sortService() {
60
+ return this._sortService;
61
+ }
62
+ subscription;
63
+ hostButton;
64
+ constructor(element, ngZone) {
65
+ this.element = element;
66
+ this.ngZone = ngZone;
67
+ }
68
+ ngAfterViewInit() {
69
+ this.ngZone.onStable.pipe(take(1)).subscribe(() => {
70
+ this.sortItems?.get(0)?.nativeElement.focus();
71
+ });
72
+ }
73
+ ngOnDestroy() {
74
+ if (this.subscription) {
75
+ this.subscription.unsubscribe();
76
+ }
77
+ }
78
+ toggleSort(column) {
79
+ const field = column?.field;
80
+ if (!field) {
81
+ return;
82
+ }
83
+ const descriptor = this.getDescriptor(column);
84
+ this.sort = descriptor;
85
+ this.sortService.sort(descriptor);
86
+ }
87
+ getColumnComponent(column) {
88
+ return column;
89
+ }
90
+ sortDescriptor(field) {
91
+ return this.sort.find(item => item.field === field) || { field };
92
+ }
93
+ getDescriptor(column) {
94
+ const { allowUnsort, mode, initialDirection } = normalize(this.ctx.grid.sortable, column.sortable);
95
+ const field = column?.field;
96
+ if (!field) {
97
+ return;
98
+ }
99
+ const descriptorT = this.sort.find(item => item.field === field) || { field };
100
+ const [first, second] = directions(initialDirection);
101
+ let dir = first;
102
+ if (descriptorT.dir === first) {
103
+ dir = second;
104
+ }
105
+ else if (descriptorT.dir === second && allowUnsort) {
106
+ dir = undefined;
107
+ }
108
+ const descriptor = { field, dir };
109
+ if (mode === 'single') {
110
+ return [descriptor];
111
+ }
112
+ return [...this.sort.filter(desc => desc.field !== field), descriptor];
113
+ }
114
+ showSortNumbering(column) {
115
+ return this.sort
116
+ && this.sort.filter(({ dir }) => isPresent(dir)).length > 1
117
+ && this.sortOrder(column.field) > 0;
118
+ }
119
+ sortOrder(field) {
120
+ return this.sort
121
+ .filter(({ dir }) => isPresent(dir))
122
+ .findIndex(x => x.field === field)
123
+ + 1;
124
+ }
125
+ clearSorting() {
126
+ if (!this.sort || this.sort.length === 0) {
127
+ return;
128
+ }
129
+ this.sort = [];
130
+ this.sortService.sort([]);
131
+ this.sortClear.emit();
132
+ }
133
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SortToolbarToolComponent, deps: [{ token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
134
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: SortToolbarToolComponent, isStandalone: true, selector: "kendo-sort-toolbar-tool", outputs: { close: "close", sortClear: "sortClear" }, host: { listeners: { "keydown.escape": "onEscKeyDown($event)" }, properties: { "class.k-column-menu": "this.wrapperClasses", "class.k-column-menu-md": "this.wrapperClasses" } }, viewQueries: [{ propertyName: "sortItems", predicate: ["sortItem"], descendants: true, read: ElementRef }], ngImport: i0, template: `
135
+ <div
136
+ class="k-column-menu-item-wrapper"
137
+ [style.max-height.px]="200"
138
+ [style.overflow-x]="'hidden'"
139
+ [style.overflow-y]="'auto'"
140
+ >
141
+ <div *ngFor="let column of columns"
142
+ #sortItem
143
+ role="button"
144
+ class="k-columnmenu-item"
145
+ (click)="toggleSort(column)"
146
+ (keydown.enter)="toggleSort(column)"
147
+ [tabindex]="'0'"
148
+ >
149
+ {{column.title || getColumnComponent(column).field}}
150
+
151
+ <span class="k-columnmenu-indicators">
152
+ <kendo-icon-wrapper
153
+ *ngIf="sortDescriptor(getColumnComponent(column).field).dir"
154
+ name="sort-{{sortDescriptor(getColumnComponent(column).field).dir}}-small"
155
+ [svgIcon]="sortDescriptor(getColumnComponent(column).field).dir === 'asc' ? sortAscSmallIcon : sortDescSmallIcon"
156
+ ></kendo-icon-wrapper>
157
+ <span *ngIf="showSortNumbering(getColumnComponent(column))" class="k-sort-index">{{sortOrder(getColumnComponent(column).field)}}</span>
158
+ </span>
159
+ </div>
160
+ </div>
161
+
162
+ <div class="k-actions k-actions-stretched k-actions-horizontal k-column-menu-footer">
163
+ <button kendoButton [svgIcon]="clearIcon" (click)="clearSorting()" >Clear sorting</button>
164
+ </div>
165
+ `, 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"] }] });
166
+ }
167
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SortToolbarToolComponent, decorators: [{
168
+ type: Component,
169
+ args: [{
170
+ selector: 'kendo-sort-toolbar-tool',
171
+ template: `
172
+ <div
173
+ class="k-column-menu-item-wrapper"
174
+ [style.max-height.px]="200"
175
+ [style.overflow-x]="'hidden'"
176
+ [style.overflow-y]="'auto'"
177
+ >
178
+ <div *ngFor="let column of columns"
179
+ #sortItem
180
+ role="button"
181
+ class="k-columnmenu-item"
182
+ (click)="toggleSort(column)"
183
+ (keydown.enter)="toggleSort(column)"
184
+ [tabindex]="'0'"
185
+ >
186
+ {{column.title || getColumnComponent(column).field}}
187
+
188
+ <span class="k-columnmenu-indicators">
189
+ <kendo-icon-wrapper
190
+ *ngIf="sortDescriptor(getColumnComponent(column).field).dir"
191
+ name="sort-{{sortDescriptor(getColumnComponent(column).field).dir}}-small"
192
+ [svgIcon]="sortDescriptor(getColumnComponent(column).field).dir === 'asc' ? sortAscSmallIcon : sortDescSmallIcon"
193
+ ></kendo-icon-wrapper>
194
+ <span *ngIf="showSortNumbering(getColumnComponent(column))" class="k-sort-index">{{sortOrder(getColumnComponent(column).field)}}</span>
195
+ </span>
196
+ </div>
197
+ </div>
198
+
199
+ <div class="k-actions k-actions-stretched k-actions-horizontal k-column-menu-footer">
200
+ <button kendoButton [svgIcon]="clearIcon" (click)="clearSorting()" >Clear sorting</button>
201
+ </div>
202
+ `,
203
+ standalone: true,
204
+ imports: [NgFor, NgIf, IconWrapperComponent, KENDO_BUTTON]
205
+ }]
206
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { sortItems: [{
207
+ type: ViewChildren,
208
+ args: ['sortItem', { read: ElementRef }]
209
+ }], wrapperClasses: [{
210
+ type: HostBinding,
211
+ args: ['class.k-column-menu']
212
+ }, {
213
+ type: HostBinding,
214
+ args: ['class.k-column-menu-md']
215
+ }], onEscKeyDown: [{
216
+ type: HostListener,
217
+ args: ['keydown.escape', ['$event']]
218
+ }], close: [{
219
+ type: Output
220
+ }], sortClear: [{
221
+ type: Output
222
+ }] } });