@progress/kendo-angular-treelist 21.4.1-develop.1 → 22.0.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/binding-directives/base-binding.directive.d.ts +1 -1
- package/column-menu/column-menu-item-base.d.ts +1 -1
- package/columns/column-base.d.ts +1 -1
- package/editing-directives/editing-directive-base.d.ts +1 -1
- package/editing-directives/row-editing-directive-base.d.ts +1 -1
- package/fesm2022/progress-kendo-angular-treelist.mjs +519 -519
- package/filtering/base-filter-cell.component.d.ts +1 -1
- package/filtering/boolean-filter.component.d.ts +1 -1
- package/filtering/date-filter.component.d.ts +1 -1
- package/filtering/filter-host.directive.d.ts +1 -1
- package/filtering/filter-input-wrapper.component.d.ts +1 -1
- package/filtering/numeric-filter.component.d.ts +1 -1
- package/filtering/operators/filter-operator.base.d.ts +1 -1
- package/filtering/string-filter.component.d.ts +1 -1
- package/localization/messages.d.ts +1 -1
- package/package.json +23 -31
- package/schematics/ngAdd/index.js +3 -3
- package/esm2022/binding-directives/base-binding.directive.mjs +0 -180
- package/esm2022/binding-directives/data-bound-tree-component.mjs +0 -18
- package/esm2022/binding-directives/flat-binding.directive.mjs +0 -130
- package/esm2022/binding-directives/hierarchy-binding.directive.mjs +0 -109
- package/esm2022/column-menu/column-chooser-item-checked.directive.mjs +0 -45
- package/esm2022/column-menu/column-chooser.component.mjs +0 -221
- package/esm2022/column-menu/column-list-kb-nav.service.mjs +0 -40
- package/esm2022/column-menu/column-list.component.mjs +0 -380
- package/esm2022/column-menu/column-locked-change-event.mjs +0 -21
- package/esm2022/column-menu/column-menu-autosize-all.component.mjs +0 -78
- package/esm2022/column-menu/column-menu-autosize.component.mjs +0 -86
- package/esm2022/column-menu/column-menu-chooser.component.mjs +0 -164
- package/esm2022/column-menu/column-menu-container.component.mjs +0 -58
- package/esm2022/column-menu/column-menu-expandable-item.interface.mjs +0 -5
- package/esm2022/column-menu/column-menu-filter.component.mjs +0 -141
- package/esm2022/column-menu/column-menu-item-base.mjs +0 -41
- package/esm2022/column-menu/column-menu-item-content-template.directive.mjs +0 -43
- package/esm2022/column-menu/column-menu-item.component.mjs +0 -329
- package/esm2022/column-menu/column-menu-item.directive.mjs +0 -147
- package/esm2022/column-menu/column-menu-lock.component.mjs +0 -112
- package/esm2022/column-menu/column-menu-settings.interface.mjs +0 -5
- package/esm2022/column-menu/column-menu-sort.component.mjs +0 -115
- package/esm2022/column-menu/column-menu-template.directive.mjs +0 -47
- package/esm2022/column-menu/column-menu.component.mjs +0 -470
- package/esm2022/column-menu/column-menu.service.mjs +0 -70
- package/esm2022/column-menu/column-visibility-change-event.mjs +0 -19
- package/esm2022/column-menu/utils.mjs +0 -44
- package/esm2022/column-resizing/column-handle.directive.mjs +0 -226
- package/esm2022/column-resizing/column-resize.interface.mjs +0 -5
- package/esm2022/column-resizing/column-resizing.service.mjs +0 -143
- package/esm2022/column-resizing/table.directive.mjs +0 -130
- package/esm2022/columns/checkbox-column.component.mjs +0 -88
- package/esm2022/columns/column-base.mjs +0 -319
- package/esm2022/columns/column-common.mjs +0 -73
- package/esm2022/columns/column-group.component.mjs +0 -115
- package/esm2022/columns/column-list.mjs +0 -94
- package/esm2022/columns/column.component.mjs +0 -165
- package/esm2022/columns/columns-container.mjs +0 -90
- package/esm2022/columns/command-column.component.mjs +0 -77
- package/esm2022/columns/rowreorder-column.component.mjs +0 -57
- package/esm2022/columns/sort-settings.mjs +0 -17
- package/esm2022/columns/span-column.component.mjs +0 -201
- package/esm2022/common/cell-click-event-args.interface.mjs +0 -5
- package/esm2022/common/column-info.service.mjs +0 -54
- package/esm2022/common/create-form-group.mjs +0 -5
- package/esm2022/common/default-track-by.mjs +0 -13
- package/esm2022/common/dom-events.service.mjs +0 -24
- package/esm2022/common/error-messages.mjs +0 -15
- package/esm2022/common/filter-descriptor-differ.mjs +0 -69
- package/esm2022/common/filter-operator.interface.mjs +0 -5
- package/esm2022/common/id.service.mjs +0 -34
- package/esm2022/common/option-changes.service.mjs +0 -24
- package/esm2022/common/pager-settings.mjs +0 -19
- package/esm2022/common/preventable-event.mjs +0 -28
- package/esm2022/common/provider.service.mjs +0 -34
- package/esm2022/common/remove-confirmation.mjs +0 -5
- package/esm2022/common/single-popup.service.mjs +0 -132
- package/esm2022/common/sort.service.mjs +0 -14
- package/esm2022/data/change-event-args.interface.mjs +0 -5
- package/esm2022/data/change-notification.service.mjs +0 -30
- package/esm2022/data/data-item.interface.mjs +0 -5
- package/esm2022/data/data.collection.mjs +0 -503
- package/esm2022/data/treelist-item.interface.mjs +0 -5
- package/esm2022/directives.mjs +0 -291
- package/esm2022/dragdrop/column-reorder-config.mjs +0 -5
- package/esm2022/dragdrop/column-reorder-event.mjs +0 -31
- package/esm2022/dragdrop/column-reorder.service.mjs +0 -20
- package/esm2022/dragdrop/common.mjs +0 -69
- package/esm2022/dragdrop/context-types.mjs +0 -5
- package/esm2022/dragdrop/drag-and-drop.service.mjs +0 -65
- package/esm2022/dragdrop/drag-hint.service.mjs +0 -137
- package/esm2022/dragdrop/draggable-column.directive.mjs +0 -141
- package/esm2022/dragdrop/drop-cue.service.mjs +0 -46
- package/esm2022/dragdrop/drop-target.directive.mjs +0 -71
- package/esm2022/editing/add-command-tool.directive.mjs +0 -60
- package/esm2022/editing/add-command.directive.mjs +0 -96
- package/esm2022/editing/add-event-args.interface.mjs +0 -5
- package/esm2022/editing/base-command.directive.mjs +0 -95
- package/esm2022/editing/cancel-command.directive.mjs +0 -97
- package/esm2022/editing/cancel-event-args.interface.mjs +0 -5
- package/esm2022/editing/cell-close-event.mjs +0 -34
- package/esm2022/editing/edit-command.directive.mjs +0 -96
- package/esm2022/editing/edit-event-args.interface.mjs +0 -5
- package/esm2022/editing/edit-template.directive.mjs +0 -45
- package/esm2022/editing/edit.service.mjs +0 -174
- package/esm2022/editing/remove-command.directive.mjs +0 -96
- package/esm2022/editing/remove-event-args.interface.mjs +0 -5
- package/esm2022/editing/save-command.directive.mjs +0 -96
- package/esm2022/editing/save-event-args.interface.mjs +0 -5
- package/esm2022/editing-directives/create-form-group-args.interface.mjs +0 -5
- package/esm2022/editing-directives/edit-service.interface.mjs +0 -5
- package/esm2022/editing-directives/editing-directive-base.mjs +0 -137
- package/esm2022/editing-directives/flat-edit.service.mjs +0 -52
- package/esm2022/editing-directives/hierarchy-edit.service.mjs +0 -48
- package/esm2022/editing-directives/in-cell-editing.directive.mjs +0 -89
- package/esm2022/editing-directives/local-edit.service.mjs +0 -28
- package/esm2022/editing-directives/reactive-editing.directive.mjs +0 -61
- package/esm2022/editing-directives/row-editing-directive-base.mjs +0 -39
- package/esm2022/editing-directives/template-editing.directive.mjs +0 -68
- package/esm2022/editing-directives/utils.mjs +0 -41
- package/esm2022/excel/excel-command-tool.directive.mjs +0 -64
- package/esm2022/excel/excel-command.directive.mjs +0 -97
- package/esm2022/excel/excel-export-data.interface.mjs +0 -5
- package/esm2022/excel/excel-export-event.mjs +0 -15
- package/esm2022/excel/excel.component.mjs +0 -277
- package/esm2022/excel/excel.module.mjs +0 -45
- package/esm2022/excel/excel.service.mjs +0 -34
- package/esm2022/expand-state/expand-event.mjs +0 -30
- package/esm2022/expand-state/expand-state.service.mjs +0 -38
- package/esm2022/expand-state/expandable-tree-component.mjs +0 -18
- package/esm2022/expand-state/expandable.directive.mjs +0 -119
- package/esm2022/filtering/base-filter-cell.component.mjs +0 -172
- package/esm2022/filtering/boolean-filter.component.mjs +0 -91
- package/esm2022/filtering/cell/autocomplete-filter-cell.component.mjs +0 -113
- package/esm2022/filtering/cell/boolean-filter-cell.component.mjs +0 -107
- package/esm2022/filtering/cell/date-filter-cell.component.mjs +0 -132
- package/esm2022/filtering/cell/filter-cell-component.factory.mjs +0 -19
- package/esm2022/filtering/cell/filter-cell-host.directive.mjs +0 -33
- package/esm2022/filtering/cell/filter-cell-operators.component.mjs +0 -235
- package/esm2022/filtering/cell/filter-cell-template.directive.mjs +0 -46
- package/esm2022/filtering/cell/filter-cell-wrapper.component.mjs +0 -74
- package/esm2022/filtering/cell/filter-cell.component.mjs +0 -91
- package/esm2022/filtering/cell/numeric-filter-cell.component.mjs +0 -143
- package/esm2022/filtering/cell/string-filter-cell.component.mjs +0 -115
- package/esm2022/filtering/date-filter.component.mjs +0 -176
- package/esm2022/filtering/filter-component.interface.mjs +0 -5
- package/esm2022/filtering/filter-host.directive.mjs +0 -56
- package/esm2022/filtering/filter-input-wrapper.component.mjs +0 -119
- package/esm2022/filtering/filter-input.directive.mjs +0 -114
- package/esm2022/filtering/filter-row.component.mjs +0 -79
- package/esm2022/filtering/filter.service.mjs +0 -42
- package/esm2022/filtering/filterable.mjs +0 -16
- package/esm2022/filtering/menu/boolean-filter-menu.component.mjs +0 -168
- package/esm2022/filtering/menu/date-filter-menu-input.component.mjs +0 -174
- package/esm2022/filtering/menu/date-filter-menu.component.mjs +0 -207
- package/esm2022/filtering/menu/filter-menu-component.factory.mjs +0 -19
- package/esm2022/filtering/menu/filter-menu-container.component.mjs +0 -299
- package/esm2022/filtering/menu/filter-menu-dropdownlist.directive.mjs +0 -44
- package/esm2022/filtering/menu/filter-menu-host.directive.mjs +0 -46
- package/esm2022/filtering/menu/filter-menu-input-wrapper.component.mjs +0 -136
- package/esm2022/filtering/menu/filter-menu-template.directive.mjs +0 -43
- package/esm2022/filtering/menu/filter-menu.component.mjs +0 -202
- package/esm2022/filtering/menu/filter-radio-button.directive.mjs +0 -34
- package/esm2022/filtering/menu/menu-tabbing.service.mjs +0 -22
- package/esm2022/filtering/menu/numeric-filter-menu-input.component.mjs +0 -152
- package/esm2022/filtering/menu/numeric-filter-menu.component.mjs +0 -224
- package/esm2022/filtering/menu/string-filter-menu-input.component.mjs +0 -105
- package/esm2022/filtering/menu/string-filter-menu.component.mjs +0 -183
- package/esm2022/filtering/numeric-filter.component.mjs +0 -144
- package/esm2022/filtering/operators/after-eq-filter-operator.component.mjs +0 -72
- package/esm2022/filtering/operators/after-filter-operator.component.mjs +0 -72
- package/esm2022/filtering/operators/before-eq-filter-operator.component.mjs +0 -72
- package/esm2022/filtering/operators/before-filter-operator.component.mjs +0 -72
- package/esm2022/filtering/operators/contains-filter-operator.component.mjs +0 -64
- package/esm2022/filtering/operators/ends-with-filter-operator.component.mjs +0 -64
- package/esm2022/filtering/operators/eq-filter-operator.component.mjs +0 -112
- package/esm2022/filtering/operators/filter-operator.base.mjs +0 -98
- package/esm2022/filtering/operators/gt-filter-operator.component.mjs +0 -63
- package/esm2022/filtering/operators/gte-filter-operator.component.mjs +0 -63
- package/esm2022/filtering/operators/is-empty-filter-operator.component.mjs +0 -64
- package/esm2022/filtering/operators/is-not-empty-filter-operator.component.mjs +0 -64
- package/esm2022/filtering/operators/is-not-null-filter-operator.component.mjs +0 -112
- package/esm2022/filtering/operators/isnull-filter-operator.component.mjs +0 -112
- package/esm2022/filtering/operators/lt-filter-operator.component.mjs +0 -63
- package/esm2022/filtering/operators/lte-filter-operator.component.mjs +0 -63
- package/esm2022/filtering/operators/neq-filter-operator.component.mjs +0 -112
- package/esm2022/filtering/operators/not-contains-filter-operator.component.mjs +0 -64
- package/esm2022/filtering/operators/starts-with-filter-operator.component.mjs +0 -64
- package/esm2022/filtering/string-filter.component.mjs +0 -89
- package/esm2022/index.mjs +0 -146
- package/esm2022/layout/browser-support.service.mjs +0 -85
- package/esm2022/layout/resizable.directive.mjs +0 -83
- package/esm2022/layout/resize.service.mjs +0 -29
- package/esm2022/layout/responsive.service.mjs +0 -34
- package/esm2022/layout/row-sync.mjs +0 -47
- package/esm2022/localization/custom-messages.component.mjs +0 -53
- package/esm2022/localization/localized-messages.directive.mjs +0 -39
- package/esm2022/localization/messages.mjs +0 -510
- package/esm2022/navigation/default-focusable-element.mjs +0 -47
- package/esm2022/navigation/focus-group.mjs +0 -105
- package/esm2022/navigation/focus-root.mjs +0 -50
- package/esm2022/navigation/focusable-element.interface.mjs +0 -5
- package/esm2022/navigation/focusable.directive.mjs +0 -174
- package/esm2022/navigation/item-map.mjs +0 -59
- package/esm2022/navigation/logical-cell.directive.mjs +0 -187
- package/esm2022/navigation/logical-cell.interface.mjs +0 -5
- package/esm2022/navigation/logical-row.directive.mjs +0 -135
- package/esm2022/navigation/logical-row.interface.mjs +0 -5
- package/esm2022/navigation/model-cell.mjs +0 -37
- package/esm2022/navigation/navigation-cell.interface.mjs +0 -5
- package/esm2022/navigation/navigation-change.interface.mjs +0 -5
- package/esm2022/navigation/navigation-cursor.mjs +0 -176
- package/esm2022/navigation/navigation-metadata.mjs +0 -31
- package/esm2022/navigation/navigation-mode.mjs +0 -5
- package/esm2022/navigation/navigation-model.mjs +0 -126
- package/esm2022/navigation/navigation-row.interface.mjs +0 -5
- package/esm2022/navigation/navigation.service.mjs +0 -695
- package/esm2022/navigation/treelist-focusable-element.mjs +0 -28
- package/esm2022/package-metadata.mjs +0 -16
- package/esm2022/pdf/export-element.mjs +0 -129
- package/esm2022/pdf/pdf-command-tool.directive.mjs +0 -68
- package/esm2022/pdf/pdf-command.directive.mjs +0 -101
- package/esm2022/pdf/pdf-export-event.mjs +0 -18
- package/esm2022/pdf/pdf-margin.component.mjs +0 -33
- package/esm2022/pdf/pdf-margin.interface.mjs +0 -5
- package/esm2022/pdf/pdf-template.directive.mjs +0 -45
- package/esm2022/pdf/pdf.component.mjs +0 -269
- package/esm2022/pdf/pdf.module.mjs +0 -48
- package/esm2022/pdf/pdf.service.mjs +0 -40
- package/esm2022/pdf/treelist-query.mjs +0 -45
- package/esm2022/progress-kendo-angular-treelist.mjs +0 -8
- package/esm2022/rendering/cell-template.directive.mjs +0 -49
- package/esm2022/rendering/cell.component.mjs +0 -383
- package/esm2022/rendering/common/col-group.component.mjs +0 -39
- package/esm2022/rendering/common/dom-queries.mjs +0 -158
- package/esm2022/rendering/common/field-accessor.pipe.mjs +0 -48
- package/esm2022/rendering/common/level-items.pipe.mjs +0 -30
- package/esm2022/rendering/common/loading.component.mjs +0 -42
- package/esm2022/rendering/common/row-class.mjs +0 -5
- package/esm2022/rendering/common/spacer.component.mjs +0 -61
- package/esm2022/rendering/constants.mjs +0 -28
- package/esm2022/rendering/footer-template.directive.mjs +0 -45
- package/esm2022/rendering/header/header-template.directive.mjs +0 -45
- package/esm2022/rendering/header/header.component.mjs +0 -978
- package/esm2022/rendering/header/select-all-checkbox.directive.mjs +0 -90
- package/esm2022/rendering/list.component.mjs +0 -850
- package/esm2022/rendering/no-records-template.directive.mjs +0 -40
- package/esm2022/rendering/table-body.component.mjs +0 -665
- package/esm2022/rendering/toolbar/toolbar-focusable.directive.mjs +0 -77
- package/esm2022/rendering/toolbar/toolbar-navigation.service.mjs +0 -54
- package/esm2022/rendering/toolbar/toolbar-template.directive.mjs +0 -58
- package/esm2022/rendering/toolbar/toolbar.component.mjs +0 -110
- package/esm2022/row-reordering/flat-reorder.service.mjs +0 -48
- package/esm2022/row-reordering/hierarchical-reorder.service.mjs +0 -55
- package/esm2022/row-reordering/row-reorder.service.mjs +0 -273
- package/esm2022/row-reordering/types.mjs +0 -5
- package/esm2022/row-reordering/utils.mjs +0 -128
- package/esm2022/scrolling/content-scroll-event.mjs +0 -5
- package/esm2022/scrolling/row-height.service.mjs +0 -30
- package/esm2022/scrolling/scroll-bottom-event.mjs +0 -5
- package/esm2022/scrolling/scroll-request.service.mjs +0 -21
- package/esm2022/scrolling/scroll-sync.service.mjs +0 -80
- package/esm2022/scrolling/scroller.service.mjs +0 -112
- package/esm2022/scrolling/scrollmode.mjs +0 -5
- package/esm2022/scrolling/suspend.service.mjs +0 -17
- package/esm2022/selection/is-selected.mjs +0 -5
- package/esm2022/selection/marquee.directive.mjs +0 -196
- package/esm2022/selection/selectable-settings.mjs +0 -5
- package/esm2022/selection/selectable.directive.mjs +0 -223
- package/esm2022/selection/selection-change-event.mjs +0 -28
- package/esm2022/selection/selection-state.mjs +0 -104
- package/esm2022/selection/selection.service.mjs +0 -264
- package/esm2022/treelist.component.mjs +0 -3111
- package/esm2022/treelist.module.mjs +0 -183
- package/esm2022/utils.mjs +0 -113
|
@@ -1,695 +0,0 @@
|
|
|
1
|
-
/**-----------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright © 2026 Progress Software Corporation. All rights reserved.
|
|
3
|
-
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
|
-
*-------------------------------------------------------------------------------------------*/
|
|
5
|
-
import { ChangeDetectorRef, EventEmitter, Injectable, NgZone, Optional } from '@angular/core';
|
|
6
|
-
import { isDocumentAvailable, Keys, normalizeKeys } from '@progress/kendo-angular-common';
|
|
7
|
-
import { LocalizationService } from '@progress/kendo-angular-l10n';
|
|
8
|
-
import { from, interval, Subscription } from 'rxjs';
|
|
9
|
-
import { filter, map, switchMap, switchMapTo, take, takeUntil } from 'rxjs/operators';
|
|
10
|
-
import { FocusRoot } from './focus-root';
|
|
11
|
-
import { FocusableDirective } from './focusable.directive';
|
|
12
|
-
import { NavigationCursor } from './navigation-cursor';
|
|
13
|
-
import { NavigationModel } from './navigation-model';
|
|
14
|
-
import { TreeListFocusableElement } from './treelist-focusable-element';
|
|
15
|
-
import { DomEventsService } from '../common/dom-events.service';
|
|
16
|
-
import { CellCloseEvent } from '../editing/cell-close-event';
|
|
17
|
-
import { EditService } from '../editing/edit.service';
|
|
18
|
-
import { ExpandStateService } from '../expand-state/expand-state.service';
|
|
19
|
-
import { closest, contains, findFocusableChild, isVisible, matchesNodeName } from '../rendering/common/dom-queries';
|
|
20
|
-
import { ScrollRequestService } from '../scrolling/scroll-request.service';
|
|
21
|
-
import { SelectionService } from '../selection/selection.service';
|
|
22
|
-
import { PagerContextService } from '@progress/kendo-angular-pager';
|
|
23
|
-
import { ContextService } from '../common/provider.service';
|
|
24
|
-
import { hasClasses } from '@progress/kendo-angular-common';
|
|
25
|
-
import * as i0 from "@angular/core";
|
|
26
|
-
import * as i1 from "../common/dom-events.service";
|
|
27
|
-
import * as i2 from "@progress/kendo-angular-pager";
|
|
28
|
-
import * as i3 from "../scrolling/scroll-request.service";
|
|
29
|
-
import * as i4 from "./focus-root";
|
|
30
|
-
import * as i5 from "../editing/edit.service";
|
|
31
|
-
import * as i6 from "@progress/kendo-angular-l10n";
|
|
32
|
-
import * as i7 from "../expand-state/expand-state.service";
|
|
33
|
-
import * as i8 from "../selection/selection.service";
|
|
34
|
-
import * as i9 from "../common/provider.service";
|
|
35
|
-
import * as i10 from "./focusable.directive";
|
|
36
|
-
const isInSameTreeList = (element, treelistElement) => closest(element, matchesNodeName('kendo-treelist')) === treelistElement;
|
|
37
|
-
const matchHeaderCell = matchesNodeName('th');
|
|
38
|
-
const matchDataCell = matchesNodeName('td');
|
|
39
|
-
const matchCell = (element) => matchDataCell(element) || matchHeaderCell(element);
|
|
40
|
-
const treelistCell = (element, treelistElement) => {
|
|
41
|
-
let target = closest(element, matchCell);
|
|
42
|
-
while (target && !isInSameTreeList(target, treelistElement)) {
|
|
43
|
-
target = closest(target.parentElement, matchCell);
|
|
44
|
-
}
|
|
45
|
-
return target;
|
|
46
|
-
};
|
|
47
|
-
const targetCell = (target, treelistElement) => {
|
|
48
|
-
const cell = treelistCell(target, treelistElement);
|
|
49
|
-
const row = closest(cell, matchesNodeName('tr'));
|
|
50
|
-
if (cell && row) {
|
|
51
|
-
let rowIndex = row.getAttribute('aria-rowindex') || row.getAttribute('data-kendo-treelist-row-index');
|
|
52
|
-
rowIndex = rowIndex ? parseInt(rowIndex, 10) - 1 : null;
|
|
53
|
-
let colIndex = cell.getAttribute('aria-colindex');
|
|
54
|
-
colIndex = colIndex ? parseInt(colIndex, 10) - 1 : null;
|
|
55
|
-
if (rowIndex !== null && colIndex !== null) {
|
|
56
|
-
return { colIndex, rowIndex, element: cell };
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
const isArrowKey = keyCode => keyCode === Keys.ArrowLeft || keyCode === Keys.ArrowRight ||
|
|
61
|
-
keyCode === Keys.ArrowUp || keyCode === Keys.ArrowDown;
|
|
62
|
-
const isNavigationKey = keyCode => isArrowKey(keyCode) ||
|
|
63
|
-
keyCode === Keys.PageUp || keyCode === Keys.PageDown ||
|
|
64
|
-
keyCode === Keys.Home || keyCode === Keys.End;
|
|
65
|
-
const isInput = matchesNodeName('input');
|
|
66
|
-
const isTextInput = element => element && isInput(element) && element.type.toLowerCase() === 'text';
|
|
67
|
-
const isPrintableCharacter = (str) => str.length === 1 && str.match(/\S/);
|
|
68
|
-
/**
|
|
69
|
-
* @hidden
|
|
70
|
-
*/
|
|
71
|
-
export class NavigationViewport {
|
|
72
|
-
firstItemIndex;
|
|
73
|
-
lastItemIndex;
|
|
74
|
-
constructor(firstItemIndex, lastItemIndex) {
|
|
75
|
-
this.firstItemIndex = firstItemIndex;
|
|
76
|
-
this.lastItemIndex = lastItemIndex;
|
|
77
|
-
}
|
|
78
|
-
containsRow(dataRowIndex) {
|
|
79
|
-
const headerRow = dataRowIndex < 0;
|
|
80
|
-
return headerRow || (dataRowIndex >= this.firstItemIndex && dataRowIndex <= this.lastItemIndex);
|
|
81
|
-
}
|
|
82
|
-
intersects(start, end) {
|
|
83
|
-
return (start <= this.firstItemIndex && this.lastItemIndex <= end) ||
|
|
84
|
-
(this.firstItemIndex <= start && start <= this.lastItemIndex) ||
|
|
85
|
-
(this.firstItemIndex <= end && end <= this.lastItemIndex);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* @hidden
|
|
90
|
-
*/
|
|
91
|
-
export class NavigationService {
|
|
92
|
-
zone;
|
|
93
|
-
domEvents;
|
|
94
|
-
pagerContextService;
|
|
95
|
-
scrollRequestService;
|
|
96
|
-
focusRoot;
|
|
97
|
-
editService;
|
|
98
|
-
localization;
|
|
99
|
-
expandState;
|
|
100
|
-
selectionService;
|
|
101
|
-
changeDetector;
|
|
102
|
-
ctx;
|
|
103
|
-
focusableParent;
|
|
104
|
-
changes;
|
|
105
|
-
cellKeydown = new EventEmitter();
|
|
106
|
-
set metadata(value) {
|
|
107
|
-
this.meta = value;
|
|
108
|
-
this.cursor.metadata = value;
|
|
109
|
-
}
|
|
110
|
-
get metadata() {
|
|
111
|
-
return this.meta;
|
|
112
|
-
}
|
|
113
|
-
get enabled() {
|
|
114
|
-
return this.alive;
|
|
115
|
-
}
|
|
116
|
-
get activeCell() {
|
|
117
|
-
if (this.mode !== 0 /* NavigationMode.Standby */) {
|
|
118
|
-
return this.cursor.cell;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
get activeRow() {
|
|
122
|
-
if (this.mode !== 0 /* NavigationMode.Standby */) {
|
|
123
|
-
return Object.assign({}, this.cursor.row, {
|
|
124
|
-
cells: this.cursor.row.cells.toArray()
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
viewport;
|
|
129
|
-
columnViewport;
|
|
130
|
-
activeRowIndex = 0;
|
|
131
|
-
alive = false;
|
|
132
|
-
active = true;
|
|
133
|
-
mode = 0 /* NavigationMode.Standby */;
|
|
134
|
-
model = new NavigationModel();
|
|
135
|
-
cursor = new NavigationCursor(this.model);
|
|
136
|
-
meta;
|
|
137
|
-
subs;
|
|
138
|
-
pendingRowIndex;
|
|
139
|
-
virtualCell;
|
|
140
|
-
get activeDataRow() {
|
|
141
|
-
return Math.max(0, this.activeRowIndex - this.meta.headerRows);
|
|
142
|
-
}
|
|
143
|
-
constructor(zone, domEvents, pagerContextService, scrollRequestService, focusRoot, editService, localization, expandState, selectionService, changeDetector, ctx, focusableParent) {
|
|
144
|
-
this.zone = zone;
|
|
145
|
-
this.domEvents = domEvents;
|
|
146
|
-
this.pagerContextService = pagerContextService;
|
|
147
|
-
this.scrollRequestService = scrollRequestService;
|
|
148
|
-
this.focusRoot = focusRoot;
|
|
149
|
-
this.editService = editService;
|
|
150
|
-
this.localization = localization;
|
|
151
|
-
this.expandState = expandState;
|
|
152
|
-
this.selectionService = selectionService;
|
|
153
|
-
this.changeDetector = changeDetector;
|
|
154
|
-
this.ctx = ctx;
|
|
155
|
-
this.focusableParent = focusableParent;
|
|
156
|
-
this.changes = this.cursor.changes;
|
|
157
|
-
}
|
|
158
|
-
init(meta) {
|
|
159
|
-
this.alive = true;
|
|
160
|
-
this.focusRoot.active = true;
|
|
161
|
-
this.metadata = meta;
|
|
162
|
-
const onStableSubscriber = (...operators) => (args) => this.zone.isStable ?
|
|
163
|
-
from([true]).pipe(map(() => args)) :
|
|
164
|
-
this.zone.onStable.pipe(take(1), map(() => args), ...operators);
|
|
165
|
-
const onStable = onStableSubscriber();
|
|
166
|
-
this.subs = new Subscription();
|
|
167
|
-
this.subs.add(this.cursor.changes
|
|
168
|
-
.subscribe(args => this.onCursorChanges(args)));
|
|
169
|
-
this.subs.add(this.domEvents.focus.pipe(switchMap(onStable))
|
|
170
|
-
.subscribe((args) => this.navigateTo(args.target)));
|
|
171
|
-
this.subs.add(this.domEvents.focusOut.pipe(filter(() => this.mode !== 0 /* NavigationMode.Standby */), switchMap(onStableSubscriber(takeUntil(this.domEvents.focus))))
|
|
172
|
-
.subscribe(args => this.onFocusOut(args)));
|
|
173
|
-
this.subs.add(this.domEvents.windowBlur.pipe(filter(() => this.mode !== 0 /* NavigationMode.Standby */))
|
|
174
|
-
.subscribe(() => this.onWindowBlur()));
|
|
175
|
-
this.subs.add(
|
|
176
|
-
// Closing the editor will not always trigger focusout in Firefox.
|
|
177
|
-
// To get around this, we ensure that the cell is closed after editing.
|
|
178
|
-
this.editService.changes.pipe(filter((e) => {
|
|
179
|
-
if (e instanceof CellCloseEvent) {
|
|
180
|
-
return !e.isDefaultPrevented();
|
|
181
|
-
}
|
|
182
|
-
return e.action !== 'edit' && this.mode === 2 /* NavigationMode.Content */;
|
|
183
|
-
}), switchMap(onStable))
|
|
184
|
-
.subscribe(() => this.leaveCell()));
|
|
185
|
-
this.subs.add(this.pagerContextService.pageChange
|
|
186
|
-
.subscribe(() => this.cursor.reset(0, 0)));
|
|
187
|
-
this.subs.add(this.domEvents.keydown
|
|
188
|
-
.subscribe(args => this.onKeydown(args)));
|
|
189
|
-
this.subs.add(this.domEvents.keydown.pipe(filter(args => args.code === Keys.Tab && this.mode === 2 /* NavigationMode.Content */), switchMapTo(this.domEvents.focusOut.pipe(takeUntil(
|
|
190
|
-
// Timeout if focusOut doesn't fire very soon
|
|
191
|
-
interval(0).pipe(take(1))))))
|
|
192
|
-
.subscribe(() => this.onTabout()));
|
|
193
|
-
if (this.focusableParent) {
|
|
194
|
-
const element = new TreeListFocusableElement(this);
|
|
195
|
-
this.focusableParent.registerElement(element);
|
|
196
|
-
}
|
|
197
|
-
this.deactivateElements();
|
|
198
|
-
}
|
|
199
|
-
ngOnDestroy() {
|
|
200
|
-
if (this.subs) {
|
|
201
|
-
this.subs.unsubscribe();
|
|
202
|
-
}
|
|
203
|
-
this.alive = false;
|
|
204
|
-
}
|
|
205
|
-
registerCell(cell) {
|
|
206
|
-
if (cell.logicalRowIndex !== this.pendingRowIndex) {
|
|
207
|
-
const modelCell = this.model.registerCell(cell);
|
|
208
|
-
if (this.virtualCell && this.cursor.activateVirtualCell(modelCell)) {
|
|
209
|
-
this.virtualCell = false;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
registerCellOnCurrentRow(cell) {
|
|
214
|
-
if (cell.logicalRowIndex === this.pendingRowIndex) {
|
|
215
|
-
this.model.registerCell(cell);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
unregisterCell(index, rowIndex, cell) {
|
|
219
|
-
this.model.unregisterCell(index, rowIndex, cell);
|
|
220
|
-
}
|
|
221
|
-
registerRow(row) {
|
|
222
|
-
this.model.registerRow(row);
|
|
223
|
-
this.pendingRowIndex = row.logicalRowIndex;
|
|
224
|
-
}
|
|
225
|
-
updateRow(row) {
|
|
226
|
-
this.model.updateRow(row);
|
|
227
|
-
}
|
|
228
|
-
unregisterRow(index, row) {
|
|
229
|
-
this.model.unregisterRow(index, row);
|
|
230
|
-
}
|
|
231
|
-
isCellFocusable(cell) {
|
|
232
|
-
return this.alive &&
|
|
233
|
-
this.active &&
|
|
234
|
-
this.mode !== 2 /* NavigationMode.Content */ &&
|
|
235
|
-
this.cursor.isActive(cell.logicalRowIndex, cell.logicalColIndex);
|
|
236
|
-
}
|
|
237
|
-
isCellFocused(cell) {
|
|
238
|
-
return this.mode === 1 /* NavigationMode.Cursor */ && this.isCellFocusable(cell);
|
|
239
|
-
}
|
|
240
|
-
navigateTo(el) {
|
|
241
|
-
if (!this.alive || !isDocumentAvailable()) {
|
|
242
|
-
return;
|
|
243
|
-
}
|
|
244
|
-
const cell = targetCell(el, this.meta.treelistElement.nativeElement);
|
|
245
|
-
if (!cell) {
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
248
|
-
const oldMode = this.mode;
|
|
249
|
-
const focusInCell = contains(cell.element, document.activeElement);
|
|
250
|
-
const focusInActiveRowContent = this.mode === 2 /* NavigationMode.Content */ &&
|
|
251
|
-
this.activeRowIndex === cell.rowIndex &&
|
|
252
|
-
el !== cell.element;
|
|
253
|
-
if (focusInCell) {
|
|
254
|
-
this.mode = 2 /* NavigationMode.Content */;
|
|
255
|
-
this.cursor.reset(cell.rowIndex, cell.colIndex);
|
|
256
|
-
this.activateRow();
|
|
257
|
-
}
|
|
258
|
-
else if (!focusInActiveRowContent) {
|
|
259
|
-
this.mode = 1 /* NavigationMode.Cursor */;
|
|
260
|
-
this.deactivateElements();
|
|
261
|
-
const alreadyActive = this.cursor.isActive(cell.rowIndex, cell.colIndex);
|
|
262
|
-
const isCursor = oldMode === 1 /* NavigationMode.Cursor */ && alreadyActive;
|
|
263
|
-
if (!isCursor) {
|
|
264
|
-
this.cursor.reset(cell.rowIndex, cell.colIndex);
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
tryFocus(el) {
|
|
269
|
-
this.activateElements();
|
|
270
|
-
const focusable = findFocusableChild(el);
|
|
271
|
-
if (focusable) {
|
|
272
|
-
const cell = targetCell(focusable, this.meta.treelistElement.nativeElement);
|
|
273
|
-
if (cell) {
|
|
274
|
-
this.cursor.reset(cell.rowIndex, cell.colIndex);
|
|
275
|
-
this.deactivateElements();
|
|
276
|
-
this.enterCell();
|
|
277
|
-
}
|
|
278
|
-
focusable.focus();
|
|
279
|
-
}
|
|
280
|
-
else {
|
|
281
|
-
this.deactivateElements();
|
|
282
|
-
}
|
|
283
|
-
return !!focusable;
|
|
284
|
-
}
|
|
285
|
-
needsViewport() {
|
|
286
|
-
return this.meta && this.meta.isVirtual;
|
|
287
|
-
}
|
|
288
|
-
setViewport(firstItemIndex, lastItemIndex) {
|
|
289
|
-
this.viewport = new NavigationViewport(firstItemIndex, lastItemIndex);
|
|
290
|
-
if (this.enabled && this.meta && this.meta.isVirtual && this.activeDataRow > -1) {
|
|
291
|
-
const dataRowIndex = this.activeDataRow;
|
|
292
|
-
const ahead = firstItemIndex - dataRowIndex;
|
|
293
|
-
const behind = dataRowIndex - lastItemIndex;
|
|
294
|
-
if (ahead > 0) {
|
|
295
|
-
this.cursor.reset(firstItemIndex + this.meta.headerRows);
|
|
296
|
-
}
|
|
297
|
-
else if (behind > 0) {
|
|
298
|
-
this.cursor.reset(lastItemIndex - this.meta.headerRows);
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
setColumnViewport(firstItemIndex, lastItemIndex) {
|
|
303
|
-
this.columnViewport = new NavigationViewport(firstItemIndex, lastItemIndex);
|
|
304
|
-
}
|
|
305
|
-
focusCell(rowIndex = undefined, colIndex = undefined) {
|
|
306
|
-
this.mode = 1 /* NavigationMode.Cursor */;
|
|
307
|
-
this.cursor.reset(rowIndex, colIndex);
|
|
308
|
-
return this.activeCell;
|
|
309
|
-
}
|
|
310
|
-
focusNextCell(wrap = true) {
|
|
311
|
-
return this.focusAdjacentCell(true, wrap);
|
|
312
|
-
}
|
|
313
|
-
focusPrevCell(wrap = true) {
|
|
314
|
-
return this.focusAdjacentCell(false, wrap);
|
|
315
|
-
}
|
|
316
|
-
toggle(active) {
|
|
317
|
-
this.active = active;
|
|
318
|
-
this.cursor.announce();
|
|
319
|
-
}
|
|
320
|
-
hasFocus() {
|
|
321
|
-
return this.mode === 1 /* NavigationMode.Cursor */ || this.mode === 2 /* NavigationMode.Content */;
|
|
322
|
-
}
|
|
323
|
-
autoFocusCell(start, end) {
|
|
324
|
-
return !this.meta.virtualColumns || end < this.meta.columns.lockedLeafColumns.length || this.columnViewport.intersects(start, end);
|
|
325
|
-
}
|
|
326
|
-
focusAdjacentCell(fwd, wrap) {
|
|
327
|
-
this.focusCell();
|
|
328
|
-
let success = fwd ? this.moveCursorFwd() : this.moveCursorBwd();
|
|
329
|
-
if (wrap && !success) {
|
|
330
|
-
success = fwd ? this.cursor.moveDown(1) : this.cursor.moveUp(1);
|
|
331
|
-
if (success) {
|
|
332
|
-
const row = this.cursor.row;
|
|
333
|
-
const colIdx = fwd ? 0 : this.cursor.lastCellIndex();
|
|
334
|
-
this.cursor.reset(row.index, colIdx);
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
if (success) {
|
|
338
|
-
return this.activeCell;
|
|
339
|
-
}
|
|
340
|
-
else {
|
|
341
|
-
this.mode = 0 /* NavigationMode.Standby */;
|
|
342
|
-
this.cursor.announce();
|
|
343
|
-
}
|
|
344
|
-
return null;
|
|
345
|
-
}
|
|
346
|
-
enterCell() {
|
|
347
|
-
const cell = this.cursor.cell;
|
|
348
|
-
if (!cell) {
|
|
349
|
-
return;
|
|
350
|
-
}
|
|
351
|
-
const group = cell.focusGroup;
|
|
352
|
-
const focusable = group && group.canFocus();
|
|
353
|
-
this.mode = focusable ? 2 /* NavigationMode.Content */ : 1 /* NavigationMode.Cursor */;
|
|
354
|
-
this.cursor.announce();
|
|
355
|
-
if (focusable) {
|
|
356
|
-
this.activateRow();
|
|
357
|
-
group.focus();
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
leaveCell() {
|
|
361
|
-
const cell = this.cursor.cell;
|
|
362
|
-
if (!cell) {
|
|
363
|
-
return;
|
|
364
|
-
}
|
|
365
|
-
const group = cell.focusGroup;
|
|
366
|
-
const focusable = group && group.canFocus();
|
|
367
|
-
if (!focusable) {
|
|
368
|
-
this.deactivateElements();
|
|
369
|
-
}
|
|
370
|
-
this.mode = 1 /* NavigationMode.Cursor */;
|
|
371
|
-
this.cursor.announce();
|
|
372
|
-
}
|
|
373
|
-
activateElements() {
|
|
374
|
-
this.focusRoot.activate();
|
|
375
|
-
}
|
|
376
|
-
deactivateElements() {
|
|
377
|
-
this.focusRoot.deactivate();
|
|
378
|
-
}
|
|
379
|
-
activateRow() {
|
|
380
|
-
this.cursor.row.cells
|
|
381
|
-
.forEach(cell => cell.focusGroup && cell.focusGroup.activate());
|
|
382
|
-
}
|
|
383
|
-
moveCursorFwd() {
|
|
384
|
-
return this.localization.rtl ? this.cursor.moveLeft() : this.cursor.moveRight();
|
|
385
|
-
}
|
|
386
|
-
moveCursorBwd() {
|
|
387
|
-
return this.localization.rtl ? this.cursor.moveRight() : this.cursor.moveLeft();
|
|
388
|
-
}
|
|
389
|
-
updateSelection(args) {
|
|
390
|
-
if (this.selectionService.enabled && this.cursor.row.dataItem) {
|
|
391
|
-
this.selectionService.click({
|
|
392
|
-
dataItem: this.cursor.row.dataItem,
|
|
393
|
-
column: this.cursor.cell.column,
|
|
394
|
-
columnIndex: this.cursor.cell.colIndex,
|
|
395
|
-
originalEvent: args
|
|
396
|
-
});
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
onCursorKeydown(args) {
|
|
400
|
-
let preventDefault = false;
|
|
401
|
-
const modifier = args.ctrlKey || args.metaKey;
|
|
402
|
-
const step = modifier ? 5 : 1;
|
|
403
|
-
if (!this.onCellKeydown(args)) {
|
|
404
|
-
return;
|
|
405
|
-
}
|
|
406
|
-
// on some keyboards arrow keys, PageUp/Down, and Home/End are mapped to Numpad keys
|
|
407
|
-
const code = normalizeKeys(args);
|
|
408
|
-
if ((args.ctrlKey || args.metaKey) && args.shiftKey && (code === Keys.ArrowUp || code === Keys.ArrowDown)) {
|
|
409
|
-
const row = this.cursor.row;
|
|
410
|
-
if (this.handleRowReorderKeyboard(args, code, row)) {
|
|
411
|
-
args.preventDefault();
|
|
412
|
-
return;
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
const row = this.cursor.row;
|
|
416
|
-
switch (code) {
|
|
417
|
-
case Keys.Space:
|
|
418
|
-
this.updateSelection(args);
|
|
419
|
-
preventDefault = this.selectionService.enabled;
|
|
420
|
-
break;
|
|
421
|
-
case Keys.KeyA:
|
|
422
|
-
if (modifier && this.selectionService.enabled) {
|
|
423
|
-
this.zone.run(() => this.selectionService.toggleAll(true));
|
|
424
|
-
preventDefault = true;
|
|
425
|
-
}
|
|
426
|
-
break;
|
|
427
|
-
case Keys.ArrowDown:
|
|
428
|
-
preventDefault = this.cursor.moveDown(step);
|
|
429
|
-
if (preventDefault && args.shiftKey && !modifier) {
|
|
430
|
-
this.updateSelection(args);
|
|
431
|
-
}
|
|
432
|
-
break;
|
|
433
|
-
case Keys.ArrowUp:
|
|
434
|
-
preventDefault = this.cursor.moveUp(step);
|
|
435
|
-
if (preventDefault && args.shiftKey && !modifier) {
|
|
436
|
-
this.updateSelection(args);
|
|
437
|
-
}
|
|
438
|
-
break;
|
|
439
|
-
case Keys.ArrowRight:
|
|
440
|
-
if (args.altKey) {
|
|
441
|
-
this.zone.run(() => {
|
|
442
|
-
this.expandState.expand(row.dataItem);
|
|
443
|
-
});
|
|
444
|
-
preventDefault = true;
|
|
445
|
-
}
|
|
446
|
-
else {
|
|
447
|
-
preventDefault = this.moveCursorFwd();
|
|
448
|
-
if (preventDefault && args.shiftKey) {
|
|
449
|
-
this.updateSelection(args);
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
break;
|
|
453
|
-
case Keys.ArrowLeft:
|
|
454
|
-
if (args.altKey) {
|
|
455
|
-
this.zone.run(() => {
|
|
456
|
-
this.expandState.collapse(row.dataItem);
|
|
457
|
-
});
|
|
458
|
-
preventDefault = true;
|
|
459
|
-
}
|
|
460
|
-
else {
|
|
461
|
-
preventDefault = this.moveCursorBwd();
|
|
462
|
-
if (preventDefault && args.shiftKey) {
|
|
463
|
-
this.updateSelection(args);
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
break;
|
|
467
|
-
case Keys.PageDown:
|
|
468
|
-
if (this.metadata.isVirtual && this.viewport) {
|
|
469
|
-
let nextItemIndex = this.meta.headerRows + this.viewport.lastItemIndex + 1;
|
|
470
|
-
nextItemIndex = Math.min(this.meta.maxLogicalRowIndex, nextItemIndex);
|
|
471
|
-
this.cursor.reset(nextItemIndex);
|
|
472
|
-
preventDefault = true;
|
|
473
|
-
}
|
|
474
|
-
else if (this.metadata.hasPager) {
|
|
475
|
-
this.zone.run(() => this.pagerContextService.nextPage());
|
|
476
|
-
preventDefault = true;
|
|
477
|
-
}
|
|
478
|
-
break;
|
|
479
|
-
case Keys.PageUp:
|
|
480
|
-
if (this.metadata.isVirtual && this.viewport) {
|
|
481
|
-
const viewportSize = this.viewport.lastItemIndex - this.viewport.firstItemIndex;
|
|
482
|
-
const firstItemIndex = this.viewport.firstItemIndex;
|
|
483
|
-
const nextItemIndex = Math.max(this.meta.headerRows, firstItemIndex - viewportSize - 1);
|
|
484
|
-
this.cursor.reset(nextItemIndex);
|
|
485
|
-
preventDefault = true;
|
|
486
|
-
}
|
|
487
|
-
else if (this.metadata.hasPager) {
|
|
488
|
-
this.zone.run(() => this.pagerContextService.prevPage());
|
|
489
|
-
preventDefault = true;
|
|
490
|
-
}
|
|
491
|
-
break;
|
|
492
|
-
case Keys.Home:
|
|
493
|
-
if (modifier) {
|
|
494
|
-
if (this.meta.isVirtual) {
|
|
495
|
-
this.cursor.reset(this.meta.headerRows, 0, false);
|
|
496
|
-
}
|
|
497
|
-
else {
|
|
498
|
-
this.cursor.reset(this.model.firstRow.index, 0, false);
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
else {
|
|
502
|
-
this.cursor.reset(row.index, 0, false);
|
|
503
|
-
}
|
|
504
|
-
preventDefault = true;
|
|
505
|
-
break;
|
|
506
|
-
case Keys.End:
|
|
507
|
-
if (modifier) {
|
|
508
|
-
if (this.meta.isVirtual) {
|
|
509
|
-
const lastRowIndex = this.meta.maxLogicalRowIndex;
|
|
510
|
-
this.cursor.reset(lastRowIndex, this.cursor.lastCellIndex(), false);
|
|
511
|
-
}
|
|
512
|
-
else {
|
|
513
|
-
this.cursor.reset(this.model.lastRow.index, this.cursor.lastCellIndex(), false);
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
else {
|
|
517
|
-
const lastIndex = this.cursor.lastCellIndex();
|
|
518
|
-
const cell = this.model.findCell(lastIndex, row);
|
|
519
|
-
if (cell) {
|
|
520
|
-
this.cursor.reset(cell.rowIndex, cell.colIndex);
|
|
521
|
-
}
|
|
522
|
-
else {
|
|
523
|
-
this.cursor.reset(row.index, lastIndex);
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
preventDefault = true;
|
|
527
|
-
break;
|
|
528
|
-
case Keys.Enter:
|
|
529
|
-
if (!modifier && !args.shiftKey) {
|
|
530
|
-
const editing = this.editService.isEditingCell();
|
|
531
|
-
const cell = this.cursor.cell;
|
|
532
|
-
if (!editing && cell.expandable === true) {
|
|
533
|
-
this.zone.run(() => {
|
|
534
|
-
this.expandState.toggleState(row.dataItem);
|
|
535
|
-
});
|
|
536
|
-
}
|
|
537
|
-
else {
|
|
538
|
-
this.enterCell();
|
|
539
|
-
if (!cell.focusGroup.isNavigable()) {
|
|
540
|
-
preventDefault = true;
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
break;
|
|
545
|
-
default:
|
|
546
|
-
if (!modifier && !args.altKey && isPrintableCharacter(args.key)) {
|
|
547
|
-
this.enterCell();
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
if (preventDefault) {
|
|
551
|
-
args.preventDefault();
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
onContentKeydown(args) {
|
|
555
|
-
if (!this.onCellKeydown(args)) {
|
|
556
|
-
return;
|
|
557
|
-
}
|
|
558
|
-
// on some keyboards arrow keys, PageUp/Down, and Home/End are mapped to Numpad keys
|
|
559
|
-
const code = normalizeKeys(args);
|
|
560
|
-
const confirm = !args.defaultPrevented && code === Keys.Enter && isTextInput(args.target);
|
|
561
|
-
if (code === Keys.Escape || code === Keys.F2 || confirm) {
|
|
562
|
-
this.leaveCell();
|
|
563
|
-
this.cursor.reset();
|
|
564
|
-
args.stopPropagation();
|
|
565
|
-
}
|
|
566
|
-
else if (isNavigationKey(code) && this.cursor.cell.focusGroup.isNavigable()) {
|
|
567
|
-
this.onCursorKeydown(args);
|
|
568
|
-
if (args.defaultPrevented) {
|
|
569
|
-
this.leaveCell();
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
onCellKeydown(args) {
|
|
574
|
-
// on some keyboards arrow keys, PageUp/Down, and Home/End are mapped to Numpad keys
|
|
575
|
-
const code = normalizeKeys(args);
|
|
576
|
-
if (this.editService.isEditingCell()) {
|
|
577
|
-
const confirm = code === Keys.Enter || code === Keys.NumpadEnter;
|
|
578
|
-
const cancel = code === Keys.Escape;
|
|
579
|
-
const navigate = isNavigationKey(code);
|
|
580
|
-
if (confirm) {
|
|
581
|
-
return !this.editService.closeCell(args);
|
|
582
|
-
}
|
|
583
|
-
else if (cancel) {
|
|
584
|
-
this.editService.cancelCell();
|
|
585
|
-
this.meta.view.updateEditedState();
|
|
586
|
-
this.changeDetector.detectChanges();
|
|
587
|
-
}
|
|
588
|
-
else if (navigate) {
|
|
589
|
-
return false;
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
this.cellKeydown.emit(args);
|
|
593
|
-
return true;
|
|
594
|
-
}
|
|
595
|
-
onCursorChanges(args) {
|
|
596
|
-
this.activeRowIndex = args.rowIndex;
|
|
597
|
-
const dataRowIndex = this.activeDataRow;
|
|
598
|
-
if (this.meta && (this.meta.isVirtual && this.viewport &&
|
|
599
|
-
!this.viewport.containsRow(dataRowIndex) && dataRowIndex > -1)) {
|
|
600
|
-
this.scrollRequestService.scrollTo({ row: dataRowIndex });
|
|
601
|
-
}
|
|
602
|
-
if (this.meta.virtualColumns && args.colIndex >= this.meta.columns.lockedLeafColumns.length) {
|
|
603
|
-
const cell = this.activeCell;
|
|
604
|
-
const { start, end } = this.model.cellRange(cell);
|
|
605
|
-
if (!cell) {
|
|
606
|
-
this.virtualCell = true;
|
|
607
|
-
}
|
|
608
|
-
if ((!cell && this.mode !== 0 /* NavigationMode.Standby */) || (cell && !this.columnViewport.intersects(start, end))) {
|
|
609
|
-
this.scrollRequestService.scrollTo({ column: args.colIndex });
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
onFocusOut(args) {
|
|
614
|
-
if (isVisible(args.target)) {
|
|
615
|
-
this.mode = 0 /* NavigationMode.Standby */;
|
|
616
|
-
}
|
|
617
|
-
else {
|
|
618
|
-
// Focused target is no longer visible,
|
|
619
|
-
// reset to cursor mode and recapture focus.
|
|
620
|
-
this.mode = 1 /* NavigationMode.Cursor */;
|
|
621
|
-
}
|
|
622
|
-
this.deactivateElements();
|
|
623
|
-
this.cursor.announce();
|
|
624
|
-
}
|
|
625
|
-
onWindowBlur() {
|
|
626
|
-
this.mode = 0 /* NavigationMode.Standby */;
|
|
627
|
-
this.deactivateElements();
|
|
628
|
-
this.cursor.announce();
|
|
629
|
-
}
|
|
630
|
-
handleRowReorderKeyboard(args, code, row) {
|
|
631
|
-
if (!this.ctx.treelist?.rowReorderable || !this.activeCell) {
|
|
632
|
-
return false;
|
|
633
|
-
}
|
|
634
|
-
const cellElement = args.target;
|
|
635
|
-
if (!cellElement) {
|
|
636
|
-
return false;
|
|
637
|
-
}
|
|
638
|
-
const dragCell = closest(cellElement, (el) => hasClasses(el, 'k-drag-cell'));
|
|
639
|
-
if (!dragCell || row.dataRowIndex < 0 || !row.dataItem) {
|
|
640
|
-
return false;
|
|
641
|
-
}
|
|
642
|
-
const isUpArrow = code === Keys.ArrowUp;
|
|
643
|
-
const currentRowIndex = row.dataRowIndex;
|
|
644
|
-
const view = this.ctx.treelist.view;
|
|
645
|
-
if (!view || view.length === 0) {
|
|
646
|
-
return false;
|
|
647
|
-
}
|
|
648
|
-
const targetRowIndex = currentRowIndex + (isUpArrow ? -1 : 1);
|
|
649
|
-
if (targetRowIndex < 0 || targetRowIndex >= view.length) {
|
|
650
|
-
return false;
|
|
651
|
-
}
|
|
652
|
-
const dropPosition = isUpArrow ? 'before' : 'after';
|
|
653
|
-
this.zone.run(() => {
|
|
654
|
-
const rowReorderService = this.ctx.treelist.rowReorderService;
|
|
655
|
-
if (rowReorderService?.reorderViaKeyboard) {
|
|
656
|
-
// Convert ViewCollection to array for the reorder method
|
|
657
|
-
const viewArray = Array.from({ length: view.length }, (_, i) => view.at(i));
|
|
658
|
-
rowReorderService.reorderViaKeyboard(currentRowIndex, targetRowIndex, dropPosition, viewArray);
|
|
659
|
-
// Move focus to follow the reordered row
|
|
660
|
-
// After reordering, the row will be at the target position
|
|
661
|
-
this.zone.onStable.pipe(take(1)).subscribe(() => {
|
|
662
|
-
const newRowIndex = this.meta.headerRows + targetRowIndex;
|
|
663
|
-
this.cursor.reset(newRowIndex, this.activeCell.colIndex);
|
|
664
|
-
});
|
|
665
|
-
}
|
|
666
|
-
});
|
|
667
|
-
return true;
|
|
668
|
-
}
|
|
669
|
-
onKeydown(args) {
|
|
670
|
-
if (this.mode === 1 /* NavigationMode.Cursor */) {
|
|
671
|
-
this.onCursorKeydown(args);
|
|
672
|
-
}
|
|
673
|
-
else if (this.mode === 2 /* NavigationMode.Content */) {
|
|
674
|
-
this.onContentKeydown(args);
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
onTabout() {
|
|
678
|
-
// Tabbed out of the last focusable content element
|
|
679
|
-
// reset to cursor mode and recapture focus.
|
|
680
|
-
if (this.cursor.cell.focusGroup.isNavigable()) {
|
|
681
|
-
// Unless the cell has a single focusable element,
|
|
682
|
-
// otherwise we'd return to Content mode and enter an endless loop
|
|
683
|
-
return;
|
|
684
|
-
}
|
|
685
|
-
this.leaveCell();
|
|
686
|
-
this.cursor.reset();
|
|
687
|
-
}
|
|
688
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: NavigationService, deps: [{ token: i0.NgZone }, { token: i1.DomEventsService }, { token: i2.PagerContextService }, { token: i3.ScrollRequestService }, { token: i4.FocusRoot }, { token: i5.EditService }, { token: i6.LocalizationService }, { token: i7.ExpandStateService }, { token: i8.SelectionService }, { token: i0.ChangeDetectorRef }, { token: i9.ContextService }, { token: i10.FocusableDirective, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
689
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: NavigationService });
|
|
690
|
-
}
|
|
691
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: NavigationService, decorators: [{
|
|
692
|
-
type: Injectable
|
|
693
|
-
}], ctorParameters: () => [{ type: i0.NgZone }, { type: i1.DomEventsService }, { type: i2.PagerContextService }, { type: i3.ScrollRequestService }, { type: i4.FocusRoot }, { type: i5.EditService }, { type: i6.LocalizationService }, { type: i7.ExpandStateService }, { type: i8.SelectionService }, { type: i0.ChangeDetectorRef }, { type: i9.ContextService }, { type: i10.FocusableDirective, decorators: [{
|
|
694
|
-
type: Optional
|
|
695
|
-
}] }] });
|