@progress/kendo-angular-gantt 0.3.0-dev.202201111723 → 1.0.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 (138) hide show
  1. package/dist/cdn/js/kendo-angular-gantt.js +2 -2
  2. package/dist/cdn/main.js +1 -29
  3. package/dist/es/common/touch-enabled.js +9 -0
  4. package/dist/es/dependencies/utils.js +34 -0
  5. package/dist/es/dragging/dependency-drag-create.directive.js +347 -0
  6. package/dist/es/dragging/drag-validation-tooltip.component.js +27 -0
  7. package/dist/es/editing/dependencies-table.component.js +1 -1
  8. package/dist/es/editing/edit-dialog.component.js +3 -3
  9. package/dist/es/editing/edit.service.js +4 -2
  10. package/dist/es/editing/task-fields.component.js +1 -1
  11. package/dist/es/editing/{util.js → utils.js} +0 -0
  12. package/dist/es/gantt.component.js +313 -28
  13. package/dist/es/gantt.module.js +23 -6
  14. package/dist/es/index.js +5 -0
  15. package/dist/es/main.js +1 -0
  16. package/dist/es/models/events/dependency-add-event.interface.js +4 -0
  17. package/dist/es/models/events/task-delete-event.interface.js +4 -0
  18. package/dist/es/models/view-item.interface.js +4 -0
  19. package/dist/es/navigation/navigation-models.js +4 -0
  20. package/dist/es/navigation/navigation.service.js +390 -0
  21. package/dist/es/navigation/utils.js +77 -0
  22. package/dist/es/package-metadata.js +1 -1
  23. package/dist/es/rendering/gantt-milestone-task.component.js +12 -6
  24. package/dist/es/rendering/gantt-summary-task.component.js +27 -6
  25. package/dist/es/rendering/gantt-task-base.js +84 -22
  26. package/dist/es/rendering/gantt-task.component.js +13 -8
  27. package/dist/es/rendering/gantt-tasks-table-body.component.js +13 -5
  28. package/dist/es/scrolling/drag-scroll-settings.js +20 -0
  29. package/dist/es/scrolling/timeline-scroll.directive.js +89 -0
  30. package/dist/es/scrolling/timeline-scroll.service.js +39 -0
  31. package/dist/es/scrolling/utils.js +80 -0
  32. package/dist/es/timeline/gantt-timeline.component.js +50 -4
  33. package/dist/es/toolbar/toolbar.component.js +12 -13
  34. package/dist/es/toolbar/view-selector.component.js +1 -1
  35. package/dist/es/utils.js +153 -12
  36. package/dist/es2015/common/touch-enabled.d.ts +9 -0
  37. package/dist/es2015/common/touch-enabled.js +9 -0
  38. package/dist/es2015/dependencies/utils.d.ts +15 -0
  39. package/dist/es2015/dependencies/utils.js +34 -0
  40. package/dist/es2015/dragging/dependency-drag-create.directive.d.ts +72 -0
  41. package/dist/es2015/dragging/dependency-drag-create.directive.js +324 -0
  42. package/dist/es2015/dragging/drag-validation-tooltip.component.d.ts +29 -0
  43. package/dist/es2015/dragging/drag-validation-tooltip.component.js +76 -0
  44. package/dist/es2015/editing/dependencies-table.component.js +1 -1
  45. package/dist/es2015/editing/edit-dialog.component.d.ts +1 -1
  46. package/dist/es2015/editing/edit-dialog.component.js +12 -4
  47. package/dist/es2015/editing/edit.service.d.ts +2 -3
  48. package/dist/es2015/editing/edit.service.js +4 -2
  49. package/dist/es2015/editing/task-fields.component.js +1 -1
  50. package/dist/es2015/editing/{util.d.ts → utils.d.ts} +2 -2
  51. package/dist/es2015/editing/{util.js → utils.js} +0 -0
  52. package/dist/es2015/gantt.component.d.ts +112 -17
  53. package/dist/es2015/gantt.component.js +292 -30
  54. package/dist/es2015/gantt.module.js +23 -6
  55. package/dist/es2015/index.d.ts +5 -0
  56. package/dist/es2015/index.js +5 -0
  57. package/dist/es2015/index.metadata.json +1 -1
  58. package/dist/es2015/main.d.ts +1 -0
  59. package/dist/es2015/main.js +1 -0
  60. package/dist/es2015/models/events/dependency-add-event.interface.d.ts +26 -0
  61. package/dist/es2015/models/events/dependency-add-event.interface.js +4 -0
  62. package/dist/es2015/models/events/task-click-event.interface.d.ts +3 -3
  63. package/dist/es2015/models/events/task-delete-event.interface.d.ts +21 -0
  64. package/dist/es2015/models/events/task-delete-event.interface.js +4 -0
  65. package/dist/es2015/models/events/task-edit-event.interface.d.ts +27 -10
  66. package/dist/es2015/models/models.d.ts +4 -0
  67. package/dist/es2015/models/view-item.interface.d.ts +35 -0
  68. package/dist/es2015/models/view-item.interface.js +4 -0
  69. package/dist/es2015/navigation/navigation-models.d.ts +34 -0
  70. package/dist/es2015/navigation/navigation-models.js +4 -0
  71. package/dist/es2015/navigation/navigation.service.d.ts +126 -0
  72. package/dist/es2015/navigation/navigation.service.js +355 -0
  73. package/dist/es2015/navigation/utils.d.ts +26 -0
  74. package/dist/es2015/navigation/utils.js +69 -0
  75. package/dist/es2015/package-metadata.js +1 -1
  76. package/dist/es2015/rendering/gantt-milestone-task.component.d.ts +3 -1
  77. package/dist/es2015/rendering/gantt-milestone-task.component.js +35 -8
  78. package/dist/es2015/rendering/gantt-summary-task.component.d.ts +5 -1
  79. package/dist/es2015/rendering/gantt-summary-task.component.js +47 -8
  80. package/dist/es2015/rendering/gantt-task-base.d.ts +20 -6
  81. package/dist/es2015/rendering/gantt-task-base.js +75 -22
  82. package/dist/es2015/rendering/gantt-task.component.d.ts +4 -2
  83. package/dist/es2015/rendering/gantt-task.component.js +47 -13
  84. package/dist/es2015/rendering/gantt-tasks-table-body.component.d.ts +6 -3
  85. package/dist/es2015/rendering/gantt-tasks-table-body.component.js +27 -9
  86. package/dist/es2015/scrolling/drag-scroll-settings.d.ts +47 -0
  87. package/dist/es2015/scrolling/drag-scroll-settings.js +20 -0
  88. package/dist/es2015/scrolling/scroll-sync.service.d.ts +1 -1
  89. package/dist/es2015/scrolling/timeline-scroll.directive.d.ts +24 -0
  90. package/dist/es2015/scrolling/timeline-scroll.directive.js +78 -0
  91. package/dist/es2015/scrolling/timeline-scroll.service.d.ts +20 -0
  92. package/dist/es2015/scrolling/timeline-scroll.service.js +44 -0
  93. package/dist/es2015/scrolling/utils.d.ts +29 -0
  94. package/dist/es2015/scrolling/utils.js +80 -0
  95. package/dist/es2015/timeline/gantt-timeline.component.d.ts +29 -4
  96. package/dist/es2015/timeline/gantt-timeline.component.js +67 -5
  97. package/dist/es2015/toolbar/toolbar.component.d.ts +4 -5
  98. package/dist/es2015/toolbar/toolbar.component.js +12 -13
  99. package/dist/es2015/toolbar/view-selector.component.js +3 -1
  100. package/dist/es2015/utils.d.ts +77 -8
  101. package/dist/es2015/utils.js +153 -12
  102. package/dist/fesm2015/index.js +3033 -1367
  103. package/dist/fesm5/index.js +2447 -830
  104. package/dist/npm/common/touch-enabled.js +11 -0
  105. package/dist/npm/dependencies/utils.js +34 -0
  106. package/dist/npm/dragging/dependency-drag-create.directive.js +349 -0
  107. package/dist/npm/dragging/drag-validation-tooltip.component.js +29 -0
  108. package/dist/npm/editing/dependencies-table.component.js +1 -1
  109. package/dist/npm/editing/edit-dialog.component.js +3 -3
  110. package/dist/npm/editing/edit.service.js +4 -2
  111. package/dist/npm/editing/task-fields.component.js +1 -1
  112. package/dist/npm/editing/{util.js → utils.js} +0 -0
  113. package/dist/npm/gantt.component.js +315 -30
  114. package/dist/npm/gantt.module.js +22 -5
  115. package/dist/npm/index.js +10 -0
  116. package/dist/npm/main.js +2 -0
  117. package/dist/npm/models/events/dependency-add-event.interface.js +6 -0
  118. package/dist/npm/models/events/task-delete-event.interface.js +6 -0
  119. package/dist/npm/models/view-item.interface.js +6 -0
  120. package/dist/npm/navigation/navigation-models.js +6 -0
  121. package/dist/npm/navigation/navigation.service.js +392 -0
  122. package/dist/npm/navigation/utils.js +79 -0
  123. package/dist/npm/package-metadata.js +1 -1
  124. package/dist/npm/rendering/gantt-milestone-task.component.js +11 -5
  125. package/dist/npm/rendering/gantt-summary-task.component.js +26 -5
  126. package/dist/npm/rendering/gantt-task-base.js +84 -22
  127. package/dist/npm/rendering/gantt-task.component.js +12 -7
  128. package/dist/npm/rendering/gantt-tasks-table-body.component.js +13 -5
  129. package/dist/npm/scrolling/drag-scroll-settings.js +22 -0
  130. package/dist/npm/scrolling/timeline-scroll.directive.js +91 -0
  131. package/dist/npm/scrolling/timeline-scroll.service.js +41 -0
  132. package/dist/npm/scrolling/utils.js +83 -0
  133. package/dist/npm/timeline/gantt-timeline.component.js +49 -3
  134. package/dist/npm/toolbar/toolbar.component.js +10 -11
  135. package/dist/npm/toolbar/view-selector.component.js +1 -1
  136. package/dist/npm/utils.js +153 -12
  137. package/dist/systemjs/kendo-angular-gantt.js +1 -1
  138. package/package.json +23 -21
