@progress/kendo-angular-filter 2.2.3-dev.202210120943 → 2.3.0

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 (33) hide show
  1. package/aria-label.directive.d.ts +1 -1
  2. package/base-filter-row.component.d.ts +28 -0
  3. package/bundles/kendo-angular-filter.umd.js +1 -1
  4. package/editors/boolean-editor.component.d.ts +1 -0
  5. package/editors/date-editor.component.d.ts +1 -0
  6. package/editors/numeric-editor.component.d.ts +1 -0
  7. package/editors/text-editor.component.d.ts +1 -0
  8. package/error-messages.d.ts +8 -0
  9. package/esm2015/aria-label.directive.js +2 -2
  10. package/esm2015/base-filter-row.component.js +69 -0
  11. package/esm2015/editors/boolean-editor.component.js +10 -4
  12. package/esm2015/editors/date-editor.component.js +10 -4
  13. package/esm2015/editors/numeric-editor.component.js +10 -4
  14. package/esm2015/editors/text-editor.component.js +10 -4
  15. package/esm2015/error-messages.js +16 -0
  16. package/esm2015/filter-expression-operators.component.js +2 -0
  17. package/esm2015/filter-expression.component.js +60 -47
  18. package/esm2015/filter-group.component.js +76 -38
  19. package/esm2015/filter.component.js +107 -32
  20. package/esm2015/filter.module.js +2 -1
  21. package/esm2015/localization/messages.js +3 -3
  22. package/esm2015/navigation.service.js +159 -0
  23. package/esm2015/package-metadata.js +1 -1
  24. package/esm2015/util.js +33 -0
  25. package/fesm2015/kendo-angular-filter.js +523 -122
  26. package/filter-expression.component.d.ts +7 -10
  27. package/filter-group.component.d.ts +11 -10
  28. package/filter.component.d.ts +24 -4
  29. package/localization/messages.d.ts +3 -3
  30. package/model/filter-expression.d.ts +1 -1
  31. package/navigation.service.d.ts +40 -0
  32. package/package.json +1 -1
  33. package/util.d.ts +12 -0
