@progress/kendo-angular-grid 19.0.0-develop.9 → 19.0.1-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.
Files changed (133) hide show
  1. package/adaptiveness/adaptive-mode.d.ts +12 -0
  2. package/adaptiveness/adaptive-renderer.component.d.ts +89 -0
  3. package/codemods/template-transformer/index.js +94 -0
  4. package/codemods/utils.js +553 -0
  5. package/codemods/v19/grid-kendogridgroupbinding.js +51 -0
  6. package/column-menu/column-chooser.component.d.ts +4 -0
  7. package/column-menu/column-list.component.d.ts +10 -3
  8. package/column-menu/column-menu-item.component.d.ts +48 -3
  9. package/column-menu/column-menu-item.directive.d.ts +5 -2
  10. package/column-menu/column-menu.component.d.ts +4 -2
  11. package/columns/column-base.d.ts +5 -0
  12. package/columns/span-column.component.d.ts +2 -2
  13. package/common/adaptiveness.service.d.ts +50 -0
  14. package/common/single-popup.service.d.ts +3 -1
  15. package/common/toolbar-tool-base.directive.d.ts +26 -0
  16. package/directives.d.ts +13 -5
  17. package/editing/add-command-tool.directive.d.ts +7 -6
  18. package/editing/cancel-command-tool.directive.d.ts +38 -0
  19. package/editing/edit-command-tool.directive.d.ts +38 -0
  20. package/editing/edit.service.d.ts +1 -1
  21. package/editing/remove-command-tool.directive.d.ts +39 -0
  22. package/editing/save-command-tool.directive.d.ts +38 -0
  23. package/editing/toolbar-editing-tool-base.directive.d.ts +29 -0
  24. package/editing-directives/editing-directive-base.d.ts +4 -1
  25. package/editing-directives/external-editing.directive.d.ts +3 -1
  26. package/esm2022/adaptiveness/adaptive-mode.mjs +5 -0
  27. package/esm2022/adaptiveness/adaptive-renderer.component.mjs +1197 -0
  28. package/esm2022/column-menu/column-chooser.component.mjs +13 -11
  29. package/esm2022/column-menu/column-list.component.mjs +51 -8
  30. package/esm2022/column-menu/column-menu-autosize-all.component.mjs +1 -1
  31. package/esm2022/column-menu/column-menu-autosize.component.mjs +1 -1
  32. package/esm2022/column-menu/column-menu-chooser.component.mjs +1 -1
  33. package/esm2022/column-menu/column-menu-container.component.mjs +1 -1
  34. package/esm2022/column-menu/column-menu-filter.component.mjs +1 -1
  35. package/esm2022/column-menu/column-menu-item.component.mjs +123 -12
  36. package/esm2022/column-menu/column-menu-item.directive.mjs +14 -5
  37. package/esm2022/column-menu/column-menu-lock.component.mjs +1 -1
  38. package/esm2022/column-menu/column-menu-position.component.mjs +1 -1
  39. package/esm2022/column-menu/column-menu-sort.component.mjs +1 -1
  40. package/esm2022/column-menu/column-menu-stick.component.mjs +1 -1
  41. package/esm2022/column-menu/column-menu.component.mjs +68 -44
  42. package/esm2022/column-resizing/column-handle.directive.mjs +2 -2
  43. package/esm2022/columns/column-base.mjs +9 -0
  44. package/esm2022/columns/columns-container.mjs +1 -1
  45. package/esm2022/columns/span-column.component.mjs +9 -9
  46. package/esm2022/common/adaptiveness.service.mjs +72 -0
  47. package/esm2022/common/single-popup.service.mjs +9 -3
  48. package/esm2022/common/toolbar-tool-base.directive.mjs +81 -0
  49. package/esm2022/directives.mjs +21 -4
  50. package/esm2022/editing/add-command-tool.directive.mjs +12 -15
  51. package/esm2022/editing/cancel-command-tool.directive.mjs +64 -0
  52. package/esm2022/editing/edit-command-tool.directive.mjs +59 -0
  53. package/esm2022/editing/remove-command-tool.directive.mjs +60 -0
  54. package/esm2022/editing/remove-command.directive.mjs +1 -0
  55. package/esm2022/editing/save-command-tool.directive.mjs +64 -0
  56. package/esm2022/editing/toolbar-editing-tool-base.directive.mjs +94 -0
  57. package/esm2022/editing-directives/editing-directive-base.mjs +5 -2
  58. package/esm2022/editing-directives/external-editing.directive.mjs +28 -14
  59. package/esm2022/excel/excel-command-tool.directive.mjs +12 -17
  60. package/esm2022/filtering/filter-input.directive.mjs +14 -2
  61. package/esm2022/filtering/menu/boolean-filter-menu.component.mjs +4 -2
  62. package/esm2022/filtering/menu/date-filter-menu-input.component.mjs +4 -0
  63. package/esm2022/filtering/menu/date-filter-menu.component.mjs +6 -0
  64. package/esm2022/filtering/menu/filter-menu-container.component.mjs +24 -10
  65. package/esm2022/filtering/menu/filter-menu-input-wrapper.component.mjs +26 -4
  66. package/esm2022/filtering/menu/filter-menu.component.mjs +44 -29
  67. package/esm2022/filtering/menu/numeric-filter-menu-input.component.mjs +2 -0
  68. package/esm2022/filtering/menu/numeric-filter-menu.component.mjs +6 -0
  69. package/esm2022/filtering/menu/string-filter-menu-input.component.mjs +2 -0
  70. package/esm2022/filtering/menu/string-filter-menu.component.mjs +10 -1
  71. package/esm2022/grid.component.mjs +376 -82
  72. package/esm2022/grid.module.mjs +115 -101
  73. package/esm2022/index.mjs +11 -1
  74. package/esm2022/localization/messages.mjs +128 -2
  75. package/esm2022/navigation/toolbar-tool-name.mjs +17 -0
  76. package/esm2022/package-metadata.mjs +2 -2
  77. package/esm2022/pdf/pdf-command-tool.directive.mjs +12 -15
  78. package/esm2022/rendering/cell.component.mjs +3 -3
  79. package/esm2022/rendering/header/header.component.mjs +1 -1
  80. package/esm2022/rendering/list.component.mjs +1 -1
  81. package/esm2022/rendering/table-body.component.mjs +1 -1
  82. package/esm2022/rendering/toolbar/tools/column-chooser-tool.directive.mjs +210 -0
  83. package/esm2022/rendering/toolbar/tools/filter-command-tool.directive.mjs +69 -34
  84. package/esm2022/rendering/toolbar/tools/filter-tool-wrapper.component.mjs +29 -8
  85. package/esm2022/rendering/toolbar/tools/filter-toolbar-tool.component.mjs +78 -8
  86. package/esm2022/rendering/toolbar/tools/group-command-tool.directive.mjs +206 -0
  87. package/esm2022/rendering/toolbar/tools/group-toolbar-tool.component.mjs +425 -0
  88. package/esm2022/rendering/toolbar/tools/sort-command-tool.directive.mjs +54 -20
  89. package/esm2022/rendering/toolbar/tools/sort-toolbar-tool.component.mjs +24 -8
  90. package/esm2022/selection/selection.service.mjs +11 -0
  91. package/esm2022/state-management/grid-state.models.mjs +26 -0
  92. package/esm2022/state-management/redo-command-tool.mjs +66 -0
  93. package/esm2022/state-management/undo-command-tool.mjs +66 -0
  94. package/esm2022/state-management/undo-redo.directive.mjs +178 -0
  95. package/esm2022/state-management/undo-redo.service.mjs +22 -0
  96. package/esm2022/state-management/undo-redo.stack.mjs +232 -0
  97. package/esm2022/utils.mjs +13 -13
  98. package/excel/excel-command-tool.directive.d.ts +5 -5
  99. package/fesm2022/progress-kendo-angular-grid.mjs +7384 -3773
  100. package/filtering/filter-input.directive.d.ts +1 -0
  101. package/filtering/menu/date-filter-menu-input.component.d.ts +1 -1
  102. package/filtering/menu/filter-menu-container.component.d.ts +15 -4
  103. package/filtering/menu/filter-menu-input-wrapper.component.d.ts +8 -3
  104. package/filtering/menu/filter-menu.component.d.ts +6 -3
  105. package/filtering/menu/numeric-filter-menu-input.component.d.ts +1 -1
  106. package/filtering/menu/string-filter-menu-input.component.d.ts +1 -1
  107. package/filtering/menu/string-filter-menu.component.d.ts +1 -0
  108. package/grid.component.d.ts +86 -33
  109. package/grid.module.d.ts +108 -100
  110. package/index.d.ts +10 -1
  111. package/localization/messages.d.ts +86 -2
  112. package/navigation/toolbar-tool-name.d.ts +17 -0
  113. package/package.json +35 -20
  114. package/pdf/pdf-command-tool.directive.d.ts +6 -5
  115. package/rendering/cell.component.d.ts +1 -1
  116. package/{column-menu → rendering/toolbar/tools}/column-chooser-tool.directive.d.ts +18 -6
  117. package/rendering/toolbar/tools/filter-command-tool.directive.d.ts +10 -1
  118. package/rendering/toolbar/tools/filter-tool-wrapper.component.d.ts +6 -5
  119. package/rendering/toolbar/tools/filter-toolbar-tool.component.d.ts +11 -2
  120. package/rendering/toolbar/tools/group-command-tool.directive.d.ts +51 -0
  121. package/rendering/toolbar/tools/group-toolbar-tool.component.d.ts +61 -0
  122. package/rendering/toolbar/tools/sort-command-tool.directive.d.ts +10 -1
  123. package/rendering/toolbar/tools/sort-toolbar-tool.component.d.ts +5 -1
  124. package/schematics/ngAdd/index.js +4 -4
  125. package/selection/selection.service.d.ts +1 -0
  126. package/state-management/grid-state.models.d.ts +58 -0
  127. package/state-management/redo-command-tool.d.ts +38 -0
  128. package/state-management/undo-command-tool.d.ts +38 -0
  129. package/state-management/undo-redo.directive.d.ts +51 -0
  130. package/state-management/undo-redo.service.d.ts +19 -0
  131. package/state-management/undo-redo.stack.d.ts +104 -0
  132. package/utils.d.ts +11 -5
  133. package/esm2022/column-menu/column-chooser-tool.directive.mjs +0 -172
