@angular/cdk 7.0.3 → 7.2.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.
- package/a11y/typings/focus-monitor/focus-monitor.d.ts +20 -4
- package/a11y/typings/index.metadata.json +1 -1
- package/a11y/typings/key-manager/list-key-manager.d.ts +8 -0
- package/a11y/typings/live-announcer/live-announcer.d.ts +37 -4
- package/bidi/typings/dir.d.ts +4 -1
- package/bidi/typings/index.metadata.json +1 -1
- package/bundles/cdk-a11y.umd.js +503 -210
- package/bundles/cdk-a11y.umd.js.map +1 -1
- package/bundles/cdk-a11y.umd.min.js +1 -1
- package/bundles/cdk-a11y.umd.min.js.map +1 -1
- package/bundles/cdk-accordion.umd.js +16 -9
- package/bundles/cdk-accordion.umd.js.map +1 -1
- package/bundles/cdk-accordion.umd.min.js.map +1 -1
- package/bundles/cdk-bidi.umd.js +16 -7
- package/bundles/cdk-bidi.umd.js.map +1 -1
- package/bundles/cdk-bidi.umd.min.js +1 -1
- package/bundles/cdk-bidi.umd.min.js.map +1 -1
- package/bundles/cdk-coercion.umd.js +5 -5
- package/bundles/cdk-coercion.umd.js.map +1 -1
- package/bundles/cdk-collections.umd.js +28 -5
- package/bundles/cdk-collections.umd.js.map +1 -1
- package/bundles/cdk-collections.umd.min.js.map +1 -1
- package/bundles/cdk-drag-drop.umd.js +2251 -853
- package/bundles/cdk-drag-drop.umd.js.map +1 -1
- package/bundles/cdk-drag-drop.umd.min.js +2 -1
- package/bundles/cdk-drag-drop.umd.min.js.map +1 -1
- package/bundles/cdk-keycodes.umd.js +33 -1
- package/bundles/cdk-keycodes.umd.js.map +1 -1
- package/bundles/cdk-keycodes.umd.min.js +1 -1
- package/bundles/cdk-keycodes.umd.min.js.map +1 -1
- package/bundles/cdk-layout.umd.js +29 -22
- package/bundles/cdk-layout.umd.js.map +1 -1
- package/bundles/cdk-layout.umd.min.js +1 -1
- package/bundles/cdk-layout.umd.min.js.map +1 -1
- package/bundles/cdk-observers.umd.js +25 -6
- package/bundles/cdk-observers.umd.js.map +1 -1
- package/bundles/cdk-observers.umd.min.js.map +1 -1
- package/bundles/cdk-overlay.umd.js +600 -243
- package/bundles/cdk-overlay.umd.js.map +1 -1
- package/bundles/cdk-overlay.umd.min.js +2 -2
- package/bundles/cdk-overlay.umd.min.js.map +1 -1
- package/bundles/cdk-platform.umd.js +50 -28
- package/bundles/cdk-platform.umd.js.map +1 -1
- package/bundles/cdk-platform.umd.min.js.map +1 -1
- package/bundles/cdk-portal.umd.js +14 -7
- package/bundles/cdk-portal.umd.js.map +1 -1
- package/bundles/cdk-portal.umd.min.js.map +1 -1
- package/bundles/cdk-scrolling.umd.js +143 -48
- package/bundles/cdk-scrolling.umd.js.map +1 -1
- package/bundles/cdk-scrolling.umd.min.js +1 -1
- package/bundles/cdk-scrolling.umd.min.js.map +1 -1
- package/bundles/cdk-stepper.umd.js +103 -19
- package/bundles/cdk-stepper.umd.js.map +1 -1
- package/bundles/cdk-stepper.umd.min.js +1 -1
- package/bundles/cdk-stepper.umd.min.js.map +1 -1
- package/bundles/cdk-table.umd.js +182 -48
- package/bundles/cdk-table.umd.js.map +1 -1
- package/bundles/cdk-table.umd.min.js.map +1 -1
- package/bundles/cdk-text-field.umd.js +70 -32
- package/bundles/cdk-text-field.umd.js.map +1 -1
- package/bundles/cdk-text-field.umd.min.js +1 -1
- package/bundles/cdk-text-field.umd.min.js.map +1 -1
- package/bundles/cdk-tree.umd.js +71 -34
- package/bundles/cdk-tree.umd.js.map +1 -1
- package/bundles/cdk-tree.umd.min.js +1 -1
- package/bundles/cdk-tree.umd.min.js.map +1 -1
- package/bundles/cdk.umd.js +5 -4
- package/bundles/cdk.umd.js.map +1 -1
- package/bundles/cdk.umd.min.js +1 -1
- package/bundles/cdk.umd.min.js.map +1 -1
- package/drag-drop/typings/{drag-handle.d.ts → directives/drag-handle.d.ts} +3 -0
- package/drag-drop/typings/{drag-placeholder.d.ts → directives/drag-placeholder.d.ts} +0 -0
- package/drag-drop/typings/{drag-preview.d.ts → directives/drag-preview.d.ts} +0 -0
- package/drag-drop/typings/directives/drag.d.ts +108 -0
- package/drag-drop/typings/directives/drop-list-group.d.ts +22 -0
- package/drag-drop/typings/directives/drop-list.d.ts +135 -0
- package/drag-drop/typings/drag-drop-registry.d.ts +8 -5
- package/drag-drop/typings/drag-events.d.ts +24 -6
- package/{typings/esm5/drag-drop/drag.d.ts → drag-drop/typings/drag-ref.d.ts} +153 -77
- package/drag-drop/typings/drop-list-container.d.ts +21 -3
- package/drag-drop/typings/{drop-list.d.ts → drop-list-ref.d.ts} +133 -77
- package/drag-drop/typings/index.d.ts +1 -0
- package/drag-drop/typings/index.metadata.json +1 -1
- package/drag-drop/typings/public-api.d.ts +13 -5
- package/esm2015/a11y.js +353 -189
- package/esm2015/a11y.js.map +1 -1
- package/esm2015/accordion.js +16 -11
- package/esm2015/accordion.js.map +1 -1
- package/esm2015/bidi.js +18 -9
- package/esm2015/bidi.js.map +1 -1
- package/esm2015/cdk.js +7 -6
- package/esm2015/cdk.js.map +1 -1
- package/esm2015/coercion.js +7 -7
- package/esm2015/coercion.js.map +1 -1
- package/esm2015/collections.js +22 -7
- package/esm2015/collections.js.map +1 -1
- package/esm2015/drag-drop.js +1768 -751
- package/esm2015/drag-drop.js.map +1 -1
- package/esm2015/keycodes.js +31 -4
- package/esm2015/keycodes.js.map +1 -1
- package/esm2015/layout.js +29 -19
- package/esm2015/layout.js.map +1 -1
- package/esm2015/observers.js +13 -8
- package/esm2015/observers.js.map +1 -1
- package/esm2015/overlay.js +384 -219
- package/esm2015/overlay.js.map +1 -1
- package/esm2015/platform.js +53 -31
- package/esm2015/platform.js.map +1 -1
- package/esm2015/portal.js +13 -9
- package/esm2015/portal.js.map +1 -1
- package/esm2015/scrolling.js +106 -49
- package/esm2015/scrolling.js.map +1 -1
- package/esm2015/stepper.js +93 -24
- package/esm2015/stepper.js.map +1 -1
- package/esm2015/table.js +89 -45
- package/esm2015/table.js.map +1 -1
- package/esm2015/text-field.js +51 -34
- package/esm2015/text-field.js.map +1 -1
- package/esm2015/tree.js +55 -36
- package/esm2015/tree.js.map +1 -1
- package/esm5/a11y.es5.js +507 -214
- package/esm5/a11y.es5.js.map +1 -1
- package/esm5/accordion.es5.js +18 -11
- package/esm5/accordion.es5.js.map +1 -1
- package/esm5/bidi.es5.js +18 -9
- package/esm5/bidi.es5.js.map +1 -1
- package/esm5/cdk.es5.js +7 -6
- package/esm5/cdk.es5.js.map +1 -1
- package/esm5/coercion.es5.js +7 -7
- package/esm5/coercion.es5.js.map +1 -1
- package/esm5/collections.es5.js +35 -7
- package/esm5/collections.es5.js.map +1 -1
- package/esm5/drag-drop.es5.js +2125 -729
- package/esm5/drag-drop.es5.js.map +1 -1
- package/esm5/keycodes.es5.js +35 -4
- package/esm5/keycodes.es5.js.map +1 -1
- package/esm5/layout.es5.js +31 -24
- package/esm5/layout.es5.js.map +1 -1
- package/esm5/observers.es5.js +27 -8
- package/esm5/observers.es5.js.map +1 -1
- package/esm5/overlay.es5.js +602 -245
- package/esm5/overlay.es5.js.map +1 -1
- package/esm5/platform.es5.js +52 -30
- package/esm5/platform.es5.js.map +1 -1
- package/esm5/portal.es5.js +16 -9
- package/esm5/portal.es5.js.map +1 -1
- package/esm5/scrolling.es5.js +145 -50
- package/esm5/scrolling.es5.js.map +1 -1
- package/esm5/stepper.es5.js +106 -24
- package/esm5/stepper.es5.js.map +1 -1
- package/esm5/table.es5.js +184 -50
- package/esm5/table.es5.js.map +1 -1
- package/esm5/text-field.es5.js +72 -34
- package/esm5/text-field.es5.js.map +1 -1
- package/esm5/tree.es5.js +74 -37
- package/esm5/tree.es5.js.map +1 -1
- package/keycodes/typings/index.metadata.json +1 -1
- package/keycodes/typings/modifiers.d.ts +14 -0
- package/keycodes/typings/public-api.d.ts +1 -0
- package/overlay/typings/index.metadata.json +1 -1
- package/package.json +4 -4
- package/schematics/ng-generate/drag-drop/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.ts +2 -2
- package/schematics/ng-update/upgrade-data.js +2 -1
- package/schematics/ng-update/upgrade-data.js.map +1 -1
- package/schematics/ng-update/upgrade-rules/index.js +3 -2
- package/schematics/ng-update/upgrade-rules/index.js.map +1 -1
- package/schematics/utils/ast/ng-module-imports.d.ts +1 -1
- package/schematics/utils/ast/ng-module-imports.js +25 -13
- package/schematics/utils/ast/ng-module-imports.js.map +1 -1
- package/schematics/utils/get-project.js +2 -1
- package/schematics/utils/get-project.js.map +1 -1
- package/schematics/utils/parse5-element.js +3 -2
- package/schematics/utils/parse5-element.js.map +1 -1
- package/schematics/utils/project-targets.js +2 -1
- package/schematics/utils/project-targets.js.map +1 -1
- package/schematics/utils/version-agnostic-typescript.js +3 -2
- package/schematics/utils/version-agnostic-typescript.js.map +1 -1
- package/scrolling/typings/index.metadata.json +1 -1
- package/stepper/typings/index.metadata.json +1 -1
- package/stepper/typings/public-api.d.ts +1 -0
- package/stepper/typings/step-header.d.ts +15 -0
- package/stepper/typings/stepper.d.ts +11 -1
- package/text-field/typings/autosize.d.ts +6 -0
- package/text-field/typings/index.metadata.json +1 -1
- package/tree/typings/nested-node.d.ts +5 -5
- package/typings/a11y/focus-monitor/focus-monitor.d.ts +20 -4
- package/typings/a11y/index.metadata.json +1 -1
- package/typings/a11y/key-manager/list-key-manager.d.ts +8 -0
- package/typings/a11y/live-announcer/live-announcer.d.ts +37 -4
- package/typings/bidi/dir.d.ts +4 -1
- package/typings/bidi/index.metadata.json +1 -1
- package/typings/{esm5/drag-drop → drag-drop/directives}/drag-handle.d.ts +3 -0
- package/typings/drag-drop/{drag-placeholder.d.ts → directives/drag-placeholder.d.ts} +0 -0
- package/typings/drag-drop/{drag-preview.d.ts → directives/drag-preview.d.ts} +0 -0
- package/typings/drag-drop/directives/drag.d.ts +108 -0
- package/typings/drag-drop/directives/drop-list-group.d.ts +22 -0
- package/typings/drag-drop/directives/drop-list.d.ts +135 -0
- package/typings/drag-drop/drag-drop-registry.d.ts +8 -5
- package/typings/drag-drop/drag-events.d.ts +24 -6
- package/typings/drag-drop/{drag.d.ts → drag-ref.d.ts} +153 -77
- package/typings/drag-drop/drop-list-container.d.ts +21 -3
- package/typings/{esm5/drag-drop/drop-list.d.ts → drag-drop/drop-list-ref.d.ts} +133 -77
- package/typings/drag-drop/index.d.ts +1 -0
- package/typings/drag-drop/index.metadata.json +1 -1
- package/typings/drag-drop/public-api.d.ts +13 -5
- package/typings/esm5/a11y/focus-monitor/focus-monitor.d.ts +20 -4
- package/typings/esm5/a11y/index.metadata.json +1 -1
- package/typings/esm5/a11y/key-manager/list-key-manager.d.ts +8 -0
- package/typings/esm5/a11y/live-announcer/live-announcer.d.ts +37 -4
- package/typings/esm5/bidi/dir.d.ts +4 -1
- package/typings/esm5/bidi/index.metadata.json +1 -1
- package/typings/{drag-drop → esm5/drag-drop/directives}/drag-handle.d.ts +3 -0
- package/typings/esm5/drag-drop/{drag-placeholder.d.ts → directives/drag-placeholder.d.ts} +0 -0
- package/typings/esm5/drag-drop/{drag-preview.d.ts → directives/drag-preview.d.ts} +0 -0
- package/typings/esm5/drag-drop/directives/drag.d.ts +108 -0
- package/typings/esm5/drag-drop/directives/drop-list-group.d.ts +22 -0
- package/typings/esm5/drag-drop/directives/drop-list.d.ts +135 -0
- package/typings/esm5/drag-drop/drag-drop-registry.d.ts +8 -5
- package/typings/esm5/drag-drop/drag-events.d.ts +24 -6
- package/{drag-drop/typings/drag.d.ts → typings/esm5/drag-drop/drag-ref.d.ts} +153 -77
- package/typings/esm5/drag-drop/drop-list-container.d.ts +21 -3
- package/typings/{drag-drop/drop-list.d.ts → esm5/drag-drop/drop-list-ref.d.ts} +133 -77
- package/typings/esm5/drag-drop/index.d.ts +1 -0
- package/typings/esm5/drag-drop/index.metadata.json +1 -1
- package/typings/esm5/drag-drop/public-api.d.ts +13 -5
- package/typings/esm5/index.metadata.json +1 -1
- package/typings/esm5/keycodes/index.metadata.json +1 -1
- package/typings/esm5/keycodes/modifiers.d.ts +14 -0
- package/typings/esm5/keycodes/public-api.d.ts +1 -0
- package/typings/esm5/overlay/index.metadata.json +1 -1
- package/typings/esm5/scrolling/index.metadata.json +1 -1
- package/typings/esm5/stepper/index.metadata.json +1 -1
- package/typings/esm5/stepper/public-api.d.ts +1 -0
- package/typings/esm5/stepper/step-header.d.ts +15 -0
- package/typings/esm5/stepper/stepper.d.ts +11 -1
- package/typings/esm5/text-field/autosize.d.ts +6 -0
- package/typings/esm5/text-field/index.metadata.json +1 -1
- package/typings/esm5/tree/nested-node.d.ts +5 -5
- package/typings/index.metadata.json +1 -1
- package/typings/keycodes/index.metadata.json +1 -1
- package/typings/keycodes/modifiers.d.ts +14 -0
- package/typings/keycodes/public-api.d.ts +1 -0
- package/typings/overlay/index.metadata.json +1 -1
- package/typings/schematics/utils/ast/ng-module-imports.d.ts +1 -1
- package/typings/scrolling/index.metadata.json +1 -1
- package/typings/stepper/index.metadata.json +1 -1
- package/typings/stepper/public-api.d.ts +1 -0
- package/typings/stepper/step-header.d.ts +15 -0
- package/typings/stepper/stepper.d.ts +11 -1
- package/typings/text-field/autosize.d.ts +6 -0
- package/typings/text-field/index.metadata.json +1 -1
- package/typings/tree/nested-node.d.ts +5 -5
package/esm5/a11y.es5.js
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
8
|
import { DOCUMENT, CommonModule } from '@angular/common';
|
|
9
|
-
import { Inject, Injectable, Optional, SkipSelf, QueryList, Directive, ElementRef, Input, NgZone, InjectionToken, EventEmitter, Output, NgModule, defineInjectable, inject } from '@angular/core';
|
|
9
|
+
import { Inject, Injectable, Optional, SkipSelf, QueryList, Directive, ElementRef, Input, NgZone, isDevMode, InjectionToken, EventEmitter, Output, NgModule, defineInjectable, inject } from '@angular/core';
|
|
10
10
|
import { Subject, Subscription, of } from 'rxjs';
|
|
11
|
-
import { UP_ARROW, DOWN_ARROW, LEFT_ARROW, RIGHT_ARROW, TAB, A, Z, ZERO, NINE } from '@angular/cdk/keycodes';
|
|
11
|
+
import { UP_ARROW, DOWN_ARROW, LEFT_ARROW, RIGHT_ARROW, TAB, A, Z, ZERO, NINE, hasModifierKey } from '@angular/cdk/keycodes';
|
|
12
12
|
import { debounceTime, filter, map, tap, take } from 'rxjs/operators';
|
|
13
13
|
import { __extends } from 'tslib';
|
|
14
14
|
import { Platform, normalizePassiveListenerOptions, PlatformModule } from '@angular/cdk/platform';
|
|
@@ -17,12 +17,13 @@ import { ContentObserver, ObserversModule } from '@angular/cdk/observers';
|
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* @fileoverview added by tsickle
|
|
20
|
-
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
20
|
+
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
|
-
/**
|
|
23
|
+
/**
|
|
24
24
|
* IDs are deliminated by an empty space, as per the spec.
|
|
25
|
-
|
|
25
|
+
* @type {?}
|
|
26
|
+
*/
|
|
26
27
|
var ID_DELIMINATOR = ' ';
|
|
27
28
|
/**
|
|
28
29
|
* Adds the given ID to the specified ARIA attribute on an element.
|
|
@@ -70,31 +71,37 @@ function getAriaReferenceIds(el, attr) {
|
|
|
70
71
|
|
|
71
72
|
/**
|
|
72
73
|
* @fileoverview added by tsickle
|
|
73
|
-
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
74
|
+
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
74
75
|
*/
|
|
75
|
-
/**
|
|
76
|
+
/**
|
|
76
77
|
* ID used for the body container where all messages are appended.
|
|
77
|
-
|
|
78
|
+
* @type {?}
|
|
79
|
+
*/
|
|
78
80
|
var MESSAGES_CONTAINER_ID = 'cdk-describedby-message-container';
|
|
79
|
-
/**
|
|
81
|
+
/**
|
|
80
82
|
* ID prefix used for each created message element.
|
|
81
|
-
|
|
83
|
+
* @type {?}
|
|
84
|
+
*/
|
|
82
85
|
var CDK_DESCRIBEDBY_ID_PREFIX = 'cdk-describedby-message';
|
|
83
|
-
/**
|
|
86
|
+
/**
|
|
84
87
|
* Attribute given to each host element that is described by a message element.
|
|
85
|
-
|
|
88
|
+
* @type {?}
|
|
89
|
+
*/
|
|
86
90
|
var CDK_DESCRIBEDBY_HOST_ATTRIBUTE = 'cdk-describedby-host';
|
|
87
|
-
/**
|
|
91
|
+
/**
|
|
88
92
|
* Global incremental identifier for each registered message element.
|
|
89
|
-
|
|
93
|
+
* @type {?}
|
|
94
|
+
*/
|
|
90
95
|
var nextId = 0;
|
|
91
|
-
/**
|
|
96
|
+
/**
|
|
92
97
|
* Global map of all registered message elements that have been placed into the document.
|
|
93
|
-
|
|
98
|
+
* @type {?}
|
|
99
|
+
*/
|
|
94
100
|
var messageRegistry = new Map();
|
|
95
|
-
/**
|
|
101
|
+
/**
|
|
96
102
|
* Container for all registered messages.
|
|
97
|
-
|
|
103
|
+
* @type {?}
|
|
104
|
+
*/
|
|
98
105
|
var messagesContainer = null;
|
|
99
106
|
/**
|
|
100
107
|
* Utility that creates visually hidden elements with a message content. Useful for elements that
|
|
@@ -191,12 +198,18 @@ var AriaDescriber = /** @class */ (function () {
|
|
|
191
198
|
/**
|
|
192
199
|
* Creates a new element in the visually hidden message container element with the message
|
|
193
200
|
* as its content and adds it to the message registry.
|
|
201
|
+
*/
|
|
202
|
+
/**
|
|
203
|
+
* Creates a new element in the visually hidden message container element with the message
|
|
204
|
+
* as its content and adds it to the message registry.
|
|
205
|
+
* @private
|
|
194
206
|
* @param {?} message
|
|
195
207
|
* @return {?}
|
|
196
208
|
*/
|
|
197
209
|
AriaDescriber.prototype._createMessageElement = /**
|
|
198
210
|
* Creates a new element in the visually hidden message container element with the message
|
|
199
211
|
* as its content and adds it to the message registry.
|
|
212
|
+
* @private
|
|
200
213
|
* @param {?} message
|
|
201
214
|
* @return {?}
|
|
202
215
|
*/
|
|
@@ -204,18 +217,21 @@ var AriaDescriber = /** @class */ (function () {
|
|
|
204
217
|
/** @type {?} */
|
|
205
218
|
var messageElement = this._document.createElement('div');
|
|
206
219
|
messageElement.setAttribute('id', CDK_DESCRIBEDBY_ID_PREFIX + "-" + nextId++);
|
|
207
|
-
messageElement.appendChild(/** @type {?} */ (
|
|
208
|
-
this._createMessagesContainer();
|
|
209
|
-
((messagesContainer)).appendChild(messageElement);
|
|
220
|
+
messageElement.appendChild((/** @type {?} */ (this._document.createTextNode(message))));
|
|
221
|
+
this._createMessagesContainer();
|
|
222
|
+
(/** @type {?} */ (messagesContainer)).appendChild(messageElement);
|
|
210
223
|
messageRegistry.set(message, { messageElement: messageElement, referenceCount: 0 });
|
|
211
224
|
};
|
|
225
|
+
/** Deletes the message element from the global messages container. */
|
|
212
226
|
/**
|
|
213
227
|
* Deletes the message element from the global messages container.
|
|
228
|
+
* @private
|
|
214
229
|
* @param {?} message
|
|
215
230
|
* @return {?}
|
|
216
231
|
*/
|
|
217
232
|
AriaDescriber.prototype._deleteMessageElement = /**
|
|
218
233
|
* Deletes the message element from the global messages container.
|
|
234
|
+
* @private
|
|
219
235
|
* @param {?} message
|
|
220
236
|
* @return {?}
|
|
221
237
|
*/
|
|
@@ -229,12 +245,15 @@ var AriaDescriber = /** @class */ (function () {
|
|
|
229
245
|
}
|
|
230
246
|
messageRegistry.delete(message);
|
|
231
247
|
};
|
|
248
|
+
/** Creates the global container for all aria-describedby messages. */
|
|
232
249
|
/**
|
|
233
250
|
* Creates the global container for all aria-describedby messages.
|
|
251
|
+
* @private
|
|
234
252
|
* @return {?}
|
|
235
253
|
*/
|
|
236
254
|
AriaDescriber.prototype._createMessagesContainer = /**
|
|
237
255
|
* Creates the global container for all aria-describedby messages.
|
|
256
|
+
* @private
|
|
238
257
|
* @return {?}
|
|
239
258
|
*/
|
|
240
259
|
function () {
|
|
@@ -246,7 +265,7 @@ var AriaDescriber = /** @class */ (function () {
|
|
|
246
265
|
// old container so we don't get duplicates. Doing this, instead of emptying the previous
|
|
247
266
|
// container, should be slightly faster.
|
|
248
267
|
if (preExistingContainer) {
|
|
249
|
-
/** @type {?} */ (
|
|
268
|
+
(/** @type {?} */ (preExistingContainer.parentNode)).removeChild(preExistingContainer);
|
|
250
269
|
}
|
|
251
270
|
messagesContainer = this._document.createElement('div');
|
|
252
271
|
messagesContainer.id = MESSAGES_CONTAINER_ID;
|
|
@@ -255,12 +274,15 @@ var AriaDescriber = /** @class */ (function () {
|
|
|
255
274
|
this._document.body.appendChild(messagesContainer);
|
|
256
275
|
}
|
|
257
276
|
};
|
|
277
|
+
/** Deletes the global messages container. */
|
|
258
278
|
/**
|
|
259
279
|
* Deletes the global messages container.
|
|
280
|
+
* @private
|
|
260
281
|
* @return {?}
|
|
261
282
|
*/
|
|
262
283
|
AriaDescriber.prototype._deleteMessagesContainer = /**
|
|
263
284
|
* Deletes the global messages container.
|
|
285
|
+
* @private
|
|
264
286
|
* @return {?}
|
|
265
287
|
*/
|
|
266
288
|
function () {
|
|
@@ -269,17 +291,21 @@ var AriaDescriber = /** @class */ (function () {
|
|
|
269
291
|
messagesContainer = null;
|
|
270
292
|
}
|
|
271
293
|
};
|
|
294
|
+
/** Removes all cdk-describedby messages that are hosted through the element. */
|
|
272
295
|
/**
|
|
273
296
|
* Removes all cdk-describedby messages that are hosted through the element.
|
|
297
|
+
* @private
|
|
274
298
|
* @param {?} element
|
|
275
299
|
* @return {?}
|
|
276
300
|
*/
|
|
277
301
|
AriaDescriber.prototype._removeCdkDescribedByReferenceIds = /**
|
|
278
302
|
* Removes all cdk-describedby messages that are hosted through the element.
|
|
303
|
+
* @private
|
|
279
304
|
* @param {?} element
|
|
280
305
|
* @return {?}
|
|
281
306
|
*/
|
|
282
307
|
function (element) {
|
|
308
|
+
// Remove all aria-describedby reference IDs that are prefixed by CDK_DESCRIBEDBY_ID_PREFIX
|
|
283
309
|
/** @type {?} */
|
|
284
310
|
var originalReferenceIds = getAriaReferenceIds(element, 'aria-describedby')
|
|
285
311
|
.filter(function (id) { return id.indexOf(CDK_DESCRIBEDBY_ID_PREFIX) != 0; });
|
|
@@ -288,6 +314,11 @@ var AriaDescriber = /** @class */ (function () {
|
|
|
288
314
|
/**
|
|
289
315
|
* Adds a message reference to the element using aria-describedby and increments the registered
|
|
290
316
|
* message's reference count.
|
|
317
|
+
*/
|
|
318
|
+
/**
|
|
319
|
+
* Adds a message reference to the element using aria-describedby and increments the registered
|
|
320
|
+
* message's reference count.
|
|
321
|
+
* @private
|
|
291
322
|
* @param {?} element
|
|
292
323
|
* @param {?} message
|
|
293
324
|
* @return {?}
|
|
@@ -295,13 +326,14 @@ var AriaDescriber = /** @class */ (function () {
|
|
|
295
326
|
AriaDescriber.prototype._addMessageReference = /**
|
|
296
327
|
* Adds a message reference to the element using aria-describedby and increments the registered
|
|
297
328
|
* message's reference count.
|
|
329
|
+
* @private
|
|
298
330
|
* @param {?} element
|
|
299
331
|
* @param {?} message
|
|
300
332
|
* @return {?}
|
|
301
333
|
*/
|
|
302
334
|
function (element, message) {
|
|
303
335
|
/** @type {?} */
|
|
304
|
-
var registeredMessage = /** @type {?} */ (
|
|
336
|
+
var registeredMessage = (/** @type {?} */ (messageRegistry.get(message)));
|
|
305
337
|
// Add the aria-describedby reference and set the
|
|
306
338
|
// describedby_host attribute to mark the element.
|
|
307
339
|
addAriaReferencedId(element, 'aria-describedby', registeredMessage.messageElement.id);
|
|
@@ -311,6 +343,11 @@ var AriaDescriber = /** @class */ (function () {
|
|
|
311
343
|
/**
|
|
312
344
|
* Removes a message reference from the element using aria-describedby
|
|
313
345
|
* and decrements the registered message's reference count.
|
|
346
|
+
*/
|
|
347
|
+
/**
|
|
348
|
+
* Removes a message reference from the element using aria-describedby
|
|
349
|
+
* and decrements the registered message's reference count.
|
|
350
|
+
* @private
|
|
314
351
|
* @param {?} element
|
|
315
352
|
* @param {?} message
|
|
316
353
|
* @return {?}
|
|
@@ -318,25 +355,29 @@ var AriaDescriber = /** @class */ (function () {
|
|
|
318
355
|
AriaDescriber.prototype._removeMessageReference = /**
|
|
319
356
|
* Removes a message reference from the element using aria-describedby
|
|
320
357
|
* and decrements the registered message's reference count.
|
|
358
|
+
* @private
|
|
321
359
|
* @param {?} element
|
|
322
360
|
* @param {?} message
|
|
323
361
|
* @return {?}
|
|
324
362
|
*/
|
|
325
363
|
function (element, message) {
|
|
326
364
|
/** @type {?} */
|
|
327
|
-
var registeredMessage = /** @type {?} */ (
|
|
365
|
+
var registeredMessage = (/** @type {?} */ (messageRegistry.get(message)));
|
|
328
366
|
registeredMessage.referenceCount--;
|
|
329
367
|
removeAriaReferencedId(element, 'aria-describedby', registeredMessage.messageElement.id);
|
|
330
368
|
element.removeAttribute(CDK_DESCRIBEDBY_HOST_ATTRIBUTE);
|
|
331
369
|
};
|
|
370
|
+
/** Returns true if the element has been described by the provided message ID. */
|
|
332
371
|
/**
|
|
333
372
|
* Returns true if the element has been described by the provided message ID.
|
|
373
|
+
* @private
|
|
334
374
|
* @param {?} element
|
|
335
375
|
* @param {?} message
|
|
336
376
|
* @return {?}
|
|
337
377
|
*/
|
|
338
378
|
AriaDescriber.prototype._isElementDescribedByMessage = /**
|
|
339
379
|
* Returns true if the element has been described by the provided message ID.
|
|
380
|
+
* @private
|
|
340
381
|
* @param {?} element
|
|
341
382
|
* @param {?} message
|
|
342
383
|
* @return {?}
|
|
@@ -350,14 +391,17 @@ var AriaDescriber = /** @class */ (function () {
|
|
|
350
391
|
var messageId = registeredMessage && registeredMessage.messageElement.id;
|
|
351
392
|
return !!messageId && referenceIds.indexOf(messageId) != -1;
|
|
352
393
|
};
|
|
394
|
+
/** Determines whether a message can be described on a particular element. */
|
|
353
395
|
/**
|
|
354
396
|
* Determines whether a message can be described on a particular element.
|
|
397
|
+
* @private
|
|
355
398
|
* @param {?} element
|
|
356
399
|
* @param {?} message
|
|
357
400
|
* @return {?}
|
|
358
401
|
*/
|
|
359
402
|
AriaDescriber.prototype._canBeDescribed = /**
|
|
360
403
|
* Determines whether a message can be described on a particular element.
|
|
404
|
+
* @private
|
|
361
405
|
* @param {?} element
|
|
362
406
|
* @param {?} message
|
|
363
407
|
* @return {?}
|
|
@@ -385,32 +429,30 @@ var AriaDescriber = /** @class */ (function () {
|
|
|
385
429
|
function ARIA_DESCRIBER_PROVIDER_FACTORY(parentDispatcher, _document) {
|
|
386
430
|
return parentDispatcher || new AriaDescriber(_document);
|
|
387
431
|
}
|
|
388
|
-
/**
|
|
432
|
+
/**
|
|
389
433
|
* \@docs-private \@deprecated \@breaking-change 8.0.0
|
|
390
|
-
|
|
434
|
+
* @type {?}
|
|
435
|
+
*/
|
|
391
436
|
var ARIA_DESCRIBER_PROVIDER = {
|
|
392
437
|
// If there is already an AriaDescriber available, use that. Otherwise, provide a new one.
|
|
393
438
|
provide: AriaDescriber,
|
|
394
439
|
deps: [
|
|
395
440
|
[new Optional(), new SkipSelf(), AriaDescriber],
|
|
396
|
-
/** @type {?} */ (DOCUMENT)
|
|
441
|
+
(/** @type {?} */ (DOCUMENT))
|
|
397
442
|
],
|
|
398
443
|
useFactory: ARIA_DESCRIBER_PROVIDER_FACTORY
|
|
399
444
|
};
|
|
400
445
|
|
|
401
446
|
/**
|
|
402
447
|
* @fileoverview added by tsickle
|
|
403
|
-
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
448
|
+
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
404
449
|
*/
|
|
405
|
-
// unsupported: template constraints.
|
|
406
450
|
/**
|
|
407
451
|
* This class manages keyboard events for selectable lists. If you pass it a query list
|
|
408
452
|
* of items, it will set the active item correctly when arrow events occur.
|
|
409
453
|
* @template T
|
|
410
454
|
*/
|
|
411
|
-
var
|
|
412
|
-
// unsupported: template constraints.
|
|
413
|
-
/**
|
|
455
|
+
var /**
|
|
414
456
|
* This class manages keyboard events for selectable lists. If you pass it a query list
|
|
415
457
|
* of items, it will set the active item correctly when arrow events occur.
|
|
416
458
|
* @template T
|
|
@@ -420,15 +462,18 @@ ListKeyManager = /** @class */ (function () {
|
|
|
420
462
|
var _this = this;
|
|
421
463
|
this._items = _items;
|
|
422
464
|
this._activeItemIndex = -1;
|
|
465
|
+
this._activeItem = null;
|
|
423
466
|
this._wrap = false;
|
|
424
467
|
this._letterKeyStream = new Subject();
|
|
425
468
|
this._typeaheadSubscription = Subscription.EMPTY;
|
|
426
469
|
this._vertical = true;
|
|
470
|
+
this._allowedModifierKeys = [];
|
|
427
471
|
/**
|
|
428
472
|
* Predicate function that can be used to check whether an item should be skipped
|
|
429
473
|
* by the key manager. By default, disabled items are skipped.
|
|
430
474
|
*/
|
|
431
475
|
this._skipPredicateFn = function (item) { return item.disabled; };
|
|
476
|
+
// Buffer for the letters that the user has pressed when the typeahead option is turned on.
|
|
432
477
|
this._pressedLetters = [];
|
|
433
478
|
/**
|
|
434
479
|
* Stream that emits any time the TAB key is pressed, so components can react
|
|
@@ -464,18 +509,22 @@ ListKeyManager = /** @class */ (function () {
|
|
|
464
509
|
/**
|
|
465
510
|
* Sets the predicate function that determines which items should be skipped by the
|
|
466
511
|
* list key manager.
|
|
512
|
+
* @template THIS
|
|
513
|
+
* @this {THIS}
|
|
467
514
|
* @param {?} predicate Function that determines whether the given item should be skipped.
|
|
468
|
-
* @return {
|
|
515
|
+
* @return {THIS}
|
|
469
516
|
*/
|
|
470
517
|
ListKeyManager.prototype.skipPredicate = /**
|
|
471
518
|
* Sets the predicate function that determines which items should be skipped by the
|
|
472
519
|
* list key manager.
|
|
520
|
+
* @template THIS
|
|
521
|
+
* @this {THIS}
|
|
473
522
|
* @param {?} predicate Function that determines whether the given item should be skipped.
|
|
474
|
-
* @return {
|
|
523
|
+
* @return {THIS}
|
|
475
524
|
*/
|
|
476
525
|
function (predicate) {
|
|
477
|
-
this._skipPredicateFn = predicate;
|
|
478
|
-
return this;
|
|
526
|
+
(/** @type {?} */ (this))._skipPredicateFn = predicate;
|
|
527
|
+
return (/** @type {?} */ (this));
|
|
479
528
|
};
|
|
480
529
|
/**
|
|
481
530
|
* Configures wrapping mode, which determines whether the active item will wrap to
|
|
@@ -485,19 +534,23 @@ ListKeyManager = /** @class */ (function () {
|
|
|
485
534
|
/**
|
|
486
535
|
* Configures wrapping mode, which determines whether the active item will wrap to
|
|
487
536
|
* the other end of list when there are no more items in the given direction.
|
|
537
|
+
* @template THIS
|
|
538
|
+
* @this {THIS}
|
|
488
539
|
* @param {?=} shouldWrap Whether the list should wrap when reaching the end.
|
|
489
|
-
* @return {
|
|
540
|
+
* @return {THIS}
|
|
490
541
|
*/
|
|
491
542
|
ListKeyManager.prototype.withWrap = /**
|
|
492
543
|
* Configures wrapping mode, which determines whether the active item will wrap to
|
|
493
544
|
* the other end of list when there are no more items in the given direction.
|
|
545
|
+
* @template THIS
|
|
546
|
+
* @this {THIS}
|
|
494
547
|
* @param {?=} shouldWrap Whether the list should wrap when reaching the end.
|
|
495
|
-
* @return {
|
|
548
|
+
* @return {THIS}
|
|
496
549
|
*/
|
|
497
550
|
function (shouldWrap) {
|
|
498
551
|
if (shouldWrap === void 0) { shouldWrap = true; }
|
|
499
|
-
this._wrap = shouldWrap;
|
|
500
|
-
return this;
|
|
552
|
+
(/** @type {?} */ (this))._wrap = shouldWrap;
|
|
553
|
+
return (/** @type {?} */ (this));
|
|
501
554
|
};
|
|
502
555
|
/**
|
|
503
556
|
* Configures whether the key manager should be able to move the selection vertically.
|
|
@@ -505,18 +558,22 @@ ListKeyManager = /** @class */ (function () {
|
|
|
505
558
|
*/
|
|
506
559
|
/**
|
|
507
560
|
* Configures whether the key manager should be able to move the selection vertically.
|
|
561
|
+
* @template THIS
|
|
562
|
+
* @this {THIS}
|
|
508
563
|
* @param {?=} enabled Whether vertical selection should be enabled.
|
|
509
|
-
* @return {
|
|
564
|
+
* @return {THIS}
|
|
510
565
|
*/
|
|
511
566
|
ListKeyManager.prototype.withVerticalOrientation = /**
|
|
512
567
|
* Configures whether the key manager should be able to move the selection vertically.
|
|
568
|
+
* @template THIS
|
|
569
|
+
* @this {THIS}
|
|
513
570
|
* @param {?=} enabled Whether vertical selection should be enabled.
|
|
514
|
-
* @return {
|
|
571
|
+
* @return {THIS}
|
|
515
572
|
*/
|
|
516
573
|
function (enabled) {
|
|
517
574
|
if (enabled === void 0) { enabled = true; }
|
|
518
|
-
this._vertical = enabled;
|
|
519
|
-
return this;
|
|
575
|
+
(/** @type {?} */ (this))._vertical = enabled;
|
|
576
|
+
return (/** @type {?} */ (this));
|
|
520
577
|
};
|
|
521
578
|
/**
|
|
522
579
|
* Configures the key manager to move the selection horizontally.
|
|
@@ -526,18 +583,46 @@ ListKeyManager = /** @class */ (function () {
|
|
|
526
583
|
/**
|
|
527
584
|
* Configures the key manager to move the selection horizontally.
|
|
528
585
|
* Passing in `null` will disable horizontal movement.
|
|
586
|
+
* @template THIS
|
|
587
|
+
* @this {THIS}
|
|
529
588
|
* @param {?} direction Direction in which the selection can be moved.
|
|
530
|
-
* @return {
|
|
589
|
+
* @return {THIS}
|
|
531
590
|
*/
|
|
532
591
|
ListKeyManager.prototype.withHorizontalOrientation = /**
|
|
533
592
|
* Configures the key manager to move the selection horizontally.
|
|
534
593
|
* Passing in `null` will disable horizontal movement.
|
|
594
|
+
* @template THIS
|
|
595
|
+
* @this {THIS}
|
|
535
596
|
* @param {?} direction Direction in which the selection can be moved.
|
|
536
|
-
* @return {
|
|
597
|
+
* @return {THIS}
|
|
537
598
|
*/
|
|
538
599
|
function (direction) {
|
|
539
|
-
this._horizontal = direction;
|
|
540
|
-
return this;
|
|
600
|
+
(/** @type {?} */ (this))._horizontal = direction;
|
|
601
|
+
return (/** @type {?} */ (this));
|
|
602
|
+
};
|
|
603
|
+
/**
|
|
604
|
+
* Modifier keys which are allowed to be held down and whose default actions will be prevented
|
|
605
|
+
* as the user is pressing the arrow keys. Defaults to not allowing any modifier keys.
|
|
606
|
+
*/
|
|
607
|
+
/**
|
|
608
|
+
* Modifier keys which are allowed to be held down and whose default actions will be prevented
|
|
609
|
+
* as the user is pressing the arrow keys. Defaults to not allowing any modifier keys.
|
|
610
|
+
* @template THIS
|
|
611
|
+
* @this {THIS}
|
|
612
|
+
* @param {?} keys
|
|
613
|
+
* @return {THIS}
|
|
614
|
+
*/
|
|
615
|
+
ListKeyManager.prototype.withAllowedModifierKeys = /**
|
|
616
|
+
* Modifier keys which are allowed to be held down and whose default actions will be prevented
|
|
617
|
+
* as the user is pressing the arrow keys. Defaults to not allowing any modifier keys.
|
|
618
|
+
* @template THIS
|
|
619
|
+
* @this {THIS}
|
|
620
|
+
* @param {?} keys
|
|
621
|
+
* @return {THIS}
|
|
622
|
+
*/
|
|
623
|
+
function (keys) {
|
|
624
|
+
(/** @type {?} */ (this))._allowedModifierKeys = keys;
|
|
625
|
+
return (/** @type {?} */ (this));
|
|
541
626
|
};
|
|
542
627
|
/**
|
|
543
628
|
* Turns on typeahead mode which allows users to set the active item by typing.
|
|
@@ -545,42 +630,47 @@ ListKeyManager = /** @class */ (function () {
|
|
|
545
630
|
*/
|
|
546
631
|
/**
|
|
547
632
|
* Turns on typeahead mode which allows users to set the active item by typing.
|
|
633
|
+
* @template THIS
|
|
634
|
+
* @this {THIS}
|
|
548
635
|
* @param {?=} debounceInterval Time to wait after the last keystroke before setting the active item.
|
|
549
|
-
* @return {
|
|
636
|
+
* @return {THIS}
|
|
550
637
|
*/
|
|
551
638
|
ListKeyManager.prototype.withTypeAhead = /**
|
|
552
639
|
* Turns on typeahead mode which allows users to set the active item by typing.
|
|
640
|
+
* @template THIS
|
|
641
|
+
* @this {THIS}
|
|
553
642
|
* @param {?=} debounceInterval Time to wait after the last keystroke before setting the active item.
|
|
554
|
-
* @return {
|
|
643
|
+
* @return {THIS}
|
|
555
644
|
*/
|
|
556
645
|
function (debounceInterval) {
|
|
557
646
|
var _this = this;
|
|
558
647
|
if (debounceInterval === void 0) { debounceInterval = 200; }
|
|
559
|
-
if (this._items.length && this._items.some(function (item) { return typeof item.getLabel !== 'function'; })) {
|
|
648
|
+
if ((/** @type {?} */ (this))._items.length && (/** @type {?} */ (this))._items.some(function (item) { return typeof item.getLabel !== 'function'; })) {
|
|
560
649
|
throw Error('ListKeyManager items in typeahead mode must implement the `getLabel` method.');
|
|
561
650
|
}
|
|
562
|
-
this._typeaheadSubscription.unsubscribe();
|
|
651
|
+
(/** @type {?} */ (this))._typeaheadSubscription.unsubscribe();
|
|
563
652
|
// Debounce the presses of non-navigational keys, collect the ones that correspond to letters
|
|
564
653
|
// and convert those letters back into a string. Afterwards find the first item that starts
|
|
565
654
|
// with that string and select it.
|
|
566
|
-
this._typeaheadSubscription = this._letterKeyStream.pipe(tap(function (keyCode) { return _this._pressedLetters.push(keyCode); }), debounceTime(debounceInterval), filter(function () { return _this._pressedLetters.length > 0; }), map(function () { return _this._pressedLetters.join(''); })).subscribe(function (inputString) {
|
|
655
|
+
(/** @type {?} */ (this))._typeaheadSubscription = (/** @type {?} */ (this))._letterKeyStream.pipe(tap(function (keyCode) { return (/** @type {?} */ (_this))._pressedLetters.push(keyCode); }), debounceTime(debounceInterval), filter(function () { return (/** @type {?} */ (_this))._pressedLetters.length > 0; }), map(function () { return (/** @type {?} */ (_this))._pressedLetters.join(''); })).subscribe(function (inputString) {
|
|
567
656
|
/** @type {?} */
|
|
568
|
-
var items = _this._getItemsArray();
|
|
657
|
+
var items = (/** @type {?} */ (_this))._getItemsArray();
|
|
569
658
|
// Start at 1 because we want to start searching at the item immediately
|
|
570
659
|
// following the current active item.
|
|
571
660
|
for (var i = 1; i < items.length + 1; i++) {
|
|
572
661
|
/** @type {?} */
|
|
573
|
-
var index = (_this._activeItemIndex + i) % items.length;
|
|
662
|
+
var index = ((/** @type {?} */ (_this))._activeItemIndex + i) % items.length;
|
|
574
663
|
/** @type {?} */
|
|
575
664
|
var item = items[index];
|
|
576
|
-
if (!
|
|
577
|
-
|
|
665
|
+
if (!(/** @type {?} */ (_this))._skipPredicateFn(item) &&
|
|
666
|
+
(/** @type {?} */ (item.getLabel))().toUpperCase().trim().indexOf(inputString) === 0) {
|
|
667
|
+
(/** @type {?} */ (_this)).setActiveItem(index);
|
|
578
668
|
break;
|
|
579
669
|
}
|
|
580
670
|
}
|
|
581
|
-
_this._pressedLetters = [];
|
|
671
|
+
(/** @type {?} */ (_this))._pressedLetters = [];
|
|
582
672
|
});
|
|
583
|
-
return this;
|
|
673
|
+
return (/** @type {?} */ (this));
|
|
584
674
|
};
|
|
585
675
|
/**
|
|
586
676
|
* @param {?} item
|
|
@@ -613,14 +703,21 @@ ListKeyManager = /** @class */ (function () {
|
|
|
613
703
|
* @return {?}
|
|
614
704
|
*/
|
|
615
705
|
function (event) {
|
|
706
|
+
var _this = this;
|
|
616
707
|
/** @type {?} */
|
|
617
708
|
var keyCode = event.keyCode;
|
|
709
|
+
/** @type {?} */
|
|
710
|
+
var modifiers = ['altKey', 'ctrlKey', 'metaKey', 'shiftKey'];
|
|
711
|
+
/** @type {?} */
|
|
712
|
+
var isModifierAllowed = modifiers.every(function (modifier) {
|
|
713
|
+
return !event[modifier] || _this._allowedModifierKeys.indexOf(modifier) > -1;
|
|
714
|
+
});
|
|
618
715
|
switch (keyCode) {
|
|
619
716
|
case TAB:
|
|
620
717
|
this.tabOut.next();
|
|
621
718
|
return;
|
|
622
719
|
case DOWN_ARROW:
|
|
623
|
-
if (this._vertical) {
|
|
720
|
+
if (this._vertical && isModifierAllowed) {
|
|
624
721
|
this.setNextItemActive();
|
|
625
722
|
break;
|
|
626
723
|
}
|
|
@@ -628,7 +725,7 @@ ListKeyManager = /** @class */ (function () {
|
|
|
628
725
|
return;
|
|
629
726
|
}
|
|
630
727
|
case UP_ARROW:
|
|
631
|
-
if (this._vertical) {
|
|
728
|
+
if (this._vertical && isModifierAllowed) {
|
|
632
729
|
this.setPreviousItemActive();
|
|
633
730
|
break;
|
|
634
731
|
}
|
|
@@ -636,37 +733,31 @@ ListKeyManager = /** @class */ (function () {
|
|
|
636
733
|
return;
|
|
637
734
|
}
|
|
638
735
|
case RIGHT_ARROW:
|
|
639
|
-
if (this._horizontal
|
|
640
|
-
this.setNextItemActive();
|
|
641
|
-
break;
|
|
642
|
-
}
|
|
643
|
-
else if (this._horizontal === 'rtl') {
|
|
644
|
-
this.setPreviousItemActive();
|
|
736
|
+
if (this._horizontal && isModifierAllowed) {
|
|
737
|
+
this._horizontal === 'rtl' ? this.setPreviousItemActive() : this.setNextItemActive();
|
|
645
738
|
break;
|
|
646
739
|
}
|
|
647
740
|
else {
|
|
648
741
|
return;
|
|
649
742
|
}
|
|
650
743
|
case LEFT_ARROW:
|
|
651
|
-
if (this._horizontal
|
|
652
|
-
this.setPreviousItemActive();
|
|
653
|
-
break;
|
|
654
|
-
}
|
|
655
|
-
else if (this._horizontal === 'rtl') {
|
|
656
|
-
this.setNextItemActive();
|
|
744
|
+
if (this._horizontal && isModifierAllowed) {
|
|
745
|
+
this._horizontal === 'rtl' ? this.setNextItemActive() : this.setPreviousItemActive();
|
|
657
746
|
break;
|
|
658
747
|
}
|
|
659
748
|
else {
|
|
660
749
|
return;
|
|
661
750
|
}
|
|
662
751
|
default:
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
752
|
+
if (isModifierAllowed || hasModifierKey(event, 'shiftKey')) {
|
|
753
|
+
// Attempt to use the `event.key` which also maps it to the user's keyboard language,
|
|
754
|
+
// otherwise fall back to resolving alphanumeric characters via the keyCode.
|
|
755
|
+
if (event.key && event.key.length === 1) {
|
|
756
|
+
this._letterKeyStream.next(event.key.toLocaleUpperCase());
|
|
757
|
+
}
|
|
758
|
+
else if ((keyCode >= A && keyCode <= Z) || (keyCode >= ZERO && keyCode <= NINE)) {
|
|
759
|
+
this._letterKeyStream.next(String.fromCharCode(keyCode));
|
|
760
|
+
}
|
|
670
761
|
}
|
|
671
762
|
// Note that we return here, in order to avoid preventing
|
|
672
763
|
// the default action of non-navigational keys.
|
|
@@ -761,8 +852,11 @@ ListKeyManager = /** @class */ (function () {
|
|
|
761
852
|
var itemArray = this._getItemsArray();
|
|
762
853
|
/** @type {?} */
|
|
763
854
|
var index = typeof item === 'number' ? item : itemArray.indexOf(item);
|
|
855
|
+
/** @type {?} */
|
|
856
|
+
var activeItem = itemArray[index];
|
|
857
|
+
// Explicitly check for `null` and `undefined` because other falsy values are valid.
|
|
858
|
+
this._activeItem = activeItem == null ? null : activeItem;
|
|
764
859
|
this._activeItemIndex = index;
|
|
765
|
-
this._activeItem = itemArray[index];
|
|
766
860
|
};
|
|
767
861
|
/**
|
|
768
862
|
* Allows setting of the activeItemIndex without any other effects.
|
|
@@ -791,6 +885,12 @@ ListKeyManager = /** @class */ (function () {
|
|
|
791
885
|
* This method sets the active item, given a list of items and the delta between the
|
|
792
886
|
* currently active item and the new active item. It will calculate differently
|
|
793
887
|
* depending on whether wrap mode is turned on.
|
|
888
|
+
*/
|
|
889
|
+
/**
|
|
890
|
+
* This method sets the active item, given a list of items and the delta between the
|
|
891
|
+
* currently active item and the new active item. It will calculate differently
|
|
892
|
+
* depending on whether wrap mode is turned on.
|
|
893
|
+
* @private
|
|
794
894
|
* @param {?} delta
|
|
795
895
|
* @return {?}
|
|
796
896
|
*/
|
|
@@ -798,6 +898,7 @@ ListKeyManager = /** @class */ (function () {
|
|
|
798
898
|
* This method sets the active item, given a list of items and the delta between the
|
|
799
899
|
* currently active item and the new active item. It will calculate differently
|
|
800
900
|
* depending on whether wrap mode is turned on.
|
|
901
|
+
* @private
|
|
801
902
|
* @param {?} delta
|
|
802
903
|
* @return {?}
|
|
803
904
|
*/
|
|
@@ -808,6 +909,12 @@ ListKeyManager = /** @class */ (function () {
|
|
|
808
909
|
* Sets the active item properly given "wrap" mode. In other words, it will continue to move
|
|
809
910
|
* down the list until it finds an item that is not disabled, and it will wrap if it
|
|
810
911
|
* encounters either end of the list.
|
|
912
|
+
*/
|
|
913
|
+
/**
|
|
914
|
+
* Sets the active item properly given "wrap" mode. In other words, it will continue to move
|
|
915
|
+
* down the list until it finds an item that is not disabled, and it will wrap if it
|
|
916
|
+
* encounters either end of the list.
|
|
917
|
+
* @private
|
|
811
918
|
* @param {?} delta
|
|
812
919
|
* @return {?}
|
|
813
920
|
*/
|
|
@@ -815,6 +922,7 @@ ListKeyManager = /** @class */ (function () {
|
|
|
815
922
|
* Sets the active item properly given "wrap" mode. In other words, it will continue to move
|
|
816
923
|
* down the list until it finds an item that is not disabled, and it will wrap if it
|
|
817
924
|
* encounters either end of the list.
|
|
925
|
+
* @private
|
|
818
926
|
* @param {?} delta
|
|
819
927
|
* @return {?}
|
|
820
928
|
*/
|
|
@@ -836,6 +944,12 @@ ListKeyManager = /** @class */ (function () {
|
|
|
836
944
|
* Sets the active item properly given the default mode. In other words, it will
|
|
837
945
|
* continue to move down the list until it finds an item that is not disabled. If
|
|
838
946
|
* it encounters either end of the list, it will stop and not wrap.
|
|
947
|
+
*/
|
|
948
|
+
/**
|
|
949
|
+
* Sets the active item properly given the default mode. In other words, it will
|
|
950
|
+
* continue to move down the list until it finds an item that is not disabled. If
|
|
951
|
+
* it encounters either end of the list, it will stop and not wrap.
|
|
952
|
+
* @private
|
|
839
953
|
* @param {?} delta
|
|
840
954
|
* @return {?}
|
|
841
955
|
*/
|
|
@@ -843,6 +957,7 @@ ListKeyManager = /** @class */ (function () {
|
|
|
843
957
|
* Sets the active item properly given the default mode. In other words, it will
|
|
844
958
|
* continue to move down the list until it finds an item that is not disabled. If
|
|
845
959
|
* it encounters either end of the list, it will stop and not wrap.
|
|
960
|
+
* @private
|
|
846
961
|
* @param {?} delta
|
|
847
962
|
* @return {?}
|
|
848
963
|
*/
|
|
@@ -853,6 +968,12 @@ ListKeyManager = /** @class */ (function () {
|
|
|
853
968
|
* Sets the active item to the first enabled item starting at the index specified. If the
|
|
854
969
|
* item is disabled, it will move in the fallbackDelta direction until it either
|
|
855
970
|
* finds an enabled item or encounters the end of the list.
|
|
971
|
+
*/
|
|
972
|
+
/**
|
|
973
|
+
* Sets the active item to the first enabled item starting at the index specified. If the
|
|
974
|
+
* item is disabled, it will move in the fallbackDelta direction until it either
|
|
975
|
+
* finds an enabled item or encounters the end of the list.
|
|
976
|
+
* @private
|
|
856
977
|
* @param {?} index
|
|
857
978
|
* @param {?} fallbackDelta
|
|
858
979
|
* @return {?}
|
|
@@ -861,6 +982,7 @@ ListKeyManager = /** @class */ (function () {
|
|
|
861
982
|
* Sets the active item to the first enabled item starting at the index specified. If the
|
|
862
983
|
* item is disabled, it will move in the fallbackDelta direction until it either
|
|
863
984
|
* finds an enabled item or encounters the end of the list.
|
|
985
|
+
* @private
|
|
864
986
|
* @param {?} index
|
|
865
987
|
* @param {?} fallbackDelta
|
|
866
988
|
* @return {?}
|
|
@@ -879,12 +1001,15 @@ ListKeyManager = /** @class */ (function () {
|
|
|
879
1001
|
}
|
|
880
1002
|
this.setActiveItem(index);
|
|
881
1003
|
};
|
|
1004
|
+
/** Returns the items as an array. */
|
|
882
1005
|
/**
|
|
883
1006
|
* Returns the items as an array.
|
|
1007
|
+
* @private
|
|
884
1008
|
* @return {?}
|
|
885
1009
|
*/
|
|
886
1010
|
ListKeyManager.prototype._getItemsArray = /**
|
|
887
1011
|
* Returns the items as an array.
|
|
1012
|
+
* @private
|
|
888
1013
|
* @return {?}
|
|
889
1014
|
*/
|
|
890
1015
|
function () {
|
|
@@ -895,7 +1020,7 @@ ListKeyManager = /** @class */ (function () {
|
|
|
895
1020
|
|
|
896
1021
|
/**
|
|
897
1022
|
* @fileoverview added by tsickle
|
|
898
|
-
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
1023
|
+
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
899
1024
|
*/
|
|
900
1025
|
/**
|
|
901
1026
|
* @template T
|
|
@@ -930,7 +1055,7 @@ ActiveDescendantKeyManager = /** @class */ (function (_super) {
|
|
|
930
1055
|
|
|
931
1056
|
/**
|
|
932
1057
|
* @fileoverview added by tsickle
|
|
933
|
-
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
1058
|
+
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
934
1059
|
*/
|
|
935
1060
|
/**
|
|
936
1061
|
* @template T
|
|
@@ -951,17 +1076,21 @@ FocusKeyManager = /** @class */ (function (_super) {
|
|
|
951
1076
|
*/
|
|
952
1077
|
/**
|
|
953
1078
|
* Sets the focus origin that will be passed in to the items for any subsequent `focus` calls.
|
|
1079
|
+
* @template THIS
|
|
1080
|
+
* @this {THIS}
|
|
954
1081
|
* @param {?} origin Focus origin to be used when focusing items.
|
|
955
|
-
* @return {
|
|
1082
|
+
* @return {THIS}
|
|
956
1083
|
*/
|
|
957
1084
|
FocusKeyManager.prototype.setFocusOrigin = /**
|
|
958
1085
|
* Sets the focus origin that will be passed in to the items for any subsequent `focus` calls.
|
|
1086
|
+
* @template THIS
|
|
1087
|
+
* @this {THIS}
|
|
959
1088
|
* @param {?} origin Focus origin to be used when focusing items.
|
|
960
|
-
* @return {
|
|
1089
|
+
* @return {THIS}
|
|
961
1090
|
*/
|
|
962
1091
|
function (origin) {
|
|
963
|
-
this._origin = origin;
|
|
964
|
-
return this;
|
|
1092
|
+
(/** @type {?} */ (this))._origin = origin;
|
|
1093
|
+
return (/** @type {?} */ (this));
|
|
965
1094
|
};
|
|
966
1095
|
/**
|
|
967
1096
|
* @param {?} item
|
|
@@ -982,8 +1111,11 @@ FocusKeyManager = /** @class */ (function (_super) {
|
|
|
982
1111
|
|
|
983
1112
|
/**
|
|
984
1113
|
* @fileoverview added by tsickle
|
|
985
|
-
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
1114
|
+
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
986
1115
|
*/
|
|
1116
|
+
// The InteractivityChecker leans heavily on the ally.js accessibility utilities.
|
|
1117
|
+
// Methods like `isTabbable` are only covering specific edge-cases for the browsers which are
|
|
1118
|
+
// supported.
|
|
987
1119
|
/**
|
|
988
1120
|
* Utility for checking the interactivity of an element, such as whether is is focusable or
|
|
989
1121
|
* tabbable.
|
|
@@ -1172,7 +1304,7 @@ var InteractivityChecker = /** @class */ (function () {
|
|
|
1172
1304
|
*/
|
|
1173
1305
|
function getFrameElement(window) {
|
|
1174
1306
|
try {
|
|
1175
|
-
return /** @type {?} */ (window.frameElement);
|
|
1307
|
+
return (/** @type {?} */ (window.frameElement));
|
|
1176
1308
|
}
|
|
1177
1309
|
catch (_a) {
|
|
1178
1310
|
return null;
|
|
@@ -1261,6 +1393,7 @@ function getTabIndexValue(element) {
|
|
|
1261
1393
|
if (!hasValidTabIndex(element)) {
|
|
1262
1394
|
return null;
|
|
1263
1395
|
}
|
|
1396
|
+
// See browser issue in Gecko https://bugzilla.mozilla.org/show_bug.cgi?id=1128054
|
|
1264
1397
|
/** @type {?} */
|
|
1265
1398
|
var tabIndex = parseInt(element.getAttribute('tabindex') || '', 10);
|
|
1266
1399
|
return isNaN(tabIndex) ? -1 : tabIndex;
|
|
@@ -1274,7 +1407,7 @@ function isPotentiallyTabbableIOS(element) {
|
|
|
1274
1407
|
/** @type {?} */
|
|
1275
1408
|
var nodeName = element.nodeName.toLowerCase();
|
|
1276
1409
|
/** @type {?} */
|
|
1277
|
-
var inputType = nodeName === 'input' && (/** @type {?} */ (element)).type;
|
|
1410
|
+
var inputType = nodeName === 'input' && ((/** @type {?} */ (element))).type;
|
|
1278
1411
|
return inputType === 'text'
|
|
1279
1412
|
|| inputType === 'password'
|
|
1280
1413
|
|| nodeName === 'select'
|
|
@@ -1308,7 +1441,7 @@ function getWindow(node) {
|
|
|
1308
1441
|
|
|
1309
1442
|
/**
|
|
1310
1443
|
* @fileoverview added by tsickle
|
|
1311
|
-
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
1444
|
+
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1312
1445
|
*/
|
|
1313
1446
|
/**
|
|
1314
1447
|
* Class that allows for trapping focus within a DOM element.
|
|
@@ -1402,17 +1535,17 @@ FocusTrap = /** @class */ (function () {
|
|
|
1402
1535
|
}
|
|
1403
1536
|
this._ngZone.runOutsideAngular(function () {
|
|
1404
1537
|
if (!_this._startAnchor) {
|
|
1405
|
-
_this._startAnchor = _this._createAnchor();
|
|
1406
|
-
((_this._startAnchor)).addEventListener('focus', function () { return _this.focusLastTabbableElement(); });
|
|
1538
|
+
_this._startAnchor = _this._createAnchor();
|
|
1539
|
+
(/** @type {?} */ (_this._startAnchor)).addEventListener('focus', function () { return _this.focusLastTabbableElement(); });
|
|
1407
1540
|
}
|
|
1408
1541
|
if (!_this._endAnchor) {
|
|
1409
|
-
_this._endAnchor = _this._createAnchor();
|
|
1410
|
-
((_this._endAnchor)).addEventListener('focus', function () { return _this.focusFirstTabbableElement(); });
|
|
1542
|
+
_this._endAnchor = _this._createAnchor();
|
|
1543
|
+
(/** @type {?} */ (_this._endAnchor)).addEventListener('focus', function () { return _this.focusFirstTabbableElement(); });
|
|
1411
1544
|
}
|
|
1412
1545
|
});
|
|
1413
1546
|
if (this._element.parentNode) {
|
|
1414
|
-
this._element.parentNode.insertBefore(/** @type {?} */ (
|
|
1415
|
-
this._element.parentNode.insertBefore(/** @type {?} */ (
|
|
1547
|
+
this._element.parentNode.insertBefore((/** @type {?} */ (this._startAnchor)), this._element);
|
|
1548
|
+
this._element.parentNode.insertBefore((/** @type {?} */ (this._endAnchor)), this._element.nextSibling);
|
|
1416
1549
|
this._hasAttached = true;
|
|
1417
1550
|
}
|
|
1418
1551
|
return this._hasAttached;
|
|
@@ -1491,19 +1624,27 @@ FocusTrap = /** @class */ (function () {
|
|
|
1491
1624
|
};
|
|
1492
1625
|
/**
|
|
1493
1626
|
* Get the specified boundary element of the trapped region.
|
|
1627
|
+
* @param bound The boundary to get (start or end of trapped region).
|
|
1628
|
+
* @returns The boundary element.
|
|
1629
|
+
*/
|
|
1630
|
+
/**
|
|
1631
|
+
* Get the specified boundary element of the trapped region.
|
|
1632
|
+
* @private
|
|
1494
1633
|
* @param {?} bound The boundary to get (start or end of trapped region).
|
|
1495
1634
|
* @return {?} The boundary element.
|
|
1496
1635
|
*/
|
|
1497
1636
|
FocusTrap.prototype._getRegionBoundary = /**
|
|
1498
1637
|
* Get the specified boundary element of the trapped region.
|
|
1638
|
+
* @private
|
|
1499
1639
|
* @param {?} bound The boundary to get (start or end of trapped region).
|
|
1500
1640
|
* @return {?} The boundary element.
|
|
1501
1641
|
*/
|
|
1502
1642
|
function (bound) {
|
|
1643
|
+
// Contains the deprecated version of selector, for temporary backwards comparability.
|
|
1503
1644
|
/** @type {?} */
|
|
1504
|
-
var markers = /** @type {?} */ (this._element.querySelectorAll("[cdk-focus-region-" + bound + "], " +
|
|
1645
|
+
var markers = (/** @type {?} */ (this._element.querySelectorAll("[cdk-focus-region-" + bound + "], " +
|
|
1505
1646
|
("[cdkFocusRegion" + bound + "], ") +
|
|
1506
|
-
("[cdk-focus-" + bound + "]")));
|
|
1647
|
+
("[cdk-focus-" + bound + "]"))));
|
|
1507
1648
|
for (var i = 0; i < markers.length; i++) {
|
|
1508
1649
|
// @breaking-change 8.0.0
|
|
1509
1650
|
if (markers[i].hasAttribute("cdk-focus-" + bound)) {
|
|
@@ -1536,9 +1677,10 @@ FocusTrap = /** @class */ (function () {
|
|
|
1536
1677
|
* @return {?} Whether focus was moved successfuly.
|
|
1537
1678
|
*/
|
|
1538
1679
|
function () {
|
|
1680
|
+
// Contains the deprecated version of selector, for temporary backwards comparability.
|
|
1539
1681
|
/** @type {?} */
|
|
1540
|
-
var redirectToElement = /** @type {?} */ (this._element.querySelector("[cdk-focus-initial], " +
|
|
1541
|
-
"[cdkFocusInitial]"));
|
|
1682
|
+
var redirectToElement = (/** @type {?} */ (this._element.querySelector("[cdk-focus-initial], " +
|
|
1683
|
+
"[cdkFocusInitial]")));
|
|
1542
1684
|
if (redirectToElement) {
|
|
1543
1685
|
// @breaking-change 8.0.0
|
|
1544
1686
|
if (redirectToElement.hasAttribute("cdk-focus-initial")) {
|
|
@@ -1546,6 +1688,11 @@ FocusTrap = /** @class */ (function () {
|
|
|
1546
1688
|
"use 'cdkFocusInitial' instead. The deprecated attribute " +
|
|
1547
1689
|
"will be removed in 8.0.0", redirectToElement);
|
|
1548
1690
|
}
|
|
1691
|
+
// Warn the consumer if the element they've pointed to
|
|
1692
|
+
// isn't focusable, when not in production mode.
|
|
1693
|
+
if (isDevMode() && !this._checker.isFocusable(redirectToElement)) {
|
|
1694
|
+
console.warn("Element matching '[cdkFocusInitial]' is not focusable.", redirectToElement);
|
|
1695
|
+
}
|
|
1549
1696
|
redirectToElement.focus();
|
|
1550
1697
|
return true;
|
|
1551
1698
|
}
|
|
@@ -1605,13 +1752,16 @@ FocusTrap = /** @class */ (function () {
|
|
|
1605
1752
|
function () {
|
|
1606
1753
|
return this._hasAttached;
|
|
1607
1754
|
};
|
|
1755
|
+
/** Get the first tabbable element from a DOM subtree (inclusive). */
|
|
1608
1756
|
/**
|
|
1609
1757
|
* Get the first tabbable element from a DOM subtree (inclusive).
|
|
1758
|
+
* @private
|
|
1610
1759
|
* @param {?} root
|
|
1611
1760
|
* @return {?}
|
|
1612
1761
|
*/
|
|
1613
1762
|
FocusTrap.prototype._getFirstTabbableElement = /**
|
|
1614
1763
|
* Get the first tabbable element from a DOM subtree (inclusive).
|
|
1764
|
+
* @private
|
|
1615
1765
|
* @param {?} root
|
|
1616
1766
|
* @return {?}
|
|
1617
1767
|
*/
|
|
@@ -1619,12 +1769,14 @@ FocusTrap = /** @class */ (function () {
|
|
|
1619
1769
|
if (this._checker.isFocusable(root) && this._checker.isTabbable(root)) {
|
|
1620
1770
|
return root;
|
|
1621
1771
|
}
|
|
1772
|
+
// Iterate in DOM order. Note that IE doesn't have `children` for SVG so we fall
|
|
1773
|
+
// back to `childNodes` which includes text nodes, comments etc.
|
|
1622
1774
|
/** @type {?} */
|
|
1623
1775
|
var children = root.children || root.childNodes;
|
|
1624
1776
|
for (var i = 0; i < children.length; i++) {
|
|
1625
1777
|
/** @type {?} */
|
|
1626
1778
|
var tabbableChild = children[i].nodeType === this._document.ELEMENT_NODE ?
|
|
1627
|
-
this._getFirstTabbableElement(/** @type {?} */ (children[i])) :
|
|
1779
|
+
this._getFirstTabbableElement((/** @type {?} */ (children[i]))) :
|
|
1628
1780
|
null;
|
|
1629
1781
|
if (tabbableChild) {
|
|
1630
1782
|
return tabbableChild;
|
|
@@ -1632,13 +1784,16 @@ FocusTrap = /** @class */ (function () {
|
|
|
1632
1784
|
}
|
|
1633
1785
|
return null;
|
|
1634
1786
|
};
|
|
1787
|
+
/** Get the last tabbable element from a DOM subtree (inclusive). */
|
|
1635
1788
|
/**
|
|
1636
1789
|
* Get the last tabbable element from a DOM subtree (inclusive).
|
|
1790
|
+
* @private
|
|
1637
1791
|
* @param {?} root
|
|
1638
1792
|
* @return {?}
|
|
1639
1793
|
*/
|
|
1640
1794
|
FocusTrap.prototype._getLastTabbableElement = /**
|
|
1641
1795
|
* Get the last tabbable element from a DOM subtree (inclusive).
|
|
1796
|
+
* @private
|
|
1642
1797
|
* @param {?} root
|
|
1643
1798
|
* @return {?}
|
|
1644
1799
|
*/
|
|
@@ -1646,12 +1801,13 @@ FocusTrap = /** @class */ (function () {
|
|
|
1646
1801
|
if (this._checker.isFocusable(root) && this._checker.isTabbable(root)) {
|
|
1647
1802
|
return root;
|
|
1648
1803
|
}
|
|
1804
|
+
// Iterate in reverse DOM order.
|
|
1649
1805
|
/** @type {?} */
|
|
1650
1806
|
var children = root.children || root.childNodes;
|
|
1651
1807
|
for (var i = children.length - 1; i >= 0; i--) {
|
|
1652
1808
|
/** @type {?} */
|
|
1653
1809
|
var tabbableChild = children[i].nodeType === this._document.ELEMENT_NODE ?
|
|
1654
|
-
this._getLastTabbableElement(/** @type {?} */ (children[i])) :
|
|
1810
|
+
this._getLastTabbableElement((/** @type {?} */ (children[i]))) :
|
|
1655
1811
|
null;
|
|
1656
1812
|
if (tabbableChild) {
|
|
1657
1813
|
return tabbableChild;
|
|
@@ -1659,12 +1815,15 @@ FocusTrap = /** @class */ (function () {
|
|
|
1659
1815
|
}
|
|
1660
1816
|
return null;
|
|
1661
1817
|
};
|
|
1818
|
+
/** Creates an anchor element. */
|
|
1662
1819
|
/**
|
|
1663
1820
|
* Creates an anchor element.
|
|
1821
|
+
* @private
|
|
1664
1822
|
* @return {?}
|
|
1665
1823
|
*/
|
|
1666
1824
|
FocusTrap.prototype._createAnchor = /**
|
|
1667
1825
|
* Creates an anchor element.
|
|
1826
|
+
* @private
|
|
1668
1827
|
* @return {?}
|
|
1669
1828
|
*/
|
|
1670
1829
|
function () {
|
|
@@ -1677,12 +1836,19 @@ FocusTrap = /** @class */ (function () {
|
|
|
1677
1836
|
};
|
|
1678
1837
|
/**
|
|
1679
1838
|
* Toggles the `tabindex` of an anchor, based on the enabled state of the focus trap.
|
|
1839
|
+
* @param isEnabled Whether the focus trap is enabled.
|
|
1840
|
+
* @param anchor Anchor on which to toggle the tabindex.
|
|
1841
|
+
*/
|
|
1842
|
+
/**
|
|
1843
|
+
* Toggles the `tabindex` of an anchor, based on the enabled state of the focus trap.
|
|
1844
|
+
* @private
|
|
1680
1845
|
* @param {?} isEnabled Whether the focus trap is enabled.
|
|
1681
1846
|
* @param {?} anchor Anchor on which to toggle the tabindex.
|
|
1682
1847
|
* @return {?}
|
|
1683
1848
|
*/
|
|
1684
1849
|
FocusTrap.prototype._toggleAnchorTabIndex = /**
|
|
1685
1850
|
* Toggles the `tabindex` of an anchor, based on the enabled state of the focus trap.
|
|
1851
|
+
* @private
|
|
1686
1852
|
* @param {?} isEnabled Whether the focus trap is enabled.
|
|
1687
1853
|
* @param {?} anchor Anchor on which to toggle the tabindex.
|
|
1688
1854
|
* @return {?}
|
|
@@ -1692,13 +1858,16 @@ FocusTrap = /** @class */ (function () {
|
|
|
1692
1858
|
// element has a tabindex, the user might still hit it when navigating with the arrow keys.
|
|
1693
1859
|
isEnabled ? anchor.setAttribute('tabindex', '0') : anchor.removeAttribute('tabindex');
|
|
1694
1860
|
};
|
|
1861
|
+
/** Executes a function when the zone is stable. */
|
|
1695
1862
|
/**
|
|
1696
1863
|
* Executes a function when the zone is stable.
|
|
1864
|
+
* @private
|
|
1697
1865
|
* @param {?} fn
|
|
1698
1866
|
* @return {?}
|
|
1699
1867
|
*/
|
|
1700
1868
|
FocusTrap.prototype._executeOnStable = /**
|
|
1701
1869
|
* Executes a function when the zone is stable.
|
|
1870
|
+
* @private
|
|
1702
1871
|
* @param {?} fn
|
|
1703
1872
|
* @return {?}
|
|
1704
1873
|
*/
|
|
@@ -1830,7 +1999,7 @@ var CdkTrapFocus = /** @class */ (function () {
|
|
|
1830
1999
|
function () {
|
|
1831
2000
|
this.focusTrap.attachAnchors();
|
|
1832
2001
|
if (this.autoCapture) {
|
|
1833
|
-
this._previouslyFocusedElement = /** @type {?} */ (this._document.activeElement);
|
|
2002
|
+
this._previouslyFocusedElement = (/** @type {?} */ (this._document.activeElement));
|
|
1834
2003
|
this.focusTrap.focusInitialElementWhenReady();
|
|
1835
2004
|
}
|
|
1836
2005
|
};
|
|
@@ -1866,8 +2035,10 @@ var CdkTrapFocus = /** @class */ (function () {
|
|
|
1866
2035
|
|
|
1867
2036
|
/**
|
|
1868
2037
|
* @fileoverview added by tsickle
|
|
1869
|
-
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
2038
|
+
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1870
2039
|
*/
|
|
2040
|
+
// The token for the live announcer element is defined in a separate file from LiveAnnouncer
|
|
2041
|
+
// as a workaround for https://github.com/angular/angular/issues/22559
|
|
1871
2042
|
/** @type {?} */
|
|
1872
2043
|
var LIVE_ANNOUNCER_ELEMENT_TOKEN = new InjectionToken('liveAnnouncerElement', {
|
|
1873
2044
|
providedIn: 'root',
|
|
@@ -1883,7 +2054,7 @@ function LIVE_ANNOUNCER_ELEMENT_TOKEN_FACTORY() {
|
|
|
1883
2054
|
|
|
1884
2055
|
/**
|
|
1885
2056
|
* @fileoverview added by tsickle
|
|
1886
|
-
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
2057
|
+
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1887
2058
|
*/
|
|
1888
2059
|
var LiveAnnouncer = /** @class */ (function () {
|
|
1889
2060
|
function LiveAnnouncer(elementToken, _ngZone, _document) {
|
|
@@ -1895,29 +2066,35 @@ var LiveAnnouncer = /** @class */ (function () {
|
|
|
1895
2066
|
this._liveElement = elementToken || this._createLiveElement();
|
|
1896
2067
|
}
|
|
1897
2068
|
/**
|
|
1898
|
-
*
|
|
1899
|
-
* @param
|
|
1900
|
-
* @
|
|
1901
|
-
* @returns Promise that will be resolved when the message is added to the DOM.
|
|
1902
|
-
*/
|
|
1903
|
-
/**
|
|
1904
|
-
* Announces a message to screenreaders.
|
|
1905
|
-
* @param {?} message Message to be announced to the screenreader
|
|
1906
|
-
* @param {?=} politeness The politeness of the announcer element
|
|
1907
|
-
* @return {?} Promise that will be resolved when the message is added to the DOM.
|
|
2069
|
+
* @param {?} message
|
|
2070
|
+
* @param {...?} args
|
|
2071
|
+
* @return {?}
|
|
1908
2072
|
*/
|
|
1909
2073
|
LiveAnnouncer.prototype.announce = /**
|
|
1910
|
-
*
|
|
1911
|
-
* @param {
|
|
1912
|
-
* @
|
|
1913
|
-
* @return {?} Promise that will be resolved when the message is added to the DOM.
|
|
2074
|
+
* @param {?} message
|
|
2075
|
+
* @param {...?} args
|
|
2076
|
+
* @return {?}
|
|
1914
2077
|
*/
|
|
1915
|
-
function (message
|
|
2078
|
+
function (message) {
|
|
1916
2079
|
var _this = this;
|
|
1917
|
-
|
|
1918
|
-
|
|
2080
|
+
var args = [];
|
|
2081
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
2082
|
+
args[_i - 1] = arguments[_i];
|
|
2083
|
+
}
|
|
2084
|
+
/** @type {?} */
|
|
2085
|
+
var politeness;
|
|
2086
|
+
/** @type {?} */
|
|
2087
|
+
var duration;
|
|
2088
|
+
if (args.length === 1 && typeof args[0] === 'number') {
|
|
2089
|
+
duration = args[0];
|
|
2090
|
+
}
|
|
2091
|
+
else {
|
|
2092
|
+
politeness = args[0], duration = args[1];
|
|
2093
|
+
}
|
|
2094
|
+
this.clear();
|
|
2095
|
+
clearTimeout(this._previousTimeout);
|
|
1919
2096
|
// TODO: ensure changing the politeness works on all environments we support.
|
|
1920
|
-
this._liveElement.setAttribute('aria-live', politeness);
|
|
2097
|
+
this._liveElement.setAttribute('aria-live', (/** @type {?} */ (politeness)) || 'polite');
|
|
1921
2098
|
// This 100ms timeout is necessary for some browser + screen-reader combinations:
|
|
1922
2099
|
// - Both JAWS and NVDA over IE11 will not announce anything without a non-zero timeout.
|
|
1923
2100
|
// - With Chrome and IE11 with NVDA or JAWS, a repeated (identical) message won't be read a
|
|
@@ -1925,13 +2102,39 @@ var LiveAnnouncer = /** @class */ (function () {
|
|
|
1925
2102
|
// (using JAWS 17 at time of this writing).
|
|
1926
2103
|
return this._ngZone.runOutsideAngular(function () {
|
|
1927
2104
|
return new Promise(function (resolve) {
|
|
1928
|
-
|
|
2105
|
+
clearTimeout(_this._previousTimeout);
|
|
2106
|
+
_this._previousTimeout = setTimeout(function () {
|
|
1929
2107
|
_this._liveElement.textContent = message;
|
|
1930
2108
|
resolve();
|
|
2109
|
+
if (typeof duration === 'number') {
|
|
2110
|
+
_this._previousTimeout = setTimeout(function () { return _this.clear(); }, duration);
|
|
2111
|
+
}
|
|
1931
2112
|
}, 100);
|
|
1932
2113
|
});
|
|
1933
2114
|
});
|
|
1934
2115
|
};
|
|
2116
|
+
/**
|
|
2117
|
+
* Clears the current text from the announcer element. Can be used to prevent
|
|
2118
|
+
* screen readers from reading the text out again while the user is going
|
|
2119
|
+
* through the page landmarks.
|
|
2120
|
+
*/
|
|
2121
|
+
/**
|
|
2122
|
+
* Clears the current text from the announcer element. Can be used to prevent
|
|
2123
|
+
* screen readers from reading the text out again while the user is going
|
|
2124
|
+
* through the page landmarks.
|
|
2125
|
+
* @return {?}
|
|
2126
|
+
*/
|
|
2127
|
+
LiveAnnouncer.prototype.clear = /**
|
|
2128
|
+
* Clears the current text from the announcer element. Can be used to prevent
|
|
2129
|
+
* screen readers from reading the text out again while the user is going
|
|
2130
|
+
* through the page landmarks.
|
|
2131
|
+
* @return {?}
|
|
2132
|
+
*/
|
|
2133
|
+
function () {
|
|
2134
|
+
if (this._liveElement) {
|
|
2135
|
+
this._liveElement.textContent = '';
|
|
2136
|
+
}
|
|
2137
|
+
};
|
|
1935
2138
|
/**
|
|
1936
2139
|
* @return {?}
|
|
1937
2140
|
*/
|
|
@@ -1939,14 +2142,18 @@ var LiveAnnouncer = /** @class */ (function () {
|
|
|
1939
2142
|
* @return {?}
|
|
1940
2143
|
*/
|
|
1941
2144
|
function () {
|
|
2145
|
+
clearTimeout(this._previousTimeout);
|
|
1942
2146
|
if (this._liveElement && this._liveElement.parentNode) {
|
|
1943
2147
|
this._liveElement.parentNode.removeChild(this._liveElement);
|
|
2148
|
+
this._liveElement = (/** @type {?} */ (null));
|
|
1944
2149
|
}
|
|
1945
2150
|
};
|
|
1946
2151
|
/**
|
|
2152
|
+
* @private
|
|
1947
2153
|
* @return {?}
|
|
1948
2154
|
*/
|
|
1949
2155
|
LiveAnnouncer.prototype._createLiveElement = /**
|
|
2156
|
+
* @private
|
|
1950
2157
|
* @return {?}
|
|
1951
2158
|
*/
|
|
1952
2159
|
function () {
|
|
@@ -1958,7 +2165,7 @@ var LiveAnnouncer = /** @class */ (function () {
|
|
|
1958
2165
|
var liveEl = this._document.createElement('div');
|
|
1959
2166
|
// Remove any old containers. This can happen when coming in from a server-side-rendered page.
|
|
1960
2167
|
for (var i = 0; i < previousElements.length; i++) {
|
|
1961
|
-
/** @type {?} */ (
|
|
2168
|
+
(/** @type {?} */ (previousElements[i].parentNode)).removeChild(previousElements[i]);
|
|
1962
2169
|
}
|
|
1963
2170
|
liveEl.classList.add(elementClass);
|
|
1964
2171
|
liveEl.classList.add('cdk-visually-hidden');
|
|
@@ -2016,9 +2223,15 @@ var CdkAriaLive = /** @class */ (function () {
|
|
|
2016
2223
|
return _this._contentObserver
|
|
2017
2224
|
.observe(_this._elementRef)
|
|
2018
2225
|
.subscribe(function () {
|
|
2226
|
+
// Note that we use textContent here, rather than innerText, in order to avoid a reflow.
|
|
2019
2227
|
/** @type {?} */
|
|
2020
|
-
var
|
|
2021
|
-
|
|
2228
|
+
var elementText = _this._elementRef.nativeElement.textContent;
|
|
2229
|
+
// The `MutationObserver` fires also for attribute
|
|
2230
|
+
// changes which we don't want to announce.
|
|
2231
|
+
if (elementText !== _this._previousAnnouncedText) {
|
|
2232
|
+
_this._liveAnnouncer.announce(elementText, _this._politeness);
|
|
2233
|
+
_this._previousAnnouncedText = elementText;
|
|
2234
|
+
}
|
|
2022
2235
|
});
|
|
2023
2236
|
});
|
|
2024
2237
|
}
|
|
@@ -2057,18 +2270,19 @@ var CdkAriaLive = /** @class */ (function () {
|
|
|
2057
2270
|
}());
|
|
2058
2271
|
/**
|
|
2059
2272
|
* \@docs-private \@deprecated \@breaking-change 8.0.0
|
|
2060
|
-
* @param {?}
|
|
2273
|
+
* @param {?} parentAnnouncer
|
|
2061
2274
|
* @param {?} liveElement
|
|
2062
2275
|
* @param {?} _document
|
|
2063
2276
|
* @param {?} ngZone
|
|
2064
2277
|
* @return {?}
|
|
2065
2278
|
*/
|
|
2066
|
-
function LIVE_ANNOUNCER_PROVIDER_FACTORY(
|
|
2067
|
-
return
|
|
2279
|
+
function LIVE_ANNOUNCER_PROVIDER_FACTORY(parentAnnouncer, liveElement, _document, ngZone) {
|
|
2280
|
+
return parentAnnouncer || new LiveAnnouncer(liveElement, ngZone, _document);
|
|
2068
2281
|
}
|
|
2069
|
-
/**
|
|
2282
|
+
/**
|
|
2070
2283
|
* \@docs-private \@deprecated \@breaking-change 8.0.0
|
|
2071
|
-
|
|
2284
|
+
* @type {?}
|
|
2285
|
+
*/
|
|
2072
2286
|
var LIVE_ANNOUNCER_PROVIDER = {
|
|
2073
2287
|
// If there is already a LiveAnnouncer available, use that. Otherwise, provide a new one.
|
|
2074
2288
|
provide: LiveAnnouncer,
|
|
@@ -2083,15 +2297,27 @@ var LIVE_ANNOUNCER_PROVIDER = {
|
|
|
2083
2297
|
|
|
2084
2298
|
/**
|
|
2085
2299
|
* @fileoverview added by tsickle
|
|
2086
|
-
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
2300
|
+
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2087
2301
|
*/
|
|
2302
|
+
// This is the value used by AngularJS Material. Through trial and error (on iPhone 6S) they found
|
|
2303
|
+
// that a value of around 650ms seems appropriate.
|
|
2088
2304
|
/** @type {?} */
|
|
2089
2305
|
var TOUCH_BUFFER_MS = 650;
|
|
2306
|
+
/**
|
|
2307
|
+
* Event listener options that enable capturing and also
|
|
2308
|
+
* mark the the listener as passive if the browser supports it.
|
|
2309
|
+
* @type {?}
|
|
2310
|
+
*/
|
|
2311
|
+
var captureEventListenerOptions = normalizePassiveListenerOptions({
|
|
2312
|
+
passive: true,
|
|
2313
|
+
capture: true
|
|
2314
|
+
});
|
|
2090
2315
|
/**
|
|
2091
2316
|
* Monitors mouse and keyboard events to determine the cause of focus events.
|
|
2092
2317
|
*/
|
|
2093
2318
|
var FocusMonitor = /** @class */ (function () {
|
|
2094
2319
|
function FocusMonitor(_ngZone, _platform) {
|
|
2320
|
+
var _this = this;
|
|
2095
2321
|
this._ngZone = _ngZone;
|
|
2096
2322
|
this._platform = _platform;
|
|
2097
2323
|
/**
|
|
@@ -2106,14 +2332,54 @@ var FocusMonitor = /** @class */ (function () {
|
|
|
2106
2332
|
* Map of elements being monitored to their info.
|
|
2107
2333
|
*/
|
|
2108
2334
|
this._elementInfo = new Map();
|
|
2109
|
-
/**
|
|
2110
|
-
* A map of global objects to lists of current listeners.
|
|
2111
|
-
*/
|
|
2112
|
-
this._unregisterGlobalListeners = function () { };
|
|
2113
2335
|
/**
|
|
2114
2336
|
* The number of elements currently being monitored.
|
|
2115
2337
|
*/
|
|
2116
2338
|
this._monitoredElementCount = 0;
|
|
2339
|
+
/**
|
|
2340
|
+
* Event listener for `keydown` events on the document.
|
|
2341
|
+
* Needs to be an arrow function in order to preserve the context when it gets bound.
|
|
2342
|
+
*/
|
|
2343
|
+
this._documentKeydownListener = function () {
|
|
2344
|
+
// On keydown record the origin and clear any touch event that may be in progress.
|
|
2345
|
+
_this._lastTouchTarget = null;
|
|
2346
|
+
_this._setOriginForCurrentEventQueue('keyboard');
|
|
2347
|
+
};
|
|
2348
|
+
/**
|
|
2349
|
+
* Event listener for `mousedown` events on the document.
|
|
2350
|
+
* Needs to be an arrow function in order to preserve the context when it gets bound.
|
|
2351
|
+
*/
|
|
2352
|
+
this._documentMousedownListener = function () {
|
|
2353
|
+
// On mousedown record the origin only if there is not touch
|
|
2354
|
+
// target, since a mousedown can happen as a result of a touch event.
|
|
2355
|
+
if (!_this._lastTouchTarget) {
|
|
2356
|
+
_this._setOriginForCurrentEventQueue('mouse');
|
|
2357
|
+
}
|
|
2358
|
+
};
|
|
2359
|
+
/**
|
|
2360
|
+
* Event listener for `touchstart` events on the document.
|
|
2361
|
+
* Needs to be an arrow function in order to preserve the context when it gets bound.
|
|
2362
|
+
*/
|
|
2363
|
+
this._documentTouchstartListener = function (event) {
|
|
2364
|
+
// When the touchstart event fires the focus event is not yet in the event queue. This means
|
|
2365
|
+
// we can't rely on the trick used above (setting timeout of 1ms). Instead we wait 650ms to
|
|
2366
|
+
// see if a focus happens.
|
|
2367
|
+
if (_this._touchTimeoutId != null) {
|
|
2368
|
+
clearTimeout(_this._touchTimeoutId);
|
|
2369
|
+
}
|
|
2370
|
+
_this._lastTouchTarget = event.target;
|
|
2371
|
+
_this._touchTimeoutId = setTimeout(function () { return _this._lastTouchTarget = null; }, TOUCH_BUFFER_MS);
|
|
2372
|
+
};
|
|
2373
|
+
/**
|
|
2374
|
+
* Event listener for `focus` events on the window.
|
|
2375
|
+
* Needs to be an arrow function in order to preserve the context when it gets bound.
|
|
2376
|
+
*/
|
|
2377
|
+
this._windowFocusListener = function () {
|
|
2378
|
+
// Make a note of when the window regains focus, so we can
|
|
2379
|
+
// restore the origin info for the focused element.
|
|
2380
|
+
_this._windowFocused = true;
|
|
2381
|
+
_this._windowFocusTimeoutId = setTimeout(function () { return _this._windowFocused = false; });
|
|
2382
|
+
};
|
|
2117
2383
|
}
|
|
2118
2384
|
/**
|
|
2119
2385
|
* @param {?} element
|
|
@@ -2137,10 +2403,11 @@ var FocusMonitor = /** @class */ (function () {
|
|
|
2137
2403
|
// Check if we're already monitoring this element.
|
|
2138
2404
|
if (this._elementInfo.has(nativeElement)) {
|
|
2139
2405
|
/** @type {?} */
|
|
2140
|
-
var cachedInfo = this._elementInfo.get(nativeElement);
|
|
2141
|
-
((cachedInfo)).checkChildren = checkChildren;
|
|
2142
|
-
return /** @type {?} */ (
|
|
2406
|
+
var cachedInfo = this._elementInfo.get(nativeElement);
|
|
2407
|
+
(/** @type {?} */ (cachedInfo)).checkChildren = checkChildren;
|
|
2408
|
+
return (/** @type {?} */ (cachedInfo)).subject.asObservable();
|
|
2143
2409
|
}
|
|
2410
|
+
// Create monitored element info.
|
|
2144
2411
|
/** @type {?} */
|
|
2145
2412
|
var info = {
|
|
2146
2413
|
unlisten: function () { },
|
|
@@ -2149,6 +2416,7 @@ var FocusMonitor = /** @class */ (function () {
|
|
|
2149
2416
|
};
|
|
2150
2417
|
this._elementInfo.set(nativeElement, info);
|
|
2151
2418
|
this._incrementMonitoredElementCount();
|
|
2419
|
+
// Start listening. We need to listen in capture phase since focus events don't bubble.
|
|
2152
2420
|
/** @type {?} */
|
|
2153
2421
|
var focusListener = function (event) { return _this._onFocus(event, nativeElement); };
|
|
2154
2422
|
/** @type {?} */
|
|
@@ -2204,7 +2472,7 @@ var FocusMonitor = /** @class */ (function () {
|
|
|
2204
2472
|
// `focus` isn't available on the server
|
|
2205
2473
|
if (typeof nativeElement.focus === 'function') {
|
|
2206
2474
|
// Cast the element to `any`, because the TS typings don't have the `options` parameter yet.
|
|
2207
|
-
(/** @type {?} */ (nativeElement)).focus(options);
|
|
2475
|
+
((/** @type {?} */ (nativeElement))).focus(options);
|
|
2208
2476
|
}
|
|
2209
2477
|
};
|
|
2210
2478
|
/**
|
|
@@ -2218,74 +2486,14 @@ var FocusMonitor = /** @class */ (function () {
|
|
|
2218
2486
|
this._elementInfo.forEach(function (_info, element) { return _this.stopMonitoring(element); });
|
|
2219
2487
|
};
|
|
2220
2488
|
/**
|
|
2221
|
-
*
|
|
2222
|
-
* @return {?}
|
|
2223
|
-
*/
|
|
2224
|
-
FocusMonitor.prototype._registerGlobalListeners = /**
|
|
2225
|
-
* Register necessary event listeners on the document and window.
|
|
2226
|
-
* @return {?}
|
|
2227
|
-
*/
|
|
2228
|
-
function () {
|
|
2229
|
-
var _this = this;
|
|
2230
|
-
// Do nothing if we're not on the browser platform.
|
|
2231
|
-
if (!this._platform.isBrowser) {
|
|
2232
|
-
return;
|
|
2233
|
-
}
|
|
2234
|
-
/** @type {?} */
|
|
2235
|
-
var documentKeydownListener = function () {
|
|
2236
|
-
_this._lastTouchTarget = null;
|
|
2237
|
-
_this._setOriginForCurrentEventQueue('keyboard');
|
|
2238
|
-
};
|
|
2239
|
-
/** @type {?} */
|
|
2240
|
-
var documentMousedownListener = function () {
|
|
2241
|
-
if (!_this._lastTouchTarget) {
|
|
2242
|
-
_this._setOriginForCurrentEventQueue('mouse');
|
|
2243
|
-
}
|
|
2244
|
-
};
|
|
2245
|
-
/** @type {?} */
|
|
2246
|
-
var documentTouchstartListener = function (event) {
|
|
2247
|
-
if (_this._touchTimeoutId != null) {
|
|
2248
|
-
clearTimeout(_this._touchTimeoutId);
|
|
2249
|
-
}
|
|
2250
|
-
_this._lastTouchTarget = event.target;
|
|
2251
|
-
_this._touchTimeoutId = setTimeout(function () { return _this._lastTouchTarget = null; }, TOUCH_BUFFER_MS);
|
|
2252
|
-
};
|
|
2253
|
-
/** @type {?} */
|
|
2254
|
-
var windowFocusListener = function () {
|
|
2255
|
-
_this._windowFocused = true;
|
|
2256
|
-
_this._windowFocusTimeoutId = setTimeout(function () { return _this._windowFocused = false; });
|
|
2257
|
-
};
|
|
2258
|
-
/** @type {?} */
|
|
2259
|
-
var captureEventListenerOptions = normalizePassiveListenerOptions({
|
|
2260
|
-
passive: true,
|
|
2261
|
-
capture: true
|
|
2262
|
-
});
|
|
2263
|
-
// Note: we listen to events in the capture phase so we can detect them even if the user stops
|
|
2264
|
-
// propagation.
|
|
2265
|
-
this._ngZone.runOutsideAngular(function () {
|
|
2266
|
-
document.addEventListener('keydown', documentKeydownListener, captureEventListenerOptions);
|
|
2267
|
-
document.addEventListener('mousedown', documentMousedownListener, captureEventListenerOptions);
|
|
2268
|
-
document.addEventListener('touchstart', documentTouchstartListener, captureEventListenerOptions);
|
|
2269
|
-
window.addEventListener('focus', windowFocusListener);
|
|
2270
|
-
});
|
|
2271
|
-
this._unregisterGlobalListeners = function () {
|
|
2272
|
-
document.removeEventListener('keydown', documentKeydownListener, captureEventListenerOptions);
|
|
2273
|
-
document.removeEventListener('mousedown', documentMousedownListener, captureEventListenerOptions);
|
|
2274
|
-
document.removeEventListener('touchstart', documentTouchstartListener, captureEventListenerOptions);
|
|
2275
|
-
window.removeEventListener('focus', windowFocusListener);
|
|
2276
|
-
// Clear timeouts for all potentially pending timeouts to prevent the leaks.
|
|
2277
|
-
clearTimeout(_this._windowFocusTimeoutId);
|
|
2278
|
-
clearTimeout(_this._touchTimeoutId);
|
|
2279
|
-
clearTimeout(_this._originTimeoutId);
|
|
2280
|
-
};
|
|
2281
|
-
};
|
|
2282
|
-
/**
|
|
2489
|
+
* @private
|
|
2283
2490
|
* @param {?} element
|
|
2284
2491
|
* @param {?} className
|
|
2285
2492
|
* @param {?} shouldSet
|
|
2286
2493
|
* @return {?}
|
|
2287
2494
|
*/
|
|
2288
2495
|
FocusMonitor.prototype._toggleClass = /**
|
|
2496
|
+
* @private
|
|
2289
2497
|
* @param {?} element
|
|
2290
2498
|
* @param {?} className
|
|
2291
2499
|
* @param {?} shouldSet
|
|
@@ -2301,12 +2509,19 @@ var FocusMonitor = /** @class */ (function () {
|
|
|
2301
2509
|
};
|
|
2302
2510
|
/**
|
|
2303
2511
|
* Sets the focus classes on the element based on the given focus origin.
|
|
2512
|
+
* @param element The element to update the classes on.
|
|
2513
|
+
* @param origin The focus origin.
|
|
2514
|
+
*/
|
|
2515
|
+
/**
|
|
2516
|
+
* Sets the focus classes on the element based on the given focus origin.
|
|
2517
|
+
* @private
|
|
2304
2518
|
* @param {?} element The element to update the classes on.
|
|
2305
2519
|
* @param {?=} origin The focus origin.
|
|
2306
2520
|
* @return {?}
|
|
2307
2521
|
*/
|
|
2308
2522
|
FocusMonitor.prototype._setClasses = /**
|
|
2309
2523
|
* Sets the focus classes on the element based on the given focus origin.
|
|
2524
|
+
* @private
|
|
2310
2525
|
* @param {?} element The element to update the classes on.
|
|
2311
2526
|
* @param {?=} origin The focus origin.
|
|
2312
2527
|
* @return {?}
|
|
@@ -2324,11 +2539,17 @@ var FocusMonitor = /** @class */ (function () {
|
|
|
2324
2539
|
};
|
|
2325
2540
|
/**
|
|
2326
2541
|
* Sets the origin and schedules an async function to clear it at the end of the event queue.
|
|
2542
|
+
* @param origin The origin to set.
|
|
2543
|
+
*/
|
|
2544
|
+
/**
|
|
2545
|
+
* Sets the origin and schedules an async function to clear it at the end of the event queue.
|
|
2546
|
+
* @private
|
|
2327
2547
|
* @param {?} origin The origin to set.
|
|
2328
2548
|
* @return {?}
|
|
2329
2549
|
*/
|
|
2330
2550
|
FocusMonitor.prototype._setOriginForCurrentEventQueue = /**
|
|
2331
2551
|
* Sets the origin and schedules an async function to clear it at the end of the event queue.
|
|
2552
|
+
* @private
|
|
2332
2553
|
* @param {?} origin The origin to set.
|
|
2333
2554
|
* @return {?}
|
|
2334
2555
|
*/
|
|
@@ -2344,15 +2565,39 @@ var FocusMonitor = /** @class */ (function () {
|
|
|
2344
2565
|
};
|
|
2345
2566
|
/**
|
|
2346
2567
|
* Checks whether the given focus event was caused by a touchstart event.
|
|
2568
|
+
* @param event The focus event to check.
|
|
2569
|
+
* @returns Whether the event was caused by a touch.
|
|
2570
|
+
*/
|
|
2571
|
+
/**
|
|
2572
|
+
* Checks whether the given focus event was caused by a touchstart event.
|
|
2573
|
+
* @private
|
|
2347
2574
|
* @param {?} event The focus event to check.
|
|
2348
2575
|
* @return {?} Whether the event was caused by a touch.
|
|
2349
2576
|
*/
|
|
2350
2577
|
FocusMonitor.prototype._wasCausedByTouch = /**
|
|
2351
2578
|
* Checks whether the given focus event was caused by a touchstart event.
|
|
2579
|
+
* @private
|
|
2352
2580
|
* @param {?} event The focus event to check.
|
|
2353
2581
|
* @return {?} Whether the event was caused by a touch.
|
|
2354
2582
|
*/
|
|
2355
2583
|
function (event) {
|
|
2584
|
+
// Note(mmalerba): This implementation is not quite perfect, there is a small edge case.
|
|
2585
|
+
// Consider the following dom structure:
|
|
2586
|
+
//
|
|
2587
|
+
// <div #parent tabindex="0" cdkFocusClasses>
|
|
2588
|
+
// <div #child (click)="#parent.focus()"></div>
|
|
2589
|
+
// </div>
|
|
2590
|
+
//
|
|
2591
|
+
// If the user touches the #child element and the #parent is programmatically focused as a
|
|
2592
|
+
// result, this code will still consider it to have been caused by the touch event and will
|
|
2593
|
+
// apply the cdk-touch-focused class rather than the cdk-program-focused class. This is a
|
|
2594
|
+
// relatively small edge-case that can be worked around by using
|
|
2595
|
+
// focusVia(parentEl, 'program') to focus the parent element.
|
|
2596
|
+
//
|
|
2597
|
+
// If we decide that we absolutely must handle this case correctly, we can do so by listening
|
|
2598
|
+
// for the first focus event after the touchstart, and then the first blur event after that
|
|
2599
|
+
// focus event. When that blur event fires we know that whatever follows is not a result of the
|
|
2600
|
+
// touchstart.
|
|
2356
2601
|
/** @type {?} */
|
|
2357
2602
|
var focusTarget = event.target;
|
|
2358
2603
|
return this._lastTouchTarget instanceof Node && focusTarget instanceof Node &&
|
|
@@ -2360,22 +2605,45 @@ var FocusMonitor = /** @class */ (function () {
|
|
|
2360
2605
|
};
|
|
2361
2606
|
/**
|
|
2362
2607
|
* Handles focus events on a registered element.
|
|
2608
|
+
* @param event The focus event.
|
|
2609
|
+
* @param element The monitored element.
|
|
2610
|
+
*/
|
|
2611
|
+
/**
|
|
2612
|
+
* Handles focus events on a registered element.
|
|
2613
|
+
* @private
|
|
2363
2614
|
* @param {?} event The focus event.
|
|
2364
2615
|
* @param {?} element The monitored element.
|
|
2365
2616
|
* @return {?}
|
|
2366
2617
|
*/
|
|
2367
2618
|
FocusMonitor.prototype._onFocus = /**
|
|
2368
2619
|
* Handles focus events on a registered element.
|
|
2620
|
+
* @private
|
|
2369
2621
|
* @param {?} event The focus event.
|
|
2370
2622
|
* @param {?} element The monitored element.
|
|
2371
2623
|
* @return {?}
|
|
2372
2624
|
*/
|
|
2373
2625
|
function (event, element) {
|
|
2626
|
+
// NOTE(mmalerba): We currently set the classes based on the focus origin of the most recent
|
|
2627
|
+
// focus event affecting the monitored element. If we want to use the origin of the first event
|
|
2628
|
+
// instead we should check for the cdk-focused class here and return if the element already has
|
|
2629
|
+
// it. (This only matters for elements that have includesChildren = true).
|
|
2630
|
+
// NOTE(mmalerba): We currently set the classes based on the focus origin of the most recent
|
|
2631
|
+
// focus event affecting the monitored element. If we want to use the origin of the first event
|
|
2632
|
+
// instead we should check for the cdk-focused class here and return if the element already has
|
|
2633
|
+
// it. (This only matters for elements that have includesChildren = true).
|
|
2634
|
+
// If we are not counting child-element-focus as focused, make sure that the event target is the
|
|
2635
|
+
// monitored element itself.
|
|
2374
2636
|
/** @type {?} */
|
|
2375
2637
|
var elementInfo = this._elementInfo.get(element);
|
|
2376
2638
|
if (!elementInfo || (!elementInfo.checkChildren && element !== event.target)) {
|
|
2377
2639
|
return;
|
|
2378
2640
|
}
|
|
2641
|
+
// If we couldn't detect a cause for the focus event, it's due to one of three reasons:
|
|
2642
|
+
// 1) The window has just regained focus, in which case we want to restore the focused state of
|
|
2643
|
+
// the element from before the window blurred.
|
|
2644
|
+
// 2) It was caused by a touch event, in which case we mark the origin as 'touch'.
|
|
2645
|
+
// 3) The element was programmatically focused, in which case we should mark the origin as
|
|
2646
|
+
// 'program'.
|
|
2379
2647
|
/** @type {?} */
|
|
2380
2648
|
var origin = this._origin;
|
|
2381
2649
|
if (!origin) {
|
|
@@ -2411,6 +2679,8 @@ var FocusMonitor = /** @class */ (function () {
|
|
|
2411
2679
|
* @return {?}
|
|
2412
2680
|
*/
|
|
2413
2681
|
function (event, element) {
|
|
2682
|
+
// If we are counting child-element-focus as focused, make sure that we aren't just blurring in
|
|
2683
|
+
// order to focus another child of the monitored element.
|
|
2414
2684
|
/** @type {?} */
|
|
2415
2685
|
var elementInfo = this._elementInfo.get(element);
|
|
2416
2686
|
if (!elementInfo || (elementInfo.checkChildren && event.relatedTarget instanceof Node &&
|
|
@@ -2421,11 +2691,13 @@ var FocusMonitor = /** @class */ (function () {
|
|
|
2421
2691
|
this._emitOrigin(elementInfo.subject, null);
|
|
2422
2692
|
};
|
|
2423
2693
|
/**
|
|
2694
|
+
* @private
|
|
2424
2695
|
* @param {?} subject
|
|
2425
2696
|
* @param {?} origin
|
|
2426
2697
|
* @return {?}
|
|
2427
2698
|
*/
|
|
2428
2699
|
FocusMonitor.prototype._emitOrigin = /**
|
|
2700
|
+
* @private
|
|
2429
2701
|
* @param {?} subject
|
|
2430
2702
|
* @param {?} origin
|
|
2431
2703
|
* @return {?}
|
|
@@ -2434,35 +2706,55 @@ var FocusMonitor = /** @class */ (function () {
|
|
|
2434
2706
|
this._ngZone.run(function () { return subject.next(origin); });
|
|
2435
2707
|
};
|
|
2436
2708
|
/**
|
|
2709
|
+
* @private
|
|
2437
2710
|
* @return {?}
|
|
2438
2711
|
*/
|
|
2439
2712
|
FocusMonitor.prototype._incrementMonitoredElementCount = /**
|
|
2713
|
+
* @private
|
|
2440
2714
|
* @return {?}
|
|
2441
2715
|
*/
|
|
2442
2716
|
function () {
|
|
2717
|
+
var _this = this;
|
|
2443
2718
|
// Register global listeners when first element is monitored.
|
|
2444
|
-
if (++this._monitoredElementCount == 1) {
|
|
2445
|
-
|
|
2719
|
+
if (++this._monitoredElementCount == 1 && this._platform.isBrowser) {
|
|
2720
|
+
// Note: we listen to events in the capture phase so we
|
|
2721
|
+
// can detect them even if the user stops propagation.
|
|
2722
|
+
this._ngZone.runOutsideAngular(function () {
|
|
2723
|
+
document.addEventListener('keydown', _this._documentKeydownListener, captureEventListenerOptions);
|
|
2724
|
+
document.addEventListener('mousedown', _this._documentMousedownListener, captureEventListenerOptions);
|
|
2725
|
+
document.addEventListener('touchstart', _this._documentTouchstartListener, captureEventListenerOptions);
|
|
2726
|
+
window.addEventListener('focus', _this._windowFocusListener);
|
|
2727
|
+
});
|
|
2446
2728
|
}
|
|
2447
2729
|
};
|
|
2448
2730
|
/**
|
|
2731
|
+
* @private
|
|
2449
2732
|
* @return {?}
|
|
2450
2733
|
*/
|
|
2451
2734
|
FocusMonitor.prototype._decrementMonitoredElementCount = /**
|
|
2735
|
+
* @private
|
|
2452
2736
|
* @return {?}
|
|
2453
2737
|
*/
|
|
2454
2738
|
function () {
|
|
2455
2739
|
// Unregister global listeners when last element is unmonitored.
|
|
2456
2740
|
if (!--this._monitoredElementCount) {
|
|
2457
|
-
this.
|
|
2458
|
-
this.
|
|
2741
|
+
document.removeEventListener('keydown', this._documentKeydownListener, captureEventListenerOptions);
|
|
2742
|
+
document.removeEventListener('mousedown', this._documentMousedownListener, captureEventListenerOptions);
|
|
2743
|
+
document.removeEventListener('touchstart', this._documentTouchstartListener, captureEventListenerOptions);
|
|
2744
|
+
window.removeEventListener('focus', this._windowFocusListener);
|
|
2745
|
+
// Clear timeouts for all potentially pending timeouts to prevent the leaks.
|
|
2746
|
+
clearTimeout(this._windowFocusTimeoutId);
|
|
2747
|
+
clearTimeout(this._touchTimeoutId);
|
|
2748
|
+
clearTimeout(this._originTimeoutId);
|
|
2459
2749
|
}
|
|
2460
2750
|
};
|
|
2461
2751
|
/**
|
|
2752
|
+
* @private
|
|
2462
2753
|
* @param {?} element
|
|
2463
2754
|
* @return {?}
|
|
2464
2755
|
*/
|
|
2465
2756
|
FocusMonitor.prototype._getNativeElement = /**
|
|
2757
|
+
* @private
|
|
2466
2758
|
* @param {?} element
|
|
2467
2759
|
* @return {?}
|
|
2468
2760
|
*/
|
|
@@ -2533,9 +2825,10 @@ var CdkMonitorFocus = /** @class */ (function () {
|
|
|
2533
2825
|
function FOCUS_MONITOR_PROVIDER_FACTORY(parentDispatcher, ngZone, platform) {
|
|
2534
2826
|
return parentDispatcher || new FocusMonitor(ngZone, platform);
|
|
2535
2827
|
}
|
|
2536
|
-
/**
|
|
2828
|
+
/**
|
|
2537
2829
|
* \@docs-private \@deprecated \@breaking-change 8.0.0
|
|
2538
|
-
|
|
2830
|
+
* @type {?}
|
|
2831
|
+
*/
|
|
2539
2832
|
var FOCUS_MONITOR_PROVIDER = {
|
|
2540
2833
|
// If there is already a FocusMonitor available, use that. Otherwise, provide a new one.
|
|
2541
2834
|
provide: FocusMonitor,
|
|
@@ -2545,7 +2838,7 @@ var FOCUS_MONITOR_PROVIDER = {
|
|
|
2545
2838
|
|
|
2546
2839
|
/**
|
|
2547
2840
|
* @fileoverview added by tsickle
|
|
2548
|
-
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
2841
|
+
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2549
2842
|
*/
|
|
2550
2843
|
|
|
2551
2844
|
/**
|
|
@@ -2563,7 +2856,7 @@ function isFakeMousedownFromScreenReader(event) {
|
|
|
2563
2856
|
|
|
2564
2857
|
/**
|
|
2565
2858
|
* @fileoverview added by tsickle
|
|
2566
|
-
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
2859
|
+
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2567
2860
|
*/
|
|
2568
2861
|
var A11yModule = /** @class */ (function () {
|
|
2569
2862
|
function A11yModule() {
|
|
@@ -2580,12 +2873,12 @@ var A11yModule = /** @class */ (function () {
|
|
|
2580
2873
|
|
|
2581
2874
|
/**
|
|
2582
2875
|
* @fileoverview added by tsickle
|
|
2583
|
-
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
2876
|
+
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2584
2877
|
*/
|
|
2585
2878
|
|
|
2586
2879
|
/**
|
|
2587
2880
|
* @fileoverview added by tsickle
|
|
2588
|
-
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
2881
|
+
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2589
2882
|
*/
|
|
2590
2883
|
|
|
2591
2884
|
export { ARIA_DESCRIBER_PROVIDER_FACTORY, MESSAGES_CONTAINER_ID, CDK_DESCRIBEDBY_ID_PREFIX, CDK_DESCRIBEDBY_HOST_ATTRIBUTE, AriaDescriber, ARIA_DESCRIBER_PROVIDER, ActiveDescendantKeyManager, FocusKeyManager, ListKeyManager, FocusTrap, FocusTrapFactory, CdkTrapFocus, InteractivityChecker, LIVE_ANNOUNCER_PROVIDER_FACTORY, LiveAnnouncer, CdkAriaLive, LIVE_ANNOUNCER_PROVIDER, LIVE_ANNOUNCER_ELEMENT_TOKEN_FACTORY, LIVE_ANNOUNCER_ELEMENT_TOKEN, FOCUS_MONITOR_PROVIDER_FACTORY, TOUCH_BUFFER_MS, FocusMonitor, CdkMonitorFocus, FOCUS_MONITOR_PROVIDER, isFakeMousedownFromScreenReader, A11yModule };
|