@@ -0,0 +1,159 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ import { Injectable } from '@angular/core';
6
+ import { Keys } from '@progress/kendo-angular-common';
7
+ import { selectors } from './util';
8
+ import * as i0 from "@angular/core";
9
+ /**
10
+ * @hidden
11
+ */
12
+ export class NavigationService {
13
+ constructor(cdr, renderer) {
14
+ this.cdr = cdr;
15
+ this.renderer = renderer;
16
+ this.hierarchicalFilterItems = [];
17
+ this.flattenFilterItems = [];
18
+ this.currentToolbarItemIndex = 0;
19
+ this.currentToolbarItemChildrenIndex = 0;
20
+ this.isInnerNavigationActivated = false;
21
+ this.isFilterExpressionComponentFocused = false;
22
+ }
23
+ processKeyDown(key, event) {
24
+ switch (key) {
25
+ case Keys.ArrowUp:
26
+ event.preventDefault();
27
+ if (!this.isInnerNavigationActivated) {
28
+ this.currentToolbarItemIndex > 0 ? this.currentToolbarItemIndex-- : this.currentToolbarItemIndex;
29
+ const elementToFocus = this.flattenFilterItems[this.currentToolbarItemIndex].toolbarElement;
30
+ this.focusCurrentElement(elementToFocus);
31
+ }
32
+ break;
33
+ case Keys.ArrowDown:
34
+ event.preventDefault();
35
+ if (!this.isInnerNavigationActivated) {
36
+ this.currentToolbarItemIndex < this.flattenFilterItems.length - 1 ? this.currentToolbarItemIndex++ : this.currentToolbarItemIndex;
37
+ const elementToFocus = this.flattenFilterItems[this.currentToolbarItemIndex].toolbarElement;
38
+ this.focusCurrentElement(elementToFocus);
39
+ }
40
+ break;
41
+ case Keys.Enter:
42
+ const isEventTargetFilterToolbar = event.target.closest(selectors.kendoToolbar);
43
+ if (!this.isInnerNavigationActivated && isEventTargetFilterToolbar) {
44
+ event.preventDefault();
45
+ this.isInnerNavigationActivated = true;
46
+ this.currentToolbarItemChildrenIndex = 0;
47
+ const elementToFocus = this.flattenFilterItems[this.currentToolbarItemIndex].focusableChildren[this.currentToolbarItemChildrenIndex];
48
+ this.focusCurrentElement(elementToFocus);
49
+ }
50
+ const isEventTargetKendoFilterToolbarItem = event.target.closest(selectors.kendoFilterToolbarItem);
51
+ const isEventTargetButton = event.target.closest(selectors.kendoButton);
52
+ if (this.isInnerNavigationActivated &&
53
+ !this.isFilterExpressionComponentFocused &&
54
+ isEventTargetKendoFilterToolbarItem &&
55
+ !isEventTargetButton) {
56
+ event.preventDefault();
57
+ this.isFilterExpressionComponentFocused = true;
58
+ const focusableElement = this.flattenFilterItems[this.currentToolbarItemIndex].focusableChildren[this.currentToolbarItemChildrenIndex];
59
+ const elementToFocus = focusableElement.querySelector(selectors.KendoDropDownListComponent) ||
60
+ focusableElement.querySelector(selectors.kendoInputInner) ||
61
+ focusableElement.querySelector(selectors.inputElement) ||
62
+ focusableElement.querySelector(selectors.textAreaElement);
63
+ this.focusCurrentElement(elementToFocus);
64
+ }
65
+ break;
66
+ case Keys.Escape:
67
+ if (this.isInnerNavigationActivated && !this.isFilterExpressionComponentFocused) {
68
+ event.preventDefault();
69
+ this.isInnerNavigationActivated = false;
70
+ this.currentToolbarItemChildrenIndex = 0;
71
+ const elementToFocus = this.flattenFilterItems[this.currentToolbarItemIndex].toolbarElement;
72
+ this.focusCurrentElement(elementToFocus);
73
+ }
74
+ if (this.isFilterExpressionComponentFocused) {
75
+ event.preventDefault();
76
+ this.isFilterExpressionComponentFocused = false;
77
+ this.isInnerNavigationActivated = true;
78
+ const elementToFocus = this.flattenFilterItems[this.currentToolbarItemIndex].focusableChildren[this.currentToolbarItemChildrenIndex];
79
+ this.focusCurrentElement(elementToFocus);
80
+ }
81
+ break;
82
+ case Keys.ArrowRight:
83
+ if (this.isInnerNavigationActivated && !this.isFilterExpressionComponentFocused) {
84
+ event.preventDefault();
85
+ this.currentToolbarItemChildrenIndex < this.flattenFilterItems[this.currentToolbarItemIndex].focusableChildren.length - 1 ? this.currentToolbarItemChildrenIndex++ : this.currentToolbarItemChildrenIndex;
86
+ const elementToFocus = this.flattenFilterItems[this.currentToolbarItemIndex].focusableChildren[this.currentToolbarItemChildrenIndex];
87
+ this.focusCurrentElement(elementToFocus);
88
+ }
89
+ break;
90
+ case Keys.ArrowLeft:
91
+ if (this.isInnerNavigationActivated && !this.isFilterExpressionComponentFocused) {
92
+ event.preventDefault();
93
+ this.currentToolbarItemChildrenIndex > 0 ? this.currentToolbarItemChildrenIndex-- : this.currentToolbarItemChildrenIndex;
94
+ const elementToFocus = this.flattenFilterItems[this.currentToolbarItemIndex].focusableChildren[this.currentToolbarItemChildrenIndex];
95
+ this.focusCurrentElement(elementToFocus);
96
+ }
97
+ break;
98
+ default:
99
+ break;
100
+ }
101
+ }
102
+ focusCurrentElement(element, isOnMouseDown) {
103
+ this.renderer.setAttribute(this.currentlyFocusedElement, 'tabindex', '-1');
104
+ this.currentlyFocusedElement = element;
105
+ if (element) {
106
+ this.renderer.setAttribute(this.currentlyFocusedElement, 'tabindex', '0');
107
+ if (!isOnMouseDown) {
108
+ this.currentlyFocusedElement.focus();
109
+ }
110
+ }
111
+ }
112
+ flattenHierarchicalFilterItems(filterItems) {
113
+ filterItems.forEach((filterRow) => {
114
+ var _a, _b;
115
+ let flattenItem = { component: filterRow, isGroup: false, toolbarElement: filterRow.toolbarElement, focusableChildren: [] };
116
+ this.flattenFilterItems.push(flattenItem);
117
+ if ((filterRow['operators'] && ((_a = filterRow['filterItems']) === null || _a === void 0 ? void 0 : _a.length) > 0)) {
118
+ this.setGroupItemChildren(flattenItem, filterRow);
119
+ this.flattenHierarchicalFilterItems(filterRow['filterItems']);
120
+ }
121
+ else if (filterRow['operators'] && ((_b = filterRow['filterItems']) === null || _b === void 0 ? void 0 : _b.length) === 0) {
122
+ this.setGroupItemChildren(flattenItem, filterRow);
123
+ }
124
+ else {
125
+ flattenItem.focusableChildren.push(filterRow.toolbarElement.querySelector(selectors.filterFieldWrapper));
126
+ if (filterRow.toolbarElement.querySelector('.k-filter-operator')) {
127
+ flattenItem.focusableChildren.push(filterRow.toolbarElement.querySelector(selectors.filterOperatorWrapper));
128
+ }
129
+ flattenItem.focusableChildren.push(filterRow.toolbarElement.querySelector(selectors.filterValueEditorWrapper));
130
+ flattenItem.focusableChildren.push(filterRow.toolbarElement.querySelector(selectors.removeButton));
131
+ }
132
+ });
133
+ }
134
+ setGroupItemChildren(flattenItem, filterRow) {
135
+ flattenItem.isGroup = true;
136
+ flattenItem.focusableChildren.push(filterRow.toolbarElement.querySelector(selectors.andButton));
137
+ flattenItem.focusableChildren.push(filterRow.toolbarElement.querySelector(selectors.orButton));
138
+ flattenItem.focusableChildren.push(filterRow.toolbarElement.querySelector(selectors.addFilterButton));
139
+ flattenItem.focusableChildren.push(filterRow.toolbarElement.querySelector(selectors.addGroupButton));
140
+ flattenItem.focusableChildren.push(filterRow.toolbarElement.querySelector(selectors.removeButton));
141
+ }
142
+ setItemIndexes() {
143
+ this.flattenFilterItems.forEach((item, index) => {
144
+ item.component['itemNumber'] = index;
145
+ });
146
+ this.cdr.detectChanges();
147
+ }
148
+ reset(items) {
149
+ this.flattenFilterItems = [];
150
+ this.hierarchicalFilterItems = items;
151
+ this.flattenHierarchicalFilterItems(items);
152
+ this.setItemIndexes();
153
+ }
154
+ }
155
+ NavigationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: NavigationService, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Injectable });
156
+ NavigationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: NavigationService });
157
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: NavigationService, decorators: [{
158
+ type: Injectable
159
+ }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: i0.Renderer2 }]; } });
@@ -9,7 +9,7 @@ export const packageMetadata = {
9
9
  name: '@progress/kendo-angular-filter',
10
10
  productName: 'Kendo UI for Angular',
11
11
  productCodes: ['KENDOUIANGULAR', 'KENDOUICOMPLETE'],
12
- publishDate: 1665567772,
12
+ publishDate: 1666694566,
13
13
  version: '',
14
14
  licensingDocsUrl: 'https://www.telerik.com/kendo-angular-ui/my-license/?utm_medium=product&utm_source=kendoangular&utm_campaign=kendo-ui-angular-purchase-license-keys-warning'
15
15
  };