@@ -2,7 +2,7 @@
2
2
  * Copyright © 2025 Progress Software Corporation. All rights reserved.
3
3
  * Licensed under commercial license. See LICENSE.md in the project root for more information
4
4
  *-------------------------------------------------------------------------------------------*/
5
- import { Component, ElementRef, EventEmitter, Output, QueryList, ViewChildren } from '@angular/core';
5
+ import { Component, ElementRef, EventEmitter, NgZone, Output, QueryList, ViewChildren } from '@angular/core';
6
6
  import { ContextService } from '../../../common/provider.service';
7
7
  import { NgFor } from '@angular/common';
8
8
  import { KENDO_BUTTON } from '@progress/kendo-angular-buttons';
@@ -12,10 +12,13 @@ import { ColumnMenuItemComponent } from '../../../column-menu/column-menu-item.c
12
12
  import { ColumnMenuItemContentTemplateDirective } from '../../../column-menu/column-menu-item-content-template.directive';
13
13
  import { ColumnInfoService } from '../../../common/column-info.service';
14
14
  import { cloneFilters } from '../../../common/filter-descriptor-differ';
15
+ import { AdaptiveGridService } from '../../../common/adaptiveness.service';
16
+ import { take } from 'rxjs/operators';
15
17
  import * as i0 from "@angular/core";