@@ -0,0 +1,355 @@
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 * as tslib_1 from "tslib";
6
+ import { Injectable, NgZone, Renderer2 } from '@angular/core';
7
+ import { Keys, hasObservers } from '@progress/kendo-angular-common';
8
+ import { Subject } from 'rxjs';
9
+ import { ScrollSyncService } from '../scrolling/scroll-sync.service';
10
+ import { fitToRange, getClosestTaskIndex, isClearButton, isPresent, isTask, isToolbar } from '../utils';
11
+ import { getIndexFromViewDigitKeyCode, isArrowUpDownKey, isExpandCollapseKey, isNavigationKey, isViewDigitKey } from './utils';
12
+ /**
13
+ * @hidden
14
+ */
15
+ let NavigationService = class NavigationService {
16
+ constructor(zone, renderer, scrollSyncService) {
17
+ this.zone = zone;
18
+ this.renderer = renderer;
19
+ this.scrollSyncService = scrollSyncService;
20
+ /**
21
+ * Notifies when the tasks' focused and interactive (tabindex) state has changed.
22
+ *
23
+ * All tasks are rendered with tabindex="-1".
24
+ * When one is clicked, or when some navigation key keyboard key is pressed, it should be focused, assigned the focus class, and its tabindex updated to 0.
25
+ * All other tasks should get -1 tabindex and have the focus class removed from them.
26
+ */
27
+ this.taskStatusChanges = new Subject();
28
+ /**
29
+ * Keeps track of whether the Timeline part is focused.
30
+ * Used when the index of the task elements change (tasks are changed, pushed to, spliced from, etc.)
31
+ * and their status should be updated accordingly.
32
+ */
33
+ this.isTimelineFocused = false;
34
+ /**
35
+ * Keeps track of which part has last been focused.
36
+ * Used when calling `gantt.focus()` to determine which part of the component should receive focus.
37
+ */
38
+ this.treeListLastActive = false;
39
+ /**
40
+ * Keeps track of which part has last been focused.
41
+ * Used when calling `gantt.focus()` to determine which part of the component should receive focus.
42
+ */
43
+ this.timelineLastActive = false;
44
+ this._enabled = false;
45
+ this._activeTimelineIndex = 0;
46
+ this._activeTreeListCell = { rowIndex: 0, colIndex: 0 };
47
+ }
48
+ /**
49
+ * Specifies whether navigation is enabled.
50
+ */
51
+ get enabled() {
52
+ return this._enabled;
53
+ }
54
+ /**
55
+ * Used to retrieve read-only data about the currently active task.
56
+ */
57
+ get activeTask() {
58
+ return {
59
+ activeIndex: this.activeTimelineIndex,
60
+ isFocused: this.isTimelineFocused
61
+ };
62
+ }
63
+ /**
64
+ * Persists the expected TreeList focused cell coords.
65
+ * When the tasks in the Timeline are navigated through, the expected TreeList focus target should also change,
66
+ * in order to allow back-tabbing from the Timeline to the same row in the TreeList.
67
+ */
68
+ set activeTreeListCell(cell) {
69
+ this._activeTreeListCell = cell;
70
+ }
71
+ get activeTreeListCell() {
72
+ const firstAvailableIndex = 0;
73
+ const lastAvailableRowIndex = this.treeListHeaderRowsCount + this.gantt.treeList.view.data.length - 1;
74
+ const rowIndex = fitToRange(this._activeTreeListCell.rowIndex, firstAvailableIndex, lastAvailableRowIndex);
75
+ const lastAvailableColIndex = this.gantt.columns.length;
76
+ const colIndex = fitToRange(this._activeTreeListCell.colIndex, firstAvailableIndex, lastAvailableColIndex);
77
+ return { rowIndex, colIndex };
78
+ }
79
+ /**
80
+ * Persists the expected Timeline focused task index.
81
+ * When the cells in the TreeList are navigated through, the expected Timeline focus target should also change,
82
+ * in order to allow tabbing from the TreeList to the same row in the Timeline.
83
+ */
84
+ set activeTimelineIndex(index) {
85
+ this._activeTimelineIndex = index;
86
+ }
87
+ get activeTimelineIndex() {
88
+ const firstAvailableIndex = 0;
89
+ const lastAvailableIndex = this.gantt.treeList.view.data.length - 1;
90
+ return fitToRange(this._activeTimelineIndex, firstAvailableIndex, lastAvailableIndex);
91
+ }
92
+ /**
93
+ * The TreeList row index takes into account the header and filter rows.
94
+ * Used when translating Timeline task indices to TreeList row indices.
95
+ */
96
+ get treeListHeaderRowsCount() {
97
+ // captures nested group header rows + filter row if we start supporting it at some point
98
+ return this.treeListElement.querySelectorAll('.k-grid-header tr').length;
99
+ }
100
+ initialize({ gantt, host, treeListElement, timelineElement }) {
101
+ // no private property setters in TypeScript, so use a getter and a poorly named private prop for this value
102
+ this._enabled = true;
103
+ this.gantt = gantt;
104
+ this.host = host;
105
+ this.treeListElement = treeListElement;
106
+ this.timelineElement = timelineElement;
107
+ // TODO: fix in the splitter package and remove
108
+ // move the splitbar HTML element between the two panes to keep the visial tabbing order in tact
109
+ const splitbar = this.host.querySelector('.k-splitbar');
110
+ if (isPresent(splitbar) && isPresent(splitbar.previousElementSibling) && isPresent(splitbar.after)) {
111
+ splitbar.after(splitbar.previousElementSibling);
112
+ }
113
+ this.zone.runOutsideAngular(() => {
114
+ this.eventListenerDisposers = [
115
+ this.renderer.listen(this.host, 'keydown', this.handleKeydown.bind(this)),
116
+ this.renderer.listen(this.treeListElement, 'mousedown', this.focusTreeList.bind(this)),
117
+ this.renderer.listen(this.treeListElement, 'focusin', this.handleTreeListFocusIn.bind(this)),
118
+ this.renderer.listen(this.timelineElement, 'mousedown', this.handleTimelineMousedown.bind(this)),
119
+ this.renderer.listen(this.timelineElement, 'focusin', this.handleTimelineFocusIn.bind(this)),
120
+ this.renderer.listen(this.timelineElement, 'focusout', this.handleTimelineFocusOut.bind(this))
121
+ ];
122
+ });
123
+ }
124
+ ngOnDestroy() {
125
+ if (isPresent(this.eventListenerDisposers)) {
126
+ this.eventListenerDisposers.forEach(removeListener => removeListener());
127
+ this.eventListenerDisposers = null;
128
+ }
129
+ this.gantt = null;
130
+ this.host = null;
131
+ this.treeListElement = null;
132
+ this.timelineElement = null;
133
+ }
134
+ /**
135
+ * Focuses either the last active TreeList cell, or the last active Timeline task,
136
+ * dependening on which of the two last held focus.
137
+ *
138
+ * Focuses the first TreeList cell by default.
139
+ */
140
+ focusLastActiveItem() {
141
+ if (this.gantt.data.length === 0 || (!this.treeListLastActive && !this.timelineLastActive)) {
142
+ this.focusCell(0, 0);
143
+ }
144
+ else if (this.treeListLastActive) {
145
+ const { rowIndex, colIndex } = this.activeTreeListCell;
146
+ this.gantt.treeList.focusCell(rowIndex, colIndex);
147
+ }
148
+ else if (this.timelineLastActive) {
149
+ this.focusTask(this.activeTimelineIndex);
150
+ }
151
+ }
152
+ /**
153
+ * Focuses the targeted TreeList cell regardless of the last peresisted target.
154
+ */
155
+ focusCell(rowIndex, colIndex) {
156
+ this.activeTreeListCell = { rowIndex, colIndex };
157
+ this.activeTimelineIndex = rowIndex - this.treeListHeaderRowsCount;
158
+ this.gantt.treeList.focusCell(this.activeTreeListCell.rowIndex, this.activeTreeListCell.colIndex);
159
+ }
160
+ /**
161
+ * Focuses the targeted Timeline task regardless of the last peresisted target.
162
+ */
163
+ focusTask(index) {
164
+ this.activeTimelineIndex = index;
165
+ this.isTimelineFocused = true;
166
+ this.activeTreeListCell = {
167
+ rowIndex: index + this.treeListHeaderRowsCount,
168
+ colIndex: this.activeTreeListCell.colIndex
169
+ };
170
+ this.notifyTaskStatusChange();
171
+ }
172
+ /**
173
+ * Updates the focus target flags and notifies the active task to update its focused state.
174
+ */
175
+ handleTimelineFocusIn({ target }) {
176
+ this.treeListLastActive = false;
177
+ this.timelineLastActive = true;
178
+ this.isTimelineFocused = true;
179
+ if (isTask(target, this.timelineElement)) {
180
+ this.notifyTaskStatusChange();
181
+ }
182
+ }
183
+ /**
184
+ * Updates the timeline focus state flag and notifies the active task to update its focused state.
185
+ */
186
+ handleTimelineFocusOut({ relatedTarget }) {
187
+ this.isTimelineFocused = this.timelineElement.contains(relatedTarget);
188
+ // update the task element only if the new focus target is not in the Timeline - focus change between tasks is handled in the focusin handler
189
+ if (!isTask(relatedTarget, this.timelineElement)) {
190
+ this.notifyTaskStatusChange();
191
+ }
192
+ }
193
+ /**
194
+ * Updates the focus target flags and corrects the TreeList focus target if needed.
195
+ * As the TreeList will keep its last focused cell with tabindex="0",
196
+ * this methods forcefully focuses the correct cell,
197
+ * when navigating in the Timeline has updated the expected TreeList focus target.
198
+ */
199
+ handleTreeListFocusIn(event) {
200
+ this.treeListLastActive = true;
201
+ this.timelineLastActive = false;
202
+ // if the previous focus target was in the TreeList, rely on its component navigation and just record the focused item index
203
+ if (this.treeListElement.contains(event.relatedTarget)) {
204
+ const { colIndex, rowIndex } = this.gantt.treeList.activeCell;
205
+ this.activeTreeListCell = { colIndex, rowIndex };
206
+ }
207
+ else {
208
+ // if the previous focus target was outside the TreeList, ensure the expected focus coords are used
209
+ const { rowIndex, colIndex } = this.activeTreeListCell;
210
+ this.gantt.treeList.focusCell(rowIndex, colIndex); // activates the target cell even if it has tabindex="-1"
211
+ }
212
+ this.activeTimelineIndex = this.gantt.treeList.activeCell.dataRowIndex;
213
+ this.notifyTaskStatusChange();
214
+ if (this.gantt.treeList.activeCell.dataRowIndex >= 0) {
215
+ this.scrollHorizontallyToTask(this.activeTimelineIndex);
216
+ this.scrollSyncService.syncScrollTop('treelist', 'timeline');
217
+ }
218
+ }
219
+ handleKeydown(event) {
220
+ const { keyCode, target, altKey } = event;
221
+ const isTimelineActive = this.timelineElement.contains(target);
222
+ if (isTimelineActive) {
223
+ if (isArrowUpDownKey(keyCode)) {
224
+ const direction = keyCode === Keys.ArrowUp ? -1 : 1;
225
+ this.activeTimelineIndex = this.activeTimelineIndex + direction;
226
+ this.activeTreeListCell = {
227
+ rowIndex: this.activeTimelineIndex + this.treeListHeaderRowsCount,
228
+ colIndex: this.activeTreeListCell.colIndex
229
+ };
230
+ }
231
+ else if (keyCode === Keys.Home) {
232
+ this.activeTimelineIndex = 0;
233
+ this.activeTreeListCell = {
234
+ rowIndex: this.activeTimelineIndex + this.treeListHeaderRowsCount,
235
+ colIndex: this.activeTreeListCell.colIndex
236
+ };
237
+ }
238
+ else if (keyCode === Keys.End) {
239
+ const lastAvailableIndex = this.gantt.treeList.view.data.length - 1;
240
+ this.activeTimelineIndex = lastAvailableIndex;
241
+ this.activeTreeListCell = {
242
+ rowIndex: this.activeTimelineIndex + this.treeListHeaderRowsCount,
243
+ colIndex: this.activeTreeListCell.colIndex
244
+ };
245
+ }
246
+ if (isNavigationKey(keyCode)) {
247
+ this.scrollHorizontallyToTask(this.activeTimelineIndex);
248
+ this.scrollSyncService.syncScrollTop('timeline', 'treelist');
249
+ this.notifyTaskStatusChange();
250
+ event.preventDefault();
251
+ }
252
+ if (keyCode === Keys.Space && hasObservers(this.gantt.selectionChange)) {
253
+ const task = this.gantt.renderedTreeListItems[this.activeTimelineIndex];
254
+ const selectionAction = this.gantt.getSelectionAction(event, task);
255
+ if (isPresent(task) && !this.gantt.isSameSelection(selectionAction, task)) {
256
+ this.zone.run(() => this.gantt.notifySelectionChange(task, selectionAction));
257
+ }
258
+ event.preventDefault();
259
+ }
260
+ if (keyCode === Keys.Enter && hasObservers(this.gantt.taskClick)) {
261
+ const task = this.gantt.renderedTreeListItems[this.activeTimelineIndex];
262
+ if (isPresent(task)) {
263
+ this.zone.run(() => this.gantt.notifyTaskClick(event, task, this.activeTimelineIndex));
264
+ }
265
+ event.preventDefault();
266
+ }
267
+ if (isExpandCollapseKey(keyCode, altKey)) {
268
+ const task = this.gantt.renderedTreeListItems[this.activeTimelineIndex];
269
+ if (isPresent(task) && this.gantt.hasChildren(task)) {
270
+ const shouldExpand = keyCode === Keys.ArrowRight;
271
+ const isExpanded = this.gantt.isExpanded(task);
272
+ const sameState = shouldExpand === isExpanded;
273
+ if (!sameState) {
274
+ this.zone.run(() => {
275
+ const expandEvent = { dataItem: task };
276
+ // order is not arbitrary
277
+ // the TreeList emits the individual events first, then the combined `expandStateChange` event
278
+ const individualEmitter = shouldExpand ? this.gantt.rowExpand : this.gantt.rowCollapse;
279
+ individualEmitter.emit(expandEvent);
280
+ this.gantt.expandStateChange.emit(Object.assign({}, expandEvent, { expand: shouldExpand }));
281
+ this.gantt.updateView();
282
+ this.scrollHorizontallyToTask(this.activeTimelineIndex);
283
+ });
284
+ }
285
+ }
286
+ event.preventDefault();
287
+ }
288
+ }
289
+ const isTreeListActive = this.treeListElement.contains(target);
290
+ if (keyCode === Keys.Delete && (isTimelineActive || isTreeListActive) && hasObservers(this.gantt.taskDelete)) {
291
+ const taskIndex = isTreeListActive ?
292
+ this.gantt.treeList.activeCell.dataRowIndex :
293
+ this.activeTimelineIndex;
294
+ const task = this.gantt.renderedTreeListItems[taskIndex];
295
+ if (isPresent(task)) {
296
+ this.zone.run(() => this.gantt.notifyTaskDelete(task));
297
+ }
298
+ }
299
+ if (isViewDigitKey(keyCode) && !isToolbar(target, this.host) && !this.gantt.isInEditMode) {
300
+ const targetViewIndex = getIndexFromViewDigitKeyCode(keyCode);
301
+ const availableViews = this.gantt.views.toArray();
302
+ const targetView = availableViews[targetViewIndex];
303
+ if (isPresent(targetView) && targetView.type !== this.gantt.activeView) {
304
+ this.zone.run(() => this.gantt.changeActiveView(targetView.type));
305
+ }
306
+ }
307
+ }
308
+ /**
309
+ * Filters for task mousedown in the Timeline.
310
+ */
311
+ handleTimelineMousedown({ target }) {
312
+ if (isTask(target, this.host) && !isClearButton(target, this.host)) {
313
+ const taskIndex = getClosestTaskIndex(target, this.host);
314
+ this.focusTask(taskIndex);
315
+ }
316
+ }
317
+ /**
318
+ * Scrolls horizontally to the beginning of the target task if the beginning of its content is not in the viewport.
319
+ */
320
+ scrollHorizontallyToTask(index) {
321
+ const task = this.timelineElement.querySelectorAll('.k-task-wrap').item(index);
322
+ if (!isPresent(task)) {
323
+ return;
324
+ }
325
+ // scroll horizontally to the item if less than 200px from the beginning of its content are visible
326
+ const targetVisibleWidth = 200;
327
+ const isScrollBeforeTask = (this.timelineElement.clientWidth + this.timelineElement.scrollLeft) < (task.offsetLeft + targetVisibleWidth);
328
+ const isScrollAfterTask = this.timelineElement.scrollLeft > task.offsetLeft;
329
+ if (isScrollBeforeTask || isScrollAfterTask) {
330
+ this.timelineElement.scrollLeft = task.offsetLeft;
331
+ }
332
+ }
333
+ /**
334
+ * Focus the TreeList on TreeList mousedown.
335
+ * A nasty hack to trick `handleTreeListFocusIn` into regarding the previous focus target as again the TreeList.
336
+ * Otherwise cell clicks are wrongly overwritten in `handleTreeListFocusIn` and the click focus target is not respected.
337
+ */
338
+ focusTreeList() {
339
+ this.gantt.treeList.focus();
340
+ }
341
+ /**
342
+ * Fires the `taskStatusChanges` event with active and focused status retrieved from
343
+ * `this.activeTimelineIndex` and `this.isTimelineFocused`.
344
+ */
345
+ notifyTaskStatusChange() {
346
+ this.taskStatusChanges.next(this.activeTask);
347
+ }
348
+ };
349
+ NavigationService = tslib_1.__decorate([
350
+ Injectable(),
351
+ tslib_1.__metadata("design:paramtypes", [NgZone,
352
+ Renderer2,
353
+ ScrollSyncService])
354
+ ], NavigationService);
355
+ export { NavigationService };
@@ -0,0 +1,26 @@
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
+ /**
6
+ * @hidden
7
+ */
8
+ export declare const isArrowUpDownKey: (keyCode: number) => boolean;
9
+ /**
10
+ * @hidden
11
+ */
12
+ export declare const isNavigationKey: (keyCode: number) => boolean;
13
+ /**
14
+ * @hidden
15
+ */
16
+ export declare const isExpandCollapseKey: (keyCode: number, altKey: boolean) => boolean;
17
+ /**
18
+ * @hidden
19
+ */
20
+ export declare const isViewDigitKey: (keyCode: number) => boolean;
21
+ /**
22
+ * @hidden
23
+ *
24
+ * Returns the corresponding view index for the pressed digit key (Digit 1 => 0, Digit 2 => 1, etc.).
25
+ */
26
+ export declare const getIndexFromViewDigitKeyCode: (keyCode: number) => number;
@@ -0,0 +1,69 @@
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 { Keys } from '@progress/kendo-angular-common';
6
+ // TODO: add those keys to `import { Keys } from '@progress/kendo-angular-common';`
7
+ var NumpadKeys;
8
+ (function (NumpadKeys) {
9
+ NumpadKeys[NumpadKeys["Digit1"] = 97] = "Digit1";
10
+ NumpadKeys[NumpadKeys["Digit2"] = 98] = "Digit2";
11
+ NumpadKeys[NumpadKeys["Digit3"] = 99] = "Digit3";
12
+ NumpadKeys[NumpadKeys["Digit4"] = 100] = "Digit4";
13
+ })(NumpadKeys || (NumpadKeys = {}));
14
+ /**
15
+ * @hidden
16
+ */
17
+ export const isArrowUpDownKey = (keyCode) => [
18
+ Keys.ArrowUp,
19
+ Keys.ArrowDown
20
+ ].some(arrowKeyCode => keyCode === arrowKeyCode);
21
+ /**
22
+ * @hidden
23
+ */
24
+ export const isNavigationKey = (keyCode) => [
25
+ Keys.ArrowUp,
26
+ Keys.ArrowDown,
27
+ Keys.Home,
28
+ Keys.End
29
+ ].some(navigationKeyCode => keyCode === navigationKeyCode);
30
+ /**
31
+ * @hidden
32
+ */
33
+ export const isExpandCollapseKey = (keyCode, altKey) => {
34
+ return altKey && [
35
+ Keys.ArrowLeft,
36
+ Keys.ArrowRight
37
+ ].some(navigationKeyCode => keyCode === navigationKeyCode);
38
+ };
39
+ /**
40
+ * @hidden
41
+ */
42
+ export const isViewDigitKey = (keyCode) => [
43
+ Keys.Digit1,
44
+ NumpadKeys.Digit1,
45
+ Keys.Digit2,
46
+ NumpadKeys.Digit2,
47
+ Keys.Digit3,
48
+ NumpadKeys.Digit3,
49
+ Keys.Digit4,
50
+ NumpadKeys.Digit4
51
+ ].some(digitKeyCode => keyCode === digitKeyCode);
52
+ /**
53
+ * @hidden
54
+ *
55
+ * Returns the corresponding view index for the pressed digit key (Digit 1 => 0, Digit 2 => 1, etc.).
56
+ */
57
+ export const getIndexFromViewDigitKeyCode = (keyCode) => {
58
+ switch (keyCode) {
59
+ case NumpadKeys.Digit1:
60
+ case Keys.Digit1: return 0;
61
+ case NumpadKeys.Digit2:
62
+ case Keys.Digit2: return 1;
63
+ case NumpadKeys.Digit3:
64
+ case Keys.Digit3: return 2;
65
+ case NumpadKeys.Digit4:
66
+ case Keys.Digit4: return 3;
67
+ default: return null;
68
+ }
69
+ };
@@ -9,7 +9,7 @@ export const packageMetadata = {
9
9
  name: '@progress/kendo-angular-gantt',
10
10
  productName: 'Kendo UI for Angular',
11
11
  productCodes: ['KENDOUIANGULAR', 'KENDOUICOMPLETE'],
12
- publishDate: 1641921322,
12
+ publishDate: 1642606888,
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
  };