package/esm2015/util.js CHANGED
@@ -2,6 +2,8 @@
2
2
  * Copyright © 2021 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 { Injectable } from '@angular/core';
6
+ import * as i0 from "@angular/core";
5
7
  /**
6
8
  * @hidden
7
9
  */
@@ -138,3 +140,34 @@ export const localizeOperators = operators => localization => Object.keys(operat
138
140
  * @hidden
139
141
  */
140
142
  export const isPresent = (value) => value !== null && value !== undefined;
143
+ /**
144
+ * @hidden
145
+ */
146
+ export class FilterItem {
147
+ }
148
+ FilterItem.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FilterItem, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
149
+ FilterItem.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FilterItem });
150
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FilterItem, decorators: [{
151
+ type: Injectable
152
+ }] });
153
+ /**
154
+ * @hidden
155
+ */
156
+ export const selectors = {
157
+ andButton: `button.k-group-start`,
158
+ orButton: `button.k-group-end`,
159
+ addFilterButton: `button[icon="filter-add-expression"]`,
160
+ addGroupButton: `button[icon="filter-add-group"]`,
161
+ removeButton: `button[icon="x"]`,
162
+ filterFieldWrapper: `.k-filter-field`,
163
+ filterOperatorWrapper: `.k-filter-operator`,
164
+ filterValueEditorWrapper: `.k-filter-value`,
165
+ kendoDropDownListComponent: `kendo-dropdownlist`,
166
+ kendoInput: `.k-input`,
167
+ kendoInputInner: `.k-input-inner`,
168
+ inputElement: `input`,
169
+ textAreaElement: `textarea`,
170
+ kendoToolbar: `.k-toolbar`,
171
+ kendoButton: `.k-button`,
172
+ kendoFilterToolbarItem: `.k-filter-toolbar-item`
173
+ };