16
18
  import * as i1 from "../../../filtering/filter.service";
17
19
  import * as i2 from "../../../common/provider.service";
18
20
  import * as i3 from "../../../common/column-info.service";
21
+ import * as i4 from "../../../common/adaptiveness.service";
19
22
  /**
20
23
  * @hidden
21
24
  */
@@ -24,6 +27,8 @@ export class FilterToolbarToolComponent {
24
27
  filterService;
25
28
  ctx;
26
29
  columnInfoService;
30
+ ngZone;
31
+ adaptiveGridService;
27
32
  filterItems;
28
33
  menuItems;
29
34
  filterContainers;
@@ -38,12 +43,44 @@ export class FilterToolbarToolComponent {
38
43
  columnMenuService;
39
44
  columns;
40
45
  filter;
46
+ isFilterApplied(column) {
47
+ if (!this.filter?.filters) {
48
+ return false;
49
+ }
50
+ if (Array.isArray(this.filter.filters)) {
51
+ for (const filterGroup of this.filter.filters) {
52
+ if (filterGroup.filters && Array.isArray(filterGroup.filters)) {
53
+ for (const filter of filterGroup.filters) {
54
+ if (filter.field === column.field) {
55
+ return true;
56
+ }
57
+ }
58
+ }
59
+ else if (filterGroup.field === column.field) {
60
+ return true;
61
+ }
62
+ }
63
+ }
64
+ return false;
65
+ }
66
+ isItemFocused(filterItem) {
67
+ return this.currentFocusedItem === filterItem;
68
+ }
69
+ onItemFocus(item) {
70
+ this.currentFocusedItem = item;
71
+ }
72
+ onItemFocusOut() {
73
+ this.currentFocusedItem = null;
74
+ }
75
+ currentFocusedItem = null;
41
76
  subscriptions;
42
- constructor(element, filterService, ctx, columnInfoService) {
77
+ constructor(element, filterService, ctx, columnInfoService, ngZone, adaptiveGridService) {
43
78
  this.element = element;
44
79
  this.filterService = filterService;
45
80
  this.ctx = ctx;
46
81
  this.columnInfoService = columnInfoService;
82
+ this.ngZone = ngZone;
83
+ this.adaptiveGridService = adaptiveGridService;
47
84
  }
48
85
  ngOnInit() {
49
86
  this.columns = this.columnInfoService.leafNamedColumns.filter(column => column?.filterable);
@@ -53,19 +90,40 @@ export class FilterToolbarToolComponent {
53
90
  });
54
91
  }
55
92
  ngAfterViewInit() {
56
- this.filterItems?.get(0)?.nativeElement.focus();
93
+ this.ngZone.onStable.pipe(take(1)).subscribe(() => {
94
+ this.filterItems?.get(0)?.nativeElement.focus();
95
+ });
57
96
  }
58
97
  ngOnDestroy() {
59
98
  if (this.subscriptions) {
60
99
  this.subscriptions.unsubscribe();
61
100
  }
62
101
  }
102
+ navigateView(column) {
103
+ if (this.ctx.grid.isActionSheetExpanded && this.adaptiveGridService.viewType === 'filterToolbarTool') {
104
+ const componentRef = this.ctx.grid.adaptiveRenderer.filterToolbarToolTemplate.createComponent(FilterMenuContainerComponent);
105
+ componentRef.instance.column = this.getColumnComponent(column);
106
+ componentRef.instance.filter = this.filter;
107
+ this.subscriptions.add(componentRef.instance.close.subscribe(() => {
108
+ this.adaptiveGridService.reset();
109
+ }));
110
+ this.adaptiveGridService.filterMenuContainerComponentRef = componentRef;
111
+ this.adaptiveGridService.secondaryView = 'columnFilter';
112
+ this.adaptiveGridService.column = this.getColumnComponent(column);
113
+ this.ctx.grid.adaptiveRenderer.actionSheet.nextView();
114
+ }
115
+ }
63
116
  getColumnComponent(column) {
64
117
  return column;
65
118
  }
66
119
  handleClose(filterItem) {
67
120
  filterItem.expanded = false;
68
121
  filterItem.contentState = 'collapsed';
122
+ const filterContainer = this.filterContainers.find(container => container.column === filterItem.column);
123
+ if (filterContainer) {
124
+ // reset the child filter to ensure it is reinitialized based on the global filter on the next open
125
+ filterContainer.resetChildFilters();
126
+ }
69
127
  }
70
128
  toggleItem(event, index) {
71
129
  const menuItem = this.menuItems.get(index);
@@ -83,16 +141,22 @@ export class FilterToolbarToolComponent {
83
141
  menuItem.contentState = 'expanded';
84
142
  }
85
143
  }
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 });
144
+ 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 }, { token: i0.NgZone }, { token: i4.AdaptiveGridService }], target: i0.ɵɵFactoryTarget.Component });
87
145
  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