@@ -4,6 +4,7 @@
4
4
  *-------------------------------------------------------------------------------------------*/
5
5
  import { ChangeDetectorRef } from '@angular/core';
6
6
  import { MappingService } from '../common/mapping.service';
7
+ import { NavigationService } from '../navigation/navigation.service';
7
8
  import { DependencyDomService } from '../dependencies/dependency-dom.service';
8
9
  import { OptionChangesService } from '../common/option-changes.service';
9
10
  import { TimelineViewService } from './../timeline/timeline-view.service';
@@ -12,6 +13,7 @@ import { GanttTaskBase } from './gantt-task-base';
12
13
  * @hidden
13
14
  */
14
15
  export declare class GanttMilestoneTaskComponent extends GanttTaskBase {
16
+ touchEnabled: boolean;
15
17
  milestoneWrapperClass: boolean;
16
- constructor(mapper: MappingService, timelineViewService: TimelineViewService, dependencyDomService: DependencyDomService, optionChangesService: OptionChangesService, cdr: ChangeDetectorRef);
18
+ constructor(touchEnabled: boolean, mapper: MappingService, timelineViewService: TimelineViewService, dependencyDomService: DependencyDomService, optionChangesService: OptionChangesService, cdr: ChangeDetectorRef, navigationService: NavigationService);
17
19
  }
