@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.
- package/column-menu/column-menu-item.component.d.ts +3 -1
- package/directives.d.ts +5 -3
- package/esm2022/column-menu/column-menu-item.component.mjs +13 -4
- package/esm2022/directives.mjs +5 -1
- package/esm2022/grid.component.mjs +12 -0
- package/esm2022/grid.module.mjs +97 -95
- package/esm2022/index.mjs +2 -0
- package/esm2022/localization/messages.mjs +13 -1
- package/esm2022/package-metadata.mjs +2 -2
- package/esm2022/rendering/toolbar/tools/filter-command-tool.directive.mjs +184 -0
- package/esm2022/rendering/toolbar/tools/filter-tool-wrapper.component.mjs +130 -0
- package/esm2022/rendering/toolbar/tools/filter-toolbar-tool.component.mjs +150 -0
- package/esm2022/rendering/toolbar/tools/sort-command-tool.directive.mjs +188 -0
- package/esm2022/rendering/toolbar/tools/sort-toolbar-tool.component.mjs +222 -0
- package/fesm2022/progress-kendo-angular-grid.mjs +858 -35
- package/grid.module.d.ts +97 -95
- package/index.d.ts +2 -0
- package/localization/messages.d.ts +9 -1
- package/package.json +20 -19
- package/rendering/toolbar/tools/filter-command-tool.directive.d.ts +53 -0
- package/rendering/toolbar/tools/filter-tool-wrapper.component.d.ts +41 -0
- package/rendering/toolbar/tools/filter-toolbar-tool.component.d.ts +43 -0
- package/rendering/toolbar/tools/sort-command-tool.directive.d.ts +53 -0
- package/rendering/toolbar/tools/sort-toolbar-tool.component.d.ts +53 -0
- package/schematics/ngAdd/index.js +4 -4
|
@@ -0,0 +1,184 @@
|
|
|
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 { Directive, NgZone, Renderer2 } from '@angular/core';
|
|
6
|
+
import { ToolBarButtonComponent } from '@progress/kendo-angular-toolbar';
|
|
7
|
+
import { Subscription } from 'rxjs';
|
|
8
|
+
import { filterIcon } from '@progress/kendo-svg-icons';
|
|
9
|
+
import { PopupService } from '@progress/kendo-angular-popup';
|
|
10
|
+
import { ContextService } from '../../../common/provider.service';
|
|
11
|
+
import { closest, isDocumentAvailable, isPresent } from '@progress/kendo-angular-common';
|
|
12
|
+
import { ColumnInfoService } from '../../../common/column-info.service';
|
|
13
|
+
import { take } from 'rxjs/operators';
|
|
14
|
+
import { FilterService } from '../../../filtering/filter.service';
|
|
15
|
+
import { FilterToolWrapperComponent } from './filter-tool-wrapper.component';
|
|
16
|
+
import * as i0 from "@angular/core";
|
|
17
|
+
import * as i1 from "@progress/kendo-angular-toolbar";
|
|
18
|
+
import * as i2 from "@progress/kendo-angular-popup";
|
|
19
|
+
import * as i3 from "../../../common/provider.service";
|
|
20
|
+
import * as i4 from "../../../filtering/filter.service";
|
|
21
|
+
import * as i5 from "../../../common/column-info.service";
|
|
22
|
+
let incrementingId = 0;
|
|
23
|
+
/**
|
|
24
|
+
* Represents the toolbar tool for filtering columns of the Grid.
|
|
25
|
+
* You can apply this directive to any `kendo-toolbar-button` element inside a
|
|
26
|
+
* ToolbarComponent used in the Grid.
|
|
27
|
+
*
|
|
28
|
+
* When the user clicks the toolbar button that is associated with the directive, the
|
|
29
|
+
* filter event is triggered.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```html-no-run
|
|
33
|
+
* <kendo-grid>
|
|
34
|
+
* <kendo-toolbar>
|
|
35
|
+
* <kendo-toolbar-button text="Filter" kendoGridFilterTool></kendo-toolbar-button>
|
|
36
|
+
* </kendo-toolbar>
|
|
37
|
+
* </kendo-grid>
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export class FilterCommandToolbarDirective {
|
|
41
|
+
host;
|
|
42
|
+
popupService;
|
|
43
|
+
ctx;
|
|
44
|
+
filterService;
|
|
45
|
+
columnInfoService;
|
|
46
|
+
ngZone;
|
|
47
|
+
renderer;
|
|
48
|
+
popupRef;
|
|
49
|
+
nextId = incrementingId++;
|
|
50
|
+
toolSubs = new Subscription();
|
|
51
|
+
popupSubs;
|
|
52
|
+
removeClickListener;
|
|
53
|
+
constructor(host, popupService, ctx, filterService, columnInfoService, ngZone, renderer) {
|
|
54
|
+
this.host = host;
|
|
55
|
+
this.popupService = popupService;
|
|
56
|
+
this.ctx = ctx;
|
|
57
|
+
this.filterService = filterService;
|
|
58
|
+
this.columnInfoService = columnInfoService;
|
|
59
|
+
this.ngZone = ngZone;
|
|
60
|
+
this.renderer = renderer;
|
|
61
|
+
}
|
|
62
|
+
ngOnInit() {
|
|
63
|
+
this.toolSubs = this.host.click.subscribe(e => this.onClick(e));
|
|
64
|
+
this.toolSubs.add(this.filterService.changes.subscribe(filter => {
|
|
65
|
+
this.host.showBadge = isPresent(filter) && filter.filters.length > 0;
|
|
66
|
+
}));
|
|
67
|
+
const hasToolbarIcon = isPresent(this.host.toolbarOptions.icon) && this.host.toolbarOptions.icon !== '';
|
|
68
|
+
const hasOverflowIcon = isPresent(this.host.overflowOptions.icon) && this.host.overflowOptions.icon !== '';
|
|
69
|
+
const hasIcon = hasToolbarIcon && hasOverflowIcon;
|
|
70
|
+
const hasSvgIcon = isPresent(this.host.toolbarOptions.svgIcon) && isPresent(this.host.overflowOptions.svgIcon);
|
|
71
|
+
if (!hasIcon) {
|
|
72
|
+
this.host.icon = 'k-i-filter';
|
|
73
|
+
}
|
|
74
|
+
if (!hasSvgIcon) {
|
|
75
|
+
this.host.svgIcon = filterIcon;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
ngAfterViewInit() {
|
|
79
|
+
if (!isPresent(this.host.text)) {
|
|
80
|
+
this.ngZone.onStable.pipe(take(1)).subscribe(() => {
|
|
81
|
+
this.host.text = this.ctx.localization.get(`filterToolbarToolText`);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
this.host.toolbarButtonElement.nativeElement.setAttribute('aria-haspopup', 'dialog');
|
|
85
|
+
this.host.toolbarButtonElement.nativeElement.setAttribute('aria-expanded', 'false');
|
|
86
|
+
this.host.toolbarButtonElement.nativeElement.setAttribute('title', this.ctx.localization.get('filter'));
|
|
87
|
+
}
|
|
88
|
+
ngOnDestroy() {
|
|
89
|
+
if (this.toolSubs) {
|
|
90
|
+
this.toolSubs.unsubscribe();
|
|
91
|
+
}
|
|
92
|
+
if (this.popupSubs) {
|
|
93
|
+
this.popupSubs.unsubscribe();
|
|
94
|
+
}
|
|
95
|
+
if (this.popupRef) {
|
|
96
|
+
this.popupRef.close();
|
|
97
|
+
this.popupRef = null;
|
|
98
|
+
}
|
|
99
|
+
if (this.removeClickListener) {
|
|
100
|
+
this.removeClickListener();
|
|
101
|
+
this.removeClickListener = null;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
onClick(e) {
|
|
105
|
+
e.preventDefault();
|
|
106
|
+
if (this.popupRef) {
|
|
107
|
+
this.closePopup();
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
this.openPopup();
|
|
111
|
+
}
|
|
112
|
+
openPopup() {
|
|
113
|
+
const direction = this.ctx.localization.rtl ? 'right' : 'left';
|
|
114
|
+
this.popupRef = this.popupService.open({
|
|
115
|
+
anchor: this.host.toolbarButtonElement.nativeElement,
|
|
116
|
+
content: FilterToolWrapperComponent,
|
|
117
|
+
popupClass: 'k-grid-columnmenu-popup',
|
|
118
|
+
positionMode: 'absolute',
|
|
119
|
+
anchorAlign: { vertical: 'bottom', horizontal: direction },
|
|
120
|
+
popupAlign: { vertical: 'top', horizontal: direction }
|
|
121
|
+
});
|
|
122
|
+
this.setPopupAttributes();
|
|
123
|
+
this.ngZone.runOutsideAngular(() => {
|
|
124
|
+
if (!isDocumentAvailable()) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
this.removeClickListener = this.renderer.listen('document', 'click', (e) => {
|
|
128
|
+
if (this.popupRef && !closest(e.target, node => node === this.popupRef.popupElement || node === this.host.toolbarButtonElement.nativeElement)) {
|
|
129
|
+
this.closePopup();
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
this.popupSubs = this.popupRef.popup.instance.anchorViewportLeave.subscribe(() => {
|
|
134
|
+
this.popupSubs?.unsubscribe();
|
|
135
|
+
this.popupSubs = null;
|
|
136
|
+
this.closePopup();
|
|
137
|
+
});
|
|
138
|
+
this.initPopupProperties();
|
|
139
|
+
}
|
|
140
|
+
setPopupAttributes() {
|
|
141
|
+
const popupElement = this.popupRef.popupElement;
|
|
142
|
+
const popupId = `k-filter-tool-${this.nextId}-popup`;
|
|
143
|
+
const popupAriaElement = popupElement.querySelector('.k-popup');
|
|
144
|
+
this.renderer.setAttribute(popupElement, 'dir', this.ctx.localization.rtl ? 'rtl' : 'ltr');
|
|
145
|
+
this.renderer.setAttribute(popupAriaElement, 'id', popupId);
|
|
146
|
+
this.renderer.setAttribute(popupAriaElement, 'role', 'dialog');
|
|
147
|
+
this.host.toolbarButtonElement.nativeElement.setAttribute('aria-expanded', 'true');
|
|
148
|
+
this.host.toolbarButtonElement.nativeElement.setAttribute('aria-controls', popupId);
|
|
149
|
+
}
|
|
150
|
+
initPopupProperties() {
|
|
151
|
+
this.popupRef.content.instance.columnInfoService = this.columnInfoService;
|
|
152
|
+
this.popupRef.content.instance.ctx = this.ctx;
|
|
153
|
+
this.popupRef.content.instance.filterService = this.filterService;
|
|
154
|
+
this.popupRef.content.instance.hostButton = this.host;
|
|
155
|
+
this.popupSubs.add(this.popupRef.content.instance.close.subscribe(() => {
|
|
156
|
+
this.closePopup();
|
|
157
|
+
}));
|
|
158
|
+
}
|
|
159
|
+
closePopup() {
|
|
160
|
+
this.host.toolbarButtonElement.nativeElement.setAttribute('aria-expanded', 'false');
|
|
161
|
+
this.host.toolbarButtonElement.nativeElement.removeAttribute('aria-controls');
|
|
162
|
+
if (this.popupRef) {
|
|
163
|
+
this.popupRef.close();
|
|
164
|
+
this.popupRef = null;
|
|
165
|
+
}
|
|
166
|
+
if (this.popupSubs) {
|
|
167
|
+
this.popupSubs.unsubscribe();
|
|
168
|
+
this.popupSubs = null;
|
|
169
|
+
}
|
|
170
|
+
if (this.removeClickListener) {
|
|
171
|
+
this.removeClickListener();
|
|
172
|
+
this.removeClickListener = null;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: FilterCommandToolbarDirective, deps: [{ token: i1.ToolBarButtonComponent }, { token: i2.PopupService }, { token: i3.ContextService }, { token: i4.FilterService }, { token: i5.ColumnInfoService }, { token: i0.NgZone }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive });
|
|
176
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: FilterCommandToolbarDirective, isStandalone: true, selector: "[kendoGridFilterTool]", ngImport: i0 });
|
|
177
|
+
}
|
|
178
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: FilterCommandToolbarDirective, decorators: [{
|
|
179
|
+
type: Directive,
|
|
180
|
+
args: [{
|
|
181
|
+
selector: '[kendoGridFilterTool]',
|
|
182
|
+
standalone: true
|
|
183
|
+
}]
|
|
184
|
+
}], ctorParameters: function () { return [{ type: i1.ToolBarButtonComponent }, { type: i2.PopupService }, { type: i3.ContextService }, { type: i4.FilterService }, { type: i5.ColumnInfoService }, { type: i0.NgZone }, { type: i0.Renderer2 }]; } });
|
|
@@ -0,0 +1,130 @@
|
|
|
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, EventEmitter, HostBinding, Injector, Output, ViewChild, ViewContainerRef, HostListener } from '@angular/core';
|
|
6
|
+
import { ContextService } from '../../../common/provider.service';
|
|
7
|
+
import { filterClearIcon } from '@progress/kendo-svg-icons';
|
|
8
|
+
import { KENDO_BUTTON } from '@progress/kendo-angular-buttons';
|
|
9
|
+
import { FilterService } from '../../../filtering/filter.service';
|
|
10
|
+
import { FilterToolbarToolComponent } from './filter-toolbar-tool.component';
|
|
11
|
+
import { SinglePopupService } from '../../../common/single-popup.service';
|
|
12
|
+
import { ScrollSyncService } from '../../../scrolling/scroll-sync.service';
|
|
13
|
+
import { ColumnInfoService } from '../../../common/column-info.service';
|
|
14
|
+
import { cloneFilters } from '../../../common/filter-descriptor-differ';
|
|
15
|
+
import * as i0 from "@angular/core";
|
|
16
|
+
import * as i1 from "@progress/kendo-angular-buttons";
|
|
17
|
+
/**
|
|
18
|
+
* @hidden
|
|
19
|
+
*/
|
|
20
|
+
export class FilterToolWrapperComponent {
|
|
21
|
+
injector;
|
|
22
|
+
container;
|
|
23
|
+
wrapperClasses = true;
|
|
24
|
+
onEscKeyDown(event) {
|
|
25
|
+
event.preventDefault();
|
|
26
|
+
this.close.emit();
|
|
27
|
+
this.hostButton?.focus(event);
|
|
28
|
+
}
|
|
29
|
+
close = new EventEmitter();
|
|
30
|
+
hostButton;
|
|
31
|
+
clearIcon = filterClearIcon;
|
|
32
|
+
columnInfoService;
|
|
33
|
+
popupRef;
|
|
34
|
+
filter;
|
|
35
|
+
subscriptions;
|
|
36
|
+
_ctx;
|
|
37
|
+
set ctx(ctx) {
|
|
38
|
+
this._ctx = ctx;
|
|
39
|
+
this.createPopup();
|
|
40
|
+
}
|
|
41
|
+
get ctx() {
|
|
42
|
+
return this._ctx;
|
|
43
|
+
}
|
|
44
|
+
_filterService;
|
|
45
|
+
set filterService(filterService) {
|
|
46
|
+
this._filterService = filterService;
|
|
47
|
+
this.subscriptions = this._filterService.changes.subscribe(filter => {
|
|
48
|
+
this.filter = filter;
|
|
49
|
+
});
|
|
50
|
+
this.createPopup();
|
|
51
|
+
}
|
|
52
|
+
get filterService() {
|
|
53
|
+
return this._filterService;
|
|
54
|
+
}
|
|
55
|
+
columnMenuService;
|
|
56
|
+
constructor(injector) {
|
|
57
|
+
this.injector = injector;
|
|
58
|
+
}
|
|
59
|
+
ngOnDestroy() {
|
|
60
|
+
if (this.subscriptions) {
|
|
61
|
+
this.subscriptions.unsubscribe();
|
|
62
|
+
}
|
|
63
|
+
if (this.popupRef) {
|
|
64
|
+
this.popupRef.destroy();
|
|
65
|
+
this.popupRef = null;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
clear() {
|
|
69
|
+
if (!this.filter || this.filter.filters?.length === 0) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
this.filter = { logic: 'and', filters: [] };
|
|
73
|
+
this.popupRef.instance.filter = cloneFilters(this.filter);
|
|
74
|
+
this.filterService.filter(this.filter);
|
|
75
|
+
this.close.emit();
|
|
76
|
+
}
|
|
77
|
+
createPopup() {
|
|
78
|
+
if (this._ctx && this._filterService && this.container && !this.popupRef) {
|
|
79
|
+
const customInjector = Injector.create({
|
|
80
|
+
providers: [
|
|
81
|
+
{ provide: FilterService, useValue: this._filterService },
|
|
82
|
+
{ provide: ContextService, useValue: this._ctx },
|
|
83
|
+
{ provide: ColumnInfoService, useValue: this.columnInfoService },
|
|
84
|
+
SinglePopupService,
|
|
85
|
+
ScrollSyncService
|
|
86
|
+
],
|
|
87
|
+
parent: this.injector
|
|
88
|
+
});
|
|
89
|
+
this.popupRef = this.container.createComponent(FilterToolbarToolComponent, {
|
|
90
|
+
injector: customInjector
|
|
91
|
+
});
|
|
92
|
+
this.subscriptions.add(this.popupRef.instance.close.subscribe(() => this.close.emit()));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: FilterToolWrapperComponent, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Component });
|
|
96
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: FilterToolWrapperComponent, isStandalone: true, selector: "kendo-filter-tool-wrapper", outputs: { close: "close" }, host: { listeners: { "keydown.escape": "onEscKeyDown($event)" }, properties: { "class.k-column-menu": "this.wrapperClasses", "class.k-column-menu-md": "this.wrapperClasses" } }, viewQueries: [{ propertyName: "container", first: true, predicate: ["container"], descendants: true, read: ViewContainerRef, static: true }], ngImport: i0, template: `
|
|
97
|
+
<ng-container #container></ng-container>
|
|
98
|
+
<div class="k-actions k-actions-stretched k-actions-horizontal k-column-menu-footer">
|
|
99
|
+
<button kendoButton [svgIcon]="clearIcon" (click)="clear()">Clear all filters</button>
|
|
100
|
+
</div>
|
|
101
|
+
`, isInline: true, dependencies: [{ 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"] }] });
|
|
102
|
+
}
|
|
103
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: FilterToolWrapperComponent, decorators: [{
|
|
104
|
+
type: Component,
|
|
105
|
+
args: [{
|
|
106
|
+
selector: 'kendo-filter-tool-wrapper',
|
|
107
|
+
template: `
|
|
108
|
+
<ng-container #container></ng-container>
|
|
109
|
+
<div class="k-actions k-actions-stretched k-actions-horizontal k-column-menu-footer">
|
|
110
|
+
<button kendoButton [svgIcon]="clearIcon" (click)="clear()">Clear all filters</button>
|
|
111
|
+
</div>
|
|
112
|
+
`,
|
|
113
|
+
standalone: true,
|
|
114
|
+
imports: [KENDO_BUTTON]
|
|
115
|
+
}]
|
|
116
|
+
}], ctorParameters: function () { return [{ type: i0.Injector }]; }, propDecorators: { container: [{
|
|
117
|
+
type: ViewChild,
|
|
118
|
+
args: ['container', { read: ViewContainerRef, static: true }]
|
|
119
|
+
}], wrapperClasses: [{
|
|
120
|
+
type: HostBinding,
|
|
121
|
+
args: ['class.k-column-menu']
|
|
122
|
+
}, {
|
|
123
|
+
type: HostBinding,
|
|
124
|
+
args: ['class.k-column-menu-md']
|
|
125
|
+
}], onEscKeyDown: [{
|
|
126
|
+
type: HostListener,
|
|
127
|
+
args: ['keydown.escape', ['$event']]
|
|
128
|
+
}], close: [{
|
|
129
|
+
type: Output
|
|
130
|
+
}] } });
|
|
@@ -0,0 +1,150 @@
|
|
|
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, Output, QueryList, ViewChildren } from '@angular/core';
|
|
6
|
+
import { ContextService } from '../../../common/provider.service';
|
|
7
|
+
import { NgFor } from '@angular/common';
|
|
8
|
+
import { KENDO_BUTTON } from '@progress/kendo-angular-buttons';
|
|
9
|
+
import { FilterMenuContainerComponent } from '../../../filtering/menu/filter-menu-container.component';
|
|
10
|
+
import { FilterService } from '../../../filtering/filter.service';
|
|
11
|
+
import { ColumnMenuItemComponent } from '../../../column-menu/column-menu-item.component';
|
|
12
|
+
import { ColumnMenuItemContentTemplateDirective } from '../../../column-menu/column-menu-item-content-template.directive';
|
|
13
|
+
import { ColumnInfoService } from '../../../common/column-info.service';
|
|
14
|
+
import { cloneFilters } from '../../../common/filter-descriptor-differ';
|
|
15
|
+
import * as i0 from "@angular/core";
|
|
16
|
+
import * as i1 from "../../../filtering/filter.service";
|
|
17
|
+
import * as i2 from "../../../common/provider.service";
|
|
18
|
+
import * as i3 from "../../../common/column-info.service";
|
|
19
|
+
/**
|
|
20
|
+
* @hidden
|
|
21
|
+
*/
|
|
22
|
+
export class FilterToolbarToolComponent {
|
|
23
|
+
element;
|
|
24
|
+
filterService;
|
|
25
|
+
ctx;
|
|
26
|
+
columnInfoService;
|
|
27
|
+
filterItems;
|
|
28
|
+
menuItems;
|
|
29
|
+
filterContainers;
|
|
30
|
+
close = new EventEmitter();
|
|
31
|
+
get hostStyles() {
|
|
32
|
+
return {
|
|
33
|
+
'maxHeight': '400px',
|
|
34
|
+
'overflowX': 'hidden',
|
|
35
|
+
'overflowY': 'auto'
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
columnMenuService;
|
|
39
|
+
columns;
|
|
40
|
+
filter;
|
|
41
|
+
subscriptions;
|
|
42
|
+
constructor(element, filterService, ctx, columnInfoService) {
|
|
43
|
+
this.element = element;
|
|
44
|
+
this.filterService = filterService;
|
|
45
|
+
this.ctx = ctx;
|
|
46
|
+
this.columnInfoService = columnInfoService;
|
|
47
|
+
}
|
|
48
|
+
ngOnInit() {
|
|
49
|
+
this.columns = this.columnInfoService.leafNamedColumns.filter(column => column?.filterable);
|
|
50
|
+
this.filter = this.ctx.grid.filter;
|
|
51
|
+
this.subscriptions = this.filterService.changes.subscribe(filter => {
|
|
52
|
+
this.filter = cloneFilters(filter);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
ngAfterViewInit() {
|
|
56
|
+
this.filterItems?.get(0)?.nativeElement.focus();
|
|
57
|
+
}
|
|
58
|
+
ngOnDestroy() {
|
|
59
|
+
if (this.subscriptions) {
|
|
60
|
+
this.subscriptions.unsubscribe();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
getColumnComponent(column) {
|
|
64
|
+
return column;
|
|
65
|
+
}
|
|
66
|
+
handleClose(filterItem) {
|
|
67
|
+
filterItem.expanded = false;
|
|
68
|
+
filterItem.contentState = 'collapsed';
|
|
69
|
+
}
|
|
70
|
+
toggleItem(event, index) {
|
|
71
|
+
const menuItem = this.menuItems.get(index);
|
|
72
|
+
if (!menuItem || event.target.closest('.k-filter-menu-container')) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (menuItem.expanded) {
|
|
76
|
+
this.filterContainers.get(index).isExpanded = false;
|
|
77
|
+
menuItem.expanded = false;
|
|
78
|
+
menuItem.contentState = 'collapsed';
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
this.filterContainers.get(index).isExpanded = true;
|
|
82
|
+
menuItem.expanded = true;
|
|
83
|
+
menuItem.contentState = 'expanded';
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: FilterToolbarToolComponent, deps: [{ token: i0.ElementRef }, { token: i1.FilterService }, { token: i2.ContextService }, { token: i3.ColumnInfoService }], target: i0.ɵɵFactoryTarget.Component });
|
|
87
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: FilterToolbarToolComponent, isStandalone: true, selector: "kendo-filter-toolbar-tool", outputs: { close: "close" }, viewQueries: [{ propertyName: "filterItems", predicate: ["filterItem"], descendants: true, read: ElementRef }, { propertyName: "menuItems", predicate: ["filterItem"], descendants: true }, { propertyName: "filterContainers", predicate: ["filterContainer"], descendants: true }], ngImport: i0, template: `
|
|
88
|
+
<div [style]="hostStyles">
|
|
89
|
+
<kendo-grid-columnmenu-item *ngFor="let column of columns; let i = index"
|
|
90
|
+
class="k-columnmenu-item-wrapper" #filterItem
|
|
91
|
+
role="button"
|
|
92
|
+
tabindex="0"
|
|
93
|
+
[text]="column.title || getColumnComponent(column).field"
|
|
94
|
+
(keydown.enter)="toggleItem($event, i)"
|
|
95
|
+
[expanded]="false">
|
|
96
|
+
<ng-template kendoGridColumnMenuItemContentTemplate>
|
|
97
|
+
<kendo-grid-filter-menu-container
|
|
98
|
+
#filterContainer
|
|
99
|
+
(keydown.shift.tab)="$event.stopImmediatePropagation()"
|
|
100
|
+
[column]="getColumnComponent(column)"
|
|
101
|
+
[filter]="filter"
|
|
102
|
+
[isExpanded]="false"
|
|
103
|
+
(close)="handleClose(filterItem)">
|
|
104
|
+
</kendo-grid-filter-menu-container>
|
|
105
|
+
</ng-template>
|
|
106
|
+
</kendo-grid-columnmenu-item>
|
|
107
|
+
</div>
|
|
108
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: NgFor, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "component", type: FilterMenuContainerComponent, selector: "kendo-grid-filter-menu-container", inputs: ["column", "isLast", "isExpanded", "menuTabbingService", "filter", "actionsClass"], outputs: ["close"] }, { kind: "component", type: ColumnMenuItemComponent, selector: "kendo-grid-columnmenu-item", inputs: ["icon", "svgIcon", "text", "selected", "disabled", "expanded", "service"], outputs: ["itemClick", "expand", "collapse"] }, { kind: "directive", type: ColumnMenuItemContentTemplateDirective, selector: "[kendoGridColumnMenuItemContentTemplate]" }] });
|
|
109
|
+
}
|
|
110
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: FilterToolbarToolComponent, decorators: [{
|
|
111
|
+
type: Component,
|
|
112
|
+
args: [{
|
|
113
|
+
selector: 'kendo-filter-toolbar-tool',
|
|
114
|
+
template: `
|
|
115
|
+
<div [style]="hostStyles">
|
|
116
|
+
<kendo-grid-columnmenu-item *ngFor="let column of columns; let i = index"
|
|
117
|
+
class="k-columnmenu-item-wrapper" #filterItem
|
|
118
|
+
role="button"
|
|
119
|
+
tabindex="0"
|
|
120
|
+
[text]="column.title || getColumnComponent(column).field"
|
|
121
|
+
(keydown.enter)="toggleItem($event, i)"
|
|
122
|
+
[expanded]="false">
|
|
123
|
+
<ng-template kendoGridColumnMenuItemContentTemplate>
|
|
124
|
+
<kendo-grid-filter-menu-container
|
|
125
|
+
#filterContainer
|
|
126
|
+
(keydown.shift.tab)="$event.stopImmediatePropagation()"
|
|
127
|
+
[column]="getColumnComponent(column)"
|
|
128
|
+
[filter]="filter"
|
|
129
|
+
[isExpanded]="false"
|
|
130
|
+
(close)="handleClose(filterItem)">
|
|
131
|
+
</kendo-grid-filter-menu-container>
|
|
132
|
+
</ng-template>
|
|
133
|
+
</kendo-grid-columnmenu-item>
|
|
134
|
+
</div>
|
|
135
|
+
`,
|
|
136
|
+
standalone: true,
|
|
137
|
+
imports: [NgFor, KENDO_BUTTON, FilterMenuContainerComponent, ColumnMenuItemComponent, ColumnMenuItemContentTemplateDirective]
|
|
138
|
+
}]
|
|
139
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i1.FilterService }, { type: i2.ContextService }, { type: i3.ColumnInfoService }]; }, propDecorators: { filterItems: [{
|
|
140
|
+
type: ViewChildren,
|
|
141
|
+
args: ['filterItem', { read: ElementRef }]
|
|
142
|
+
}], menuItems: [{
|
|
143
|
+
type: ViewChildren,
|
|
144
|
+
args: ['filterItem']
|
|
145
|
+
}], filterContainers: [{
|
|
146
|
+
type: ViewChildren,
|
|
147
|
+
args: ['filterContainer']
|
|
148
|
+
}], close: [{
|
|
149
|
+
type: Output
|
|
150
|
+
}] } });
|
|
@@ -0,0 +1,188 @@
|
|
|
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 { Directive, NgZone, Renderer2 } from '@angular/core';
|
|
6
|
+
import { ToolBarButtonComponent } from '@progress/kendo-angular-toolbar';
|
|
7
|
+
import { Subscription } from 'rxjs';
|
|
8
|
+
import { arrowsSwapIcon } from '@progress/kendo-svg-icons';
|
|
9
|
+
import { SortToolbarToolComponent } from './sort-toolbar-tool.component';
|
|
10
|
+
import { PopupService } from '@progress/kendo-angular-popup';
|
|
11
|
+
import { ContextService } from '../../../common/provider.service';
|
|
12
|
+
import { SortService } from '../../../common/sort.service';
|
|
13
|
+
import { closest, isDocumentAvailable, isPresent } from '@progress/kendo-angular-common';
|
|
14
|
+
import { ColumnInfoService } from '../../../common/column-info.service';
|
|
15
|
+
import { take } from 'rxjs/operators';
|
|
16
|
+
import * as i0 from "@angular/core";
|
|
17
|
+
import * as i1 from "@progress/kendo-angular-toolbar";
|
|
18
|
+
import * as i2 from "@progress/kendo-angular-popup";
|
|
19
|
+
import * as i3 from "../../../common/provider.service";
|
|
20
|
+
import * as i4 from "../../../common/sort.service";
|
|
21
|
+
import * as i5 from "../../../common/column-info.service";
|
|
22
|
+
let incrementingId = 0;
|
|
23
|
+
/**
|
|
24
|
+
* Represents the toolbar tool for sorting columns of the Grid.
|
|
25
|
+
* You can apply this directive to any `kendo-toolbar-button` element inside a
|
|
26
|
+
* ToolbarComponent used in the Grid.
|
|
27
|
+
*
|
|
28
|
+
* When the user clicks the toolbar button that is associated with the directive, the
|
|
29
|
+
* sort event is triggered.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```html-no-run
|
|
33
|
+
* <kendo-grid>
|
|
34
|
+
* <kendo-toolbar>
|
|
35
|
+
* <kendo-toolbar-button text="Sort" kendoGridSortTool></kendo-toolbar-button>
|
|
36
|
+
* </kendo-toolbar>
|
|
37
|
+
* </kendo-grid>
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export class SortCommandToolbarDirective {
|
|
41
|
+
host;
|
|
42
|
+
popupService;
|
|
43
|
+
ctx;
|
|
44
|
+
sortService;
|
|
45
|
+
columnInfoService;
|
|
46
|
+
ngZone;
|
|
47
|
+
renderer;
|
|
48
|
+
popupRef;
|
|
49
|
+
nextId = incrementingId++;
|
|
50
|
+
toolSubs = new Subscription();
|
|
51
|
+
popupSubs;
|
|
52
|
+
removeClickListener;
|
|
53
|
+
constructor(host, popupService, ctx, sortService, columnInfoService, ngZone, renderer) {
|
|
54
|
+
this.host = host;
|
|
55
|
+
this.popupService = popupService;
|
|
56
|
+
this.ctx = ctx;
|
|
57
|
+
this.sortService = sortService;
|
|
58
|
+
this.columnInfoService = columnInfoService;
|
|
59
|
+
this.ngZone = ngZone;
|
|
60
|
+
this.renderer = renderer;
|
|
61
|
+
}
|
|
62
|
+
ngOnInit() {
|
|
63
|
+
this.toolSubs = this.host.click.subscribe(e => this.onClick(e));
|
|
64
|
+
this.toolSubs.add(this.sortService.changes.subscribe(sort => {
|
|
65
|
+
const isSortingApplied = isPresent(sort) && sort.length > 0 && sort.filter(item => item.dir !== undefined).length > 0;
|
|
66
|
+
this.host.showBadge = isSortingApplied;
|
|
67
|
+
}));
|
|
68
|
+
const hasToolbarIcon = isPresent(this.host.toolbarOptions.icon) && this.host.toolbarOptions.icon !== '';
|
|
69
|
+
const hasOverflowIcon = isPresent(this.host.overflowOptions.icon) && this.host.overflowOptions.icon !== '';
|
|
70
|
+
const hasIcon = hasToolbarIcon && hasOverflowIcon;
|
|
71
|
+
const hasSvgIcon = isPresent(this.host.toolbarOptions.svgIcon) && isPresent(this.host.overflowOptions.svgIcon);
|
|
72
|
+
if (!hasIcon) {
|
|
73
|
+
this.host.icon = 'k-i-arrows-swap';
|
|
74
|
+
}
|
|
75
|
+
if (!hasSvgIcon) {
|
|
76
|
+
this.host.svgIcon = arrowsSwapIcon;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
ngAfterViewInit() {
|
|
80
|
+
if (!isPresent(this.host.text)) {
|
|
81
|
+
this.ngZone.onStable.pipe(take(1)).subscribe(() => {
|
|
82
|
+
this.host.text = this.ctx.localization.get(`sortToolbarToolText`);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
this.host.toolbarButtonElement.nativeElement.setAttribute('aria-haspopup', 'dialog');
|
|
86
|
+
this.host.toolbarButtonElement.nativeElement.setAttribute('aria-expanded', 'false');
|
|
87
|
+
this.host.toolbarButtonElement.nativeElement.setAttribute('title', this.ctx.localization.get('sortable'));
|
|
88
|
+
}
|
|
89
|
+
ngOnDestroy() {
|
|
90
|
+
if (this.toolSubs) {
|
|
91
|
+
this.toolSubs.unsubscribe();
|
|
92
|
+
}
|
|
93
|
+
if (this.popupSubs) {
|
|
94
|
+
this.popupSubs.unsubscribe();
|
|
95
|
+
}
|
|
96
|
+
if (this.popupRef) {
|
|
97
|
+
this.popupRef.close();
|
|
98
|
+
this.popupRef = null;
|
|
99
|
+
}
|
|
100
|
+
if (this.removeClickListener) {
|
|
101
|
+
this.removeClickListener();
|
|
102
|
+
this.removeClickListener = null;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
onClick(e) {
|
|
106
|
+
e.preventDefault();
|
|
107
|
+
if (this.popupRef) {
|
|
108
|
+
this.closePopup();
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
this.openPopup();
|
|
112
|
+
}
|
|
113
|
+
openPopup() {
|
|
114
|
+
const direction = this.ctx.localization.rtl ? 'right' : 'left';
|
|
115
|
+
this.popupRef = this.popupService.open({
|
|
116
|
+
anchor: this.host.toolbarButtonElement.nativeElement,
|
|
117
|
+
content: SortToolbarToolComponent,
|
|
118
|
+
popupClass: 'k-grid-columnmenu-popup',
|
|
119
|
+
positionMode: 'absolute',
|
|
120
|
+
anchorAlign: { vertical: 'bottom', horizontal: direction },
|
|
121
|
+
popupAlign: { vertical: 'top', horizontal: direction }
|
|
122
|
+
});
|
|
123
|
+
this.setPopupAttributes();
|
|
124
|
+
this.ngZone.runOutsideAngular(() => {
|
|
125
|
+
if (!isDocumentAvailable()) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
this.removeClickListener = this.renderer.listen('document', 'click', (e) => {
|
|
129
|
+
if (this.popupRef && !closest(e.target, node => node === this.popupRef.popupElement || node === this.host.toolbarButtonElement.nativeElement)) {
|
|
130
|
+
this.closePopup();
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
this.popupSubs = this.popupRef.popup.instance.anchorViewportLeave.subscribe(() => {
|
|
135
|
+
this.popupSubs?.unsubscribe();
|
|
136
|
+
this.popupSubs = null;
|
|
137
|
+
this.closePopup();
|
|
138
|
+
});
|
|
139
|
+
this.initPopupProperties();
|
|
140
|
+
}
|
|
141
|
+
setPopupAttributes() {
|
|
142
|
+
const popupElement = this.popupRef.popupElement;
|
|
143
|
+
const popupId = `k-sort-tool-${this.nextId}-popup`;
|
|
144
|
+
const popupAriaElement = popupElement.querySelector('.k-popup');
|
|
145
|
+
this.renderer.setAttribute(popupElement, 'dir', this.ctx.localization.rtl ? 'rtl' : 'ltr');
|
|
146
|
+
this.renderer.setAttribute(popupAriaElement, 'id', popupId);
|
|
147
|
+
this.renderer.setAttribute(popupAriaElement, 'role', 'dialog');
|
|
148
|
+
this.host.toolbarButtonElement.nativeElement.setAttribute('aria-expanded', 'true');
|
|
149
|
+
this.host.toolbarButtonElement.nativeElement.setAttribute('aria-controls', popupId);
|
|
150
|
+
}
|
|
151
|
+
initPopupProperties() {
|
|
152
|
+
this.popupRef.content.instance.columnInfoService = this.columnInfoService;
|
|
153
|
+
this.popupRef.content.instance.ctx = this.ctx;
|
|
154
|
+
this.popupRef.content.instance.sortService = this.sortService;
|
|
155
|
+
this.popupRef.content.instance.hostButton = this.host;
|
|
156
|
+
this.popupSubs.add(this.popupRef.content.instance.sortClear.subscribe(() => {
|
|
157
|
+
this.closePopup();
|
|
158
|
+
}));
|
|
159
|
+
this.popupSubs.add(this.popupRef.content.instance.close.subscribe(() => {
|
|
160
|
+
this.closePopup();
|
|
161
|
+
}));
|
|
162
|
+
}
|
|
163
|
+
closePopup() {
|
|
164
|
+
this.host.toolbarButtonElement.nativeElement.setAttribute('aria-expanded', 'false');
|
|
165
|
+
this.host.toolbarButtonElement.nativeElement.removeAttribute('aria-controls');
|
|
166
|
+
if (this.popupRef) {
|
|
167
|
+
this.popupRef.close();
|
|
168
|
+
this.popupRef = null;
|
|
169
|
+
}
|
|
170
|
+
if (this.popupSubs) {
|
|
171
|
+
this.popupSubs.unsubscribe();
|
|
172
|
+
this.popupSubs = null;
|
|
173
|
+
}
|
|
174
|
+
if (this.removeClickListener) {
|
|
175
|
+
this.removeClickListener();
|
|
176
|
+
this.removeClickListener = null;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SortCommandToolbarDirective, deps: [{ token: i1.ToolBarButtonComponent }, { token: i2.PopupService }, { token: i3.ContextService }, { token: i4.SortService }, { token: i5.ColumnInfoService }, { token: i0.NgZone }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive });
|
|
180
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: SortCommandToolbarDirective, isStandalone: true, selector: "[kendoGridSortTool]", ngImport: i0 });
|
|
181
|
+
}
|
|
182
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SortCommandToolbarDirective, decorators: [{
|
|
183
|
+
type: Directive,
|
|
184
|
+
args: [{
|
|
185
|
+
selector: '[kendoGridSortTool]',
|
|
186
|
+
standalone: true
|
|
187
|
+
}]
|
|
188
|
+
}], ctorParameters: function () { return [{ type: i1.ToolBarButtonComponent }, { type: i2.PopupService }, { type: i3.ContextService }, { type: i4.SortService }, { type: i5.ColumnInfoService }, { type: i0.NgZone }, { type: i0.Renderer2 }]; } });
|