146
  <div [style]="hostStyles">
89
147
  <kendo-grid-columnmenu-item *ngFor="let column of columns; let i = index"
90
148
  class="k-columnmenu-item-wrapper" #filterItem
91
149
  role="button"
92
150
  tabindex="0"
151
+ [column]="getColumnComponent(column)"
93
152
  [text]="column.title || getColumnComponent(column).field"
153
+ (focus)="onItemFocus(filterItem)"
154
+ (focusout)="onItemFocusOut()"
94
155
  (keydown.enter)="toggleItem($event, i)"
95
- [expanded]="false">
156
+ [indicatorIcon]="isFilterApplied(column)"
157
+ (itemClick)="navigateView(getColumnComponent(column))"
158
+ [expanded]="false"
159
+ [focused]="isItemFocused(filterItem)">
96
160
  <ng-template kendoGridColumnMenuItemContentTemplate>
97
161
  <kendo-grid-filter-menu-container
98
162
  #filterContainer
@@ -105,7 +169,7 @@ export class FilterToolbarToolComponent {
105
169
  </ng-template>
106
170
  </kendo-grid-columnmenu-item>
107
171
  </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]" }] });
172
+ `, 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", "indicatorIcon", "text", "selected", "disabled", "expanded", "focused", "service", "column"], outputs: ["itemClick", "expand", "collapse"] }, { kind: "directive", type: ColumnMenuItemContentTemplateDirective, selector: "[kendoGridColumnMenuItemContentTemplate]" }] });
109
173
  }
110
174
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: FilterToolbarToolComponent, decorators: [{
111
175
  type: Component,
@@ -117,9 +181,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
117
181
  class="k-columnmenu-item-wrapper" #filterItem
118
182
  role="button"
119
183
  tabindex="0"
184
+ [column]="getColumnComponent(column)"
120
185
  [text]="column.title || getColumnComponent(column).field"
186
+ (focus)="onItemFocus(filterItem)"
187
+ (focusout)="onItemFocusOut()"
121
188
  (keydown.enter)="toggleItem($event, i)"
122
- [expanded]="false">
189
+ [indicatorIcon]="isFilterApplied(column)"
190
+ (itemClick)="navigateView(getColumnComponent(column))"
191
+ [expanded]="false"
192
+ [focused]="isItemFocused(filterItem)">
123
193
  <ng-template kendoGridColumnMenuItemContentTemplate>
124
194
  <kendo-grid-filter-menu-container
125
195
  #filterContainer
@@ -136,7 +206,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
136
206
  standalone: true,
137
207
  imports: [NgFor, KENDO_BUTTON, FilterMenuContainerComponent, ColumnMenuItemComponent, ColumnMenuItemContentTemplateDirective]
138
208
  }]
139
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i1.FilterService }, { type: i2.ContextService }, { type: i3.ColumnInfoService }]; }, propDecorators: { filterItems: [{
209
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i1.FilterService }, { type: i2.ContextService }, { type: i3.ColumnInfoService }, { type: i0.NgZone }, { type: i4.AdaptiveGridService }]; }, propDecorators: { filterItems: [{
140
210
  type: ViewChildren,
141
211
  args: ['filterItem', { read: ElementRef }]
142
212
  }], menuItems: [{
@@ -0,0 +1,206 @@
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 { groupIcon } 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 { take } from 'rxjs/operators';
13
+ import { AdaptiveGridService } from '../../../common/adaptiveness.service';
14
+ import { GroupToolbarToolComponent } from './group-toolbar-tool.component';
15
+ import * as i0 from "@angular/core";
16
+ import * as i1 from "@progress/kendo-angular-toolbar";
17
+ import * as i2 from "@progress/kendo-angular-popup";
18
+ import * as i3 from "../../../common/provider.service";
19
+ import * as i4 from "../../../common/adaptiveness.service";
20
+ let incrementingId = 0;
21
+ /**
22
+ * Represents the toolbar tool for grouping columns of the Grid.
23
+ * You can apply this directive to any `kendo-toolbar-button` element inside a
24
+ * ToolbarComponent used in the Grid.
25
+ *
26
+ * @example
27
+ * ```html-no-run
28
+ * <kendo-grid>
29
+ * <kendo-toolbar>
30
+ * <kendo-toolbar-button text="Group" kendoGridGroupTool></kendo-toolbar-button>
31
+ * </kendo-toolbar>
32
+ * </kendo-grid>
33
+ * ```
34
+ */
35
+ export class GroupCommandToolbarDirective {
36
+ host;
37
+ popupService;
38
+ ctx;
39
+ ngZone;
40
+ renderer;
41
+ adaptiveGridService;
42
+ popupRef;
43
+ nextId = incrementingId++;
44
+ toolSubs = new Subscription();
45
+ popupSubs;
46
+ actionSheetCloseSub;
47
+ removeClickListener;
48
+ constructor(host, popupService, ctx, ngZone, renderer, adaptiveGridService) {
49
+ this.host = host;
50
+ this.popupService = popupService;
51
+ this.ctx = ctx;
52
+ this.ngZone = ngZone;
53
+ this.renderer = renderer;
54
+ this.adaptiveGridService = adaptiveGridService;
55
+ }
56
+ ngOnInit() {
57
+ this.toolSubs = this.host.click.subscribe(e => this.onClick(e));
58
+ this.toolSubs.add(this.ctx.grid.groupChange.subscribe(group => {
59
+ this.host.showBadge = this.isGroupingApplied(group);
60
+ }));
61
+ this.host.hasBadgeContainer = true;
62
+ this.host.showBadge = this.isGroupingApplied(this.ctx.grid.group);
63
+ const hasToolbarIcon = isPresent(this.host.toolbarOptions.icon) && this.host.toolbarOptions.icon !== '';
64
+ const hasOverflowIcon = isPresent(this.host.overflowOptions.icon) && this.host.overflowOptions.icon !== '';
65
+ const hasIcon = hasToolbarIcon && hasOverflowIcon;
66
+ const hasSvgIcon = isPresent(this.host.toolbarOptions.svgIcon) && isPresent(this.host.overflowOptions.svgIcon);
67
+ if (!hasIcon) {
68
+ this.host.icon = 'group';
69
+ }
70
+ if (!hasSvgIcon) {
71
+ this.host.svgIcon = groupIcon;
72
+ }
73
+ }
74
+ ngAfterViewInit() {
75
+ if (!isPresent(this.host.text)) {
76
+ this.ngZone.onStable.pipe(take(1)).subscribe(() => {
77
+ this.host.text = this.ctx.localization.get(`groupToolbarToolText`);
78
+ });
79
+ }
80
+ this.buttonElement?.setAttribute('aria-haspopup', 'dialog');
81
+ this.buttonElement?.setAttribute('aria-expanded', 'false');
82
+ this.buttonElement?.setAttribute('title', this.ctx.localization.get('groupToolbarToolText'));
83
+ }
84
+ ngOnDestroy() {
85
+ if (this.toolSubs) {
86
+ this.toolSubs.unsubscribe();
87
+ }
88
+ if (this.popupSubs) {
89
+ this.popupSubs.unsubscribe();
90
+ }
91
+ if (this.popupRef) {
92
+ this.popupRef.close();
93
+ this.popupRef = null;
94
+ }
95
+ if (this.actionSheetCloseSub) {
96
+ this.actionSheetCloseSub.unsubscribe();
97
+ this.actionSheetCloseSub = null;
98
+ }
99
+ if (this.removeClickListener) {
100
+ this.removeClickListener();
101
+ this.removeClickListener = null;
102
+ }
103
+ }
104
+ onClick(e) {
105
+ e.preventDefault();
106
+ if (this.ctx.grid.adaptiveMode === 'auto' && this.adaptiveGridService.windowSize !== 'large') {
107
+ if (!this.ctx.grid.isActionSheetExpanded) {
108
+ this.adaptiveGridService.viewType = 'groupToolbarTool';
109
+ this.ctx.grid.adaptiveRenderer.actionSheet.toggle(true);
110
+ this.host.selected = true;
111
+ this.actionSheetCloseSub = this.ctx.grid.adaptiveRenderer.actionSheet.collapse.subscribe(() => this.host.selected = false);
112
+ }
113
+ }
114
+ else {
115
+ if (this.popupRef) {
116
+ this.closePopup();
117
+ return;
118
+ }
119
+ this.openPopup();
120
+ }
121
+ }
122
+ openPopup() {
123
+ const direction = this.ctx.localization.rtl ? 'right' : 'left';
124
+ this.popupRef = this.popupService.open({
125
+ anchor: this.buttonElement,
126
+ content: GroupToolbarToolComponent,
127
+ popupClass: 'k-grid-columnmenu-popup',
128
+ positionMode: 'absolute',
129
+ anchorAlign: { vertical: 'bottom', horizontal: direction },
130
+ popupAlign: { vertical: 'top', horizontal: direction }
131
+ });
132
+ this.adaptiveGridService.popupRef = this.popupRef;
133
+ this.setPopupAttributes();
134
+ this.host.selected = true;
135
+ this.ngZone.runOutsideAngular(() => {
136
+ if (!isDocumentAvailable()) {
137
+ return;
138
+ }
139
+ this.removeClickListener = this.renderer.listen('document', 'click', (e) => {
140
+ if (this.popupRef && !closest(e.target, node => node === this.popupRef.popupElement || node === this.buttonElement)) {
141
+ this.ngZone.run(() => {
142
+ this.closePopup();
143
+ });
144
+ }
145
+ });
146
+ });
147
+ this.popupSubs = this.popupRef.popup.instance.anchorViewportLeave.subscribe(() => {
148
+ this.popupSubs?.unsubscribe();
149
+ this.popupSubs = null;
150
+ this.closePopup();
151
+ });
152
+ this.initPopupProperties();
153
+ }
154
+ setPopupAttributes() {
155
+ const popupElement = this.popupRef.popupElement;
156
+ const popupId = `k-group-tool-${this.nextId}-popup`;
157
+ const popupAriaElement = popupElement.querySelector('.k-popup');
158
+ this.renderer.setAttribute(popupElement, 'dir', this.ctx.localization.rtl ? 'rtl' : 'ltr');
159
+ this.renderer.setAttribute(popupAriaElement, 'id', popupId);
160
+ this.renderer.setAttribute(popupAriaElement, 'role', 'dialog');
161
+ this.buttonElement?.setAttribute('aria-expanded', 'true');
162
+ this.buttonElement?.setAttribute('aria-controls', popupId);
163
+ }
164
+ initPopupProperties() {
165
+ this.popupRef.content.instance.ctx = this.ctx;
166
+ this.popupRef.content.instance.hostButton = this.host;
167
+ this.popupSubs.add(this.popupRef.content.instance.groupClear.subscribe(() => {
168
+ this.closePopup();
169
+ }));
170
+ this.popupSubs.add(this.popupRef.content.instance.close.subscribe(() => {
171
+ this.closePopup();
172
+ }));
173
+ }
174
+ closePopup() {
175
+ this.buttonElement?.setAttribute('aria-expanded', 'false');
176
+ this.buttonElement?.removeAttribute('aria-controls');
177
+ this.host.selected = false;
178
+ if (this.popupRef) {
179
+ this.popupRef.close();
180
+ this.popupRef = null;
181
+ }
182
+ if (this.popupSubs) {
183
+ this.popupSubs.unsubscribe();
184
+ this.popupSubs = null;
185
+ }
186
+ if (this.removeClickListener) {
187
+ this.removeClickListener();
188
+ this.removeClickListener = null;
189
+ }
190
+ }
191
+ get buttonElement() {
192
+ return this.host.getButton();
193
+ }
194
+ isGroupingApplied(group) {
195
+ return isPresent(group) && group.length > 0;
196
+ }
197
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: GroupCommandToolbarDirective, deps: [{ token: i1.ToolBarButtonComponent }, { token: i2.PopupService }, { token: i3.ContextService }, { token: i0.NgZone }, { token: i0.Renderer2 }, { token: i4.AdaptiveGridService }], target: i0.ɵɵFactoryTarget.Directive });
198
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: GroupCommandToolbarDirective, isStandalone: true, selector: "[kendoGridGroupTool]", ngImport: i0 });
199
+ }
200
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: GroupCommandToolbarDirective, decorators: [{
201
+ type: Directive,
202
+ args: [{
203
+ selector: '[kendoGridGroupTool]',
204
+ standalone: true
205
+ }]
206
+ }], ctorParameters: function () { return [{ type: i1.ToolBarButtonComponent }, { type: i2.PopupService }, { type: i3.ContextService }, { type: i0.NgZone }, { type: i0.Renderer2 }, { type: i4.AdaptiveGridService }]; } });