@@ -4,8 +4,10 @@
4
4
  *-------------------------------------------------------------------------------------------*/
5
5
  import * as tslib_1 from "tslib";
6
6
  var GanttMilestoneTaskComponent_1;
7
- import { Component, forwardRef, HostBinding, ChangeDetectorRef } from '@angular/core';
7
+ import { Component, forwardRef, HostBinding, ChangeDetectorRef, Inject } from '@angular/core';
8
8
  import { MappingService } from '../common/mapping.service';
9
+ import { NavigationService } from '../navigation/navigation.service';
10
+ import { TOUCH_ENABLED } from '../common/touch-enabled';
9
11
  import { DependencyDomService } from '../dependencies/dependency-dom.service';
10
12
  import { OptionChangesService } from '../common/option-changes.service';
11
13
  import { TimelineViewService } from './../timeline/timeline-view.service';
@@ -14,8 +16,9 @@ import { GanttTaskBase } from './gantt-task-base';
14
16
  * @hidden
15
17
  */
16
18
  let GanttMilestoneTaskComponent = GanttMilestoneTaskComponent_1 = class GanttMilestoneTaskComponent extends GanttTaskBase {
17
- constructor(mapper, timelineViewService, dependencyDomService, optionChangesService, cdr) {
18
- super(mapper, timelineViewService, dependencyDomService, optionChangesService, cdr);
19
+ constructor(touchEnabled, mapper, timelineViewService, dependencyDomService, optionChangesService, cdr, navigationService) {
20
+ super(mapper, timelineViewService, dependencyDomService, optionChangesService, cdr, navigationService);
21
+ this.touchEnabled = touchEnabled;
19
22
  this.milestoneWrapperClass = true;
20
23
  }
21
24
  };
@@ -35,20 +38,44 @@ GanttMilestoneTaskComponent = GanttMilestoneTaskComponent_1 = tslib_1.__decorate
35
38
  template: `
36
39
  <div
37
40
  #task
41
+ role="treeitem"
38
42
  class="k-task k-task-milestone"
39
43
  [ngClass]="taskClass(dataItem)"
40
- [style.left.px]="taskOffset"
41
44
  [attr.title]="mapper.extractFromTask(dataItem, 'title')"
42
45
  [class.k-state-selected]="isSelected(dataItem)"
43
- [attr.data-task-index]="index"
46
+ [attr.aria-selected]="ariaSelected"
47
+ [attr.aria-level]="level + 1"
44
48
  >
45
49
  </div>
46
- `
50
+ <ng-container *ngIf="renderDependencyDragClues">
51
+ <div
52
+ class="k-task-dot k-task-start k-touch-action-none"
53
+ [class.k-display-block]="touchEnabled"
54
+ >
55
+ </div>
56
+ <div
57
+ class="k-task-dot k-task-end k-touch-action-none"
58
+ [class.k-display-block]="touchEnabled"
59
+ >
60
+ </div>
61
+ </ng-container>
62
+ `,
63
+ styles: [`
64
+ .k-task.k-focus {
65
+ box-shadow: 0 0 4px 3px grey;
66
+ outline: none;
67
+ }
68
+ .k-task.k-focus.k-state-selected {
69
+ box-shadow: 0 0 4px 3px #ffaea8;
70
+ }
71
+ `]
47
72
  }),
48
- tslib_1.__metadata("design:paramtypes", [MappingService,
73
+ tslib_1.__param(0, Inject(TOUCH_ENABLED)),
74
+ tslib_1.__metadata("design:paramtypes", [Boolean, MappingService,
49
75
  TimelineViewService,
50
76
  DependencyDomService,
51
77
  OptionChangesService,
52
- ChangeDetectorRef])
78
+ ChangeDetectorRef,
79
+ NavigationService])
53
80
  ], GanttMilestoneTaskComponent);
54
81
  export { GanttMilestoneTaskComponent };
@@ -4,6 +4,7 @@
4
4
  *-------------------------------------------------------------------------------------------*/
5
5
  import { ChangeDetectorRef, TemplateRef } from '@angular/core';
6
6
  import { MappingService } from '../common/mapping.service';
7
+ import { NavigationService } from '../navigation/navigation.service';
7
8
  import { DependencyDomService } from '../dependencies/dependency-dom.service';
8
9
  import { OptionChangesService } from '../common/option-changes.service';
9
10
  import { TimelineViewService } from './../timeline/timeline-view.service';
@@ -12,7 +13,10 @@ import { GanttTaskBase } from './gantt-task-base';
12
13
  * @hidden
13
14
  */
14
15
  export declare class GanttSummaryTaskComponent extends GanttTaskBase {
16
+ touchEnabled: boolean;
15
17
  summaryWrapperClass: boolean;
16
18
  template: TemplateRef<any>;
17
- constructor(mapper: MappingService, timelineViewService: TimelineViewService, dependencyDomService: DependencyDomService, optionChangesService: OptionChangesService, cdr: ChangeDetectorRef);
19
+ isExpanded: (task: object) => boolean;
20
+ readonly ariaExpanded: string;
21
+ constructor(touchEnabled: boolean, mapper: MappingService, timelineViewService: TimelineViewService, dependencyDomService: DependencyDomService, optionChangesService: OptionChangesService, cdr: ChangeDetectorRef, navigationService: NavigationService);
18
22
  }
@@ -4,20 +4,30 @@
4
4
  *-------------------------------------------------------------------------------------------*/
5
5
  import * as tslib_1 from "tslib";
6
6
  var GanttSummaryTaskComponent_1;
7
- import { ChangeDetectorRef, Component, forwardRef, HostBinding, Input, TemplateRef } from '@angular/core';
7
+ import { ChangeDetectorRef, Component, forwardRef, HostBinding, Inject, Input, TemplateRef } from '@angular/core';
8
8
  import { MappingService } from '../common/mapping.service';
9
+ import { NavigationService } from '../navigation/navigation.service';
10
+ import { TOUCH_ENABLED } from '../common/touch-enabled';
9
11
  import { DependencyDomService } from '../dependencies/dependency-dom.service';
10
12
  import { OptionChangesService } from '../common/option-changes.service';
11
13
  import { TimelineViewService } from './../timeline/timeline-view.service';
12
14
  import { GanttTaskBase } from './gantt-task-base';
15
+ import { isPresent } from '../utils';
13
16
  /**
14
17
  * @hidden
15
18
  */
16
19
  let GanttSummaryTaskComponent = GanttSummaryTaskComponent_1 = class GanttSummaryTaskComponent extends GanttTaskBase {
17
- constructor(mapper, timelineViewService, dependencyDomService, optionChangesService, cdr) {
18
- super(mapper, timelineViewService, dependencyDomService, optionChangesService, cdr);
20
+ constructor(touchEnabled, mapper, timelineViewService, dependencyDomService, optionChangesService, cdr, navigationService) {
21
+ super(mapper, timelineViewService, dependencyDomService, optionChangesService, cdr, navigationService);
22
+ this.touchEnabled = touchEnabled;
19
23
  this.summaryWrapperClass = true;
20
24
  }
25
+ get ariaExpanded() {
26
+ // if no callback is provided, all child items are displayed and the item is regarded as expanded
27
+ // replicates the TreeList aria-expanded behavior
28
+ const isExpanded = !isPresent(this.isExpanded) || this.isExpanded(this.dataItem);
29
+ return String(isExpanded);
30
+ }
21
31
  };
22
32
  tslib_1.__decorate([
23
33
  HostBinding('class.k-summary-wrap'),
@@ -27,6 +37,10 @@ tslib_1.__decorate([
27
37
  Input(),
28
38
  tslib_1.__metadata("design:type", TemplateRef)
29
39
  ], GanttSummaryTaskComponent.prototype, "template", void 0);
40
+ tslib_1.__decorate([
41
+ Input(),
42
+ tslib_1.__metadata("design:type", Function)
43
+ ], GanttSummaryTaskComponent.prototype, "isExpanded", void 0);
30
44
  GanttSummaryTaskComponent = GanttSummaryTaskComponent_1 = tslib_1.__decorate([
31
45
  Component({
32
46
  selector: 'kendo-gantt-summary-task',
@@ -39,13 +53,15 @@ GanttSummaryTaskComponent = GanttSummaryTaskComponent_1 = tslib_1.__decorate([
39
53
  template: `
40
54
  <div
41
55
  #task
56
+ role="treeitem"
42
57
  class="k-task k-task-summary"
43
58
  [ngClass]="taskClass(dataItem)"
44
59
  [style.width.px]="taskWidth"
45
- [style.left.px]="taskOffset"
46
60
  [attr.title]="mapper.extractFromTask(dataItem, 'title')"
47
- [attr.data-task-index]="index"
48
61
  [class.k-state-selected]="isSelected(dataItem)"
62
+ [attr.aria-selected]="ariaSelected"
63
+ [attr.aria-expanded]="ariaExpanded"
64
+ [attr.aria-level]="level + 1"
49
65
  >
50
66
  <div *ngIf="!template; else summaryTemplate"
51
67
  class="k-task-summary-progress"
@@ -66,12 +82,35 @@ GanttSummaryTaskComponent = GanttSummaryTaskComponent_1 = tslib_1.__decorate([
66
82
  >
67
83
  </ng-template>
68
84
  </div>
69
- `
85
+ <ng-container *ngIf="renderDependencyDragClues">
86
+ <div
87
+ class="k-task-dot k-task-start k-touch-action-none"
88
+ [class.k-display-block]="touchEnabled"
89
+ >
90
+ </div>
91
+ <div
92
+ class="k-task-dot k-task-end k-touch-action-none"
93
+ [class.k-display-block]="touchEnabled"
94
+ >
95
+ </div>
96
+ </ng-container>
97
+ `,
98
+ styles: [`
99
+ .k-task.k-focus {
100
+ box-shadow: 0 0 4px 3px grey;
101
+ outline: none;
102
+ }
103
+ .k-task.k-focus.k-state-selected {
104
+ box-shadow: 0 0 4px 3px #ffaea8;
105
+ }
106
+ `]
70
107
  }),
71
- tslib_1.__metadata("design:paramtypes", [MappingService,
108
+ tslib_1.__param(0, Inject(TOUCH_ENABLED)),
109
+ tslib_1.__metadata("design:paramtypes", [Boolean, MappingService,
72
110
  TimelineViewService,
73
111
  DependencyDomService,
74
112
  OptionChangesService,
75
- ChangeDetectorRef])
113
+ ChangeDetectorRef,
114
+ NavigationService])
76
115
  ], GanttSummaryTaskComponent);
77
116
  export { GanttSummaryTaskComponent };