@angular/cdk 9.2.0 → 9.2.4
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/_text-field.scss +19 -4
- package/a11y/focus-monitor/focus-monitor.d.ts +15 -2
- package/a11y/high-contrast-mode/high-contrast-mode-detector.d.ts +2 -2
- package/a11y/index.metadata.json +1 -1
- package/bundles/cdk-a11y.umd.js +133 -86
- package/bundles/cdk-a11y.umd.js.map +1 -1
- package/bundles/cdk-a11y.umd.min.js +13 -6
- package/bundles/cdk-a11y.umd.min.js.map +1 -1
- package/bundles/cdk-drag-drop.umd.js +292 -179
- package/bundles/cdk-drag-drop.umd.js.map +1 -1
- package/bundles/cdk-drag-drop.umd.min.js +23 -9
- package/bundles/cdk-drag-drop.umd.min.js.map +1 -1
- package/bundles/cdk-overlay.umd.js +2 -12
- 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 +3 -1
- package/bundles/cdk-platform.umd.js.map +1 -1
- package/bundles/cdk-platform.umd.min.js +4 -4
- package/bundles/cdk-platform.umd.min.js.map +1 -1
- package/bundles/cdk-scrolling.umd.js +18 -3
- package/bundles/cdk-scrolling.umd.js.map +1 -1
- package/bundles/cdk-scrolling.umd.min.js +2 -2
- package/bundles/cdk-scrolling.umd.min.js.map +1 -1
- package/bundles/cdk-table.umd.js +8 -0
- package/bundles/cdk-table.umd.js.map +1 -1
- package/bundles/cdk-table.umd.min.js +1 -1
- package/bundles/cdk-table.umd.min.js.map +1 -1
- package/bundles/cdk-testing-protractor.umd.js +14 -10
- package/bundles/cdk-testing-protractor.umd.js.map +1 -1
- package/bundles/cdk-testing-protractor.umd.min.js +1 -1
- package/bundles/cdk-testing-protractor.umd.min.js.map +1 -1
- package/bundles/cdk-testing-testbed.umd.js +71 -16
- package/bundles/cdk-testing-testbed.umd.js.map +1 -1
- package/bundles/cdk-testing-testbed.umd.min.js +6 -6
- package/bundles/cdk-testing-testbed.umd.min.js.map +1 -1
- package/bundles/cdk-testing.umd.js.map +1 -1
- package/bundles/cdk-text-field.umd.js +7 -4
- package/bundles/cdk-text-field.umd.js.map +1 -1
- package/bundles/cdk-text-field.umd.min.js +2 -2
- package/bundles/cdk-text-field.umd.min.js.map +1 -1
- package/bundles/cdk-tree.umd.js +9 -4
- 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 +1 -1
- 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/client-rect.d.ts +31 -0
- package/drag-drop/directives/config.d.ts +1 -0
- package/drag-drop/directives/drop-list.d.ts +4 -3
- package/drag-drop/drag-ref.d.ts +8 -2
- package/drag-drop/drop-list-ref.d.ts +9 -8
- package/drag-drop/index.metadata.json +1 -1
- package/drag-drop/parent-position-tracker.d.ts +31 -0
- package/drag-drop/public-api.d.ts +1 -1
- package/esm2015/a11y/aria-describer/aria-reference.js +6 -6
- package/esm2015/a11y/focus-monitor/focus-monitor.js +151 -82
- package/esm2015/a11y/high-contrast-mode/high-contrast-mode-detector.js +10 -6
- package/esm2015/drag-drop/client-rect.js +75 -0
- package/esm2015/drag-drop/directives/config.js +3 -1
- package/esm2015/drag-drop/directives/drag.js +3 -2
- package/esm2015/drag-drop/directives/drop-list.js +24 -18
- package/esm2015/drag-drop/drag-drop-module.js +3 -1
- package/esm2015/drag-drop/drag-ref.js +97 -43
- package/esm2015/drag-drop/drop-list-ref.js +119 -187
- package/esm2015/drag-drop/parent-position-tracker.js +141 -0
- package/esm2015/drag-drop/public-api.js +1 -1
- package/esm2015/overlay/keyboard/overlay-keyboard-dispatcher.js +2 -2
- package/esm2015/overlay/overlay-ref.js +3 -33
- package/esm2015/overlay/position/flexible-connected-position-strategy.js +1 -1
- package/esm2015/platform/features/shadow-dom.js +4 -2
- package/esm2015/scrolling/public-api.js +2 -2
- package/esm2015/scrolling/scrolling-module.js +15 -4
- package/esm2015/table/row.js +9 -1
- package/esm2015/testing/protractor/protractor-element.js +7 -3
- package/esm2015/testing/test-element.js +1 -1
- package/esm2015/testing/testbed/fake-events/dispatch-events.js +11 -4
- package/esm2015/testing/testbed/fake-events/event-objects.js +37 -3
- package/esm2015/testing/testbed/unit-test-element.js +17 -5
- package/esm2015/text-field/autosize.js +14 -5
- package/esm2015/tree/padding.js +9 -10
- package/esm2015/tree/tree.js +2 -1
- package/esm2015/version.js +1 -1
- package/esm5/a11y/aria-describer/aria-reference.js +6 -6
- package/esm5/a11y/focus-monitor/focus-monitor.js +105 -60
- package/esm5/a11y/high-contrast-mode/high-contrast-mode-detector.js +9 -6
- package/esm5/drag-drop/client-rect.js +60 -0
- package/esm5/drag-drop/directives/config.js +1 -1
- package/esm5/drag-drop/directives/drag.js +3 -2
- package/esm5/drag-drop/directives/drop-list.js +13 -10
- package/esm5/drag-drop/drag-drop-module.js +3 -1
- package/esm5/drag-drop/drag-ref.js +62 -33
- package/esm5/drag-drop/drop-list-ref.js +89 -139
- package/esm5/drag-drop/parent-position-tracker.js +74 -0
- package/esm5/drag-drop/public-api.js +1 -1
- package/esm5/overlay/keyboard/overlay-keyboard-dispatcher.js +2 -2
- package/esm5/overlay/overlay-ref.js +3 -13
- package/esm5/overlay/position/flexible-connected-position-strategy.js +1 -1
- package/esm5/platform/features/shadow-dom.js +4 -2
- package/esm5/scrolling/scrolling-module.js +19 -4
- package/esm5/table/row.js +9 -1
- package/esm5/testing/protractor/protractor-element.js +15 -11
- package/esm5/testing/test-element.js +1 -1
- package/esm5/testing/testbed/fake-events/dispatch-events.js +15 -7
- package/esm5/testing/testbed/fake-events/event-objects.js +43 -5
- package/esm5/testing/testbed/unit-test-element.js +19 -9
- package/esm5/text-field/autosize.js +8 -5
- package/esm5/tree/padding.js +9 -5
- package/esm5/tree/tree.js +2 -1
- package/esm5/version.js +1 -1
- package/fesm2015/a11y.js +188 -116
- package/fesm2015/a11y.js.map +1 -1
- package/fesm2015/cdk.js +1 -1
- package/fesm2015/cdk.js.map +1 -1
- package/fesm2015/drag-drop.js +448 -247
- package/fesm2015/drag-drop.js.map +1 -1
- package/fesm2015/overlay.js +3 -33
- package/fesm2015/overlay.js.map +1 -1
- package/fesm2015/platform.js +3 -1
- package/fesm2015/platform.js.map +1 -1
- package/fesm2015/scrolling.js +15 -4
- package/fesm2015/scrolling.js.map +1 -1
- package/fesm2015/table.js +8 -0
- package/fesm2015/table.js.map +1 -1
- package/fesm2015/testing/protractor.js +6 -2
- package/fesm2015/testing/protractor.js.map +1 -1
- package/fesm2015/testing/testbed.js +60 -7
- package/fesm2015/testing/testbed.js.map +1 -1
- package/fesm2015/testing.js.map +1 -1
- package/fesm2015/text-field.js +13 -4
- package/fesm2015/text-field.js.map +1 -1
- package/fesm2015/tree.js +9 -9
- package/fesm2015/tree.js.map +1 -1
- package/fesm5/a11y.js +134 -87
- package/fesm5/a11y.js.map +1 -1
- package/fesm5/cdk.js +1 -1
- package/fesm5/cdk.js.map +1 -1
- package/fesm5/drag-drop.js +294 -181
- package/fesm5/drag-drop.js.map +1 -1
- package/fesm5/overlay.js +3 -13
- package/fesm5/overlay.js.map +1 -1
- package/fesm5/platform.js +3 -1
- package/fesm5/platform.js.map +1 -1
- package/fesm5/scrolling.js +18 -4
- package/fesm5/scrolling.js.map +1 -1
- package/fesm5/table.js +8 -0
- package/fesm5/table.js.map +1 -1
- package/fesm5/testing/protractor.js +14 -10
- package/fesm5/testing/protractor.js.map +1 -1
- package/fesm5/testing/testbed.js +72 -17
- package/fesm5/testing/testbed.js.map +1 -1
- package/fesm5/testing.js.map +1 -1
- package/fesm5/text-field.js +7 -4
- package/fesm5/text-field.js.map +1 -1
- package/fesm5/tree.js +9 -4
- package/fesm5/tree.js.map +1 -1
- package/overlay/index.metadata.json +1 -1
- package/overlay/overlay-ref.d.ts +0 -3
- package/overlay/position/flexible-connected-position-strategy.d.ts +1 -1
- package/package.json +1 -1
- package/schematics/ng-add/index.js +1 -1
- package/schematics/ng-update/devkit-file-system.d.ts +29 -0
- package/schematics/ng-update/devkit-file-system.js +67 -0
- package/schematics/ng-update/devkit-migration-rule.d.ts +25 -0
- package/schematics/ng-update/devkit-migration-rule.js +152 -0
- package/schematics/ng-update/devkit-migration.d.ts +37 -0
- package/schematics/ng-update/devkit-migration.js +29 -0
- package/schematics/ng-update/index.js +7 -7
- package/schematics/ng-update/{upgrade-rules/attribute-selectors-rule.d.ts → migrations/attribute-selectors.d.ts} +6 -6
- package/schematics/ng-update/migrations/attribute-selectors.js +76 -0
- package/schematics/ng-update/{upgrade-rules/class-inheritance-rule.d.ts → migrations/class-inheritance.d.ts} +6 -6
- package/schematics/ng-update/migrations/class-inheritance.js +67 -0
- package/schematics/ng-update/{upgrade-rules/class-names-rule.d.ts → migrations/class-names.d.ts} +6 -6
- package/schematics/ng-update/migrations/class-names.js +98 -0
- package/schematics/ng-update/{upgrade-rules/constructor-signature-rule.d.ts → migrations/constructor-signature.d.ts} +6 -6
- package/schematics/ng-update/migrations/constructor-signature.js +144 -0
- package/schematics/ng-update/{upgrade-rules/css-selectors-rule.d.ts → migrations/css-selectors.d.ts} +6 -6
- package/schematics/ng-update/migrations/css-selectors.js +83 -0
- package/schematics/ng-update/{upgrade-rules/element-selectors-rule.d.ts → migrations/element-selectors.d.ts} +6 -6
- package/schematics/ng-update/migrations/element-selectors.js +74 -0
- package/schematics/ng-update/{upgrade-rules/input-names-rule.d.ts → migrations/input-names.d.ts} +6 -6
- package/schematics/ng-update/migrations/input-names.js +69 -0
- package/schematics/ng-update/{upgrade-rules/method-call-arguments-rule.d.ts → migrations/method-call-arguments.d.ts} +6 -6
- package/schematics/ng-update/migrations/method-call-arguments.js +70 -0
- package/schematics/ng-update/{upgrade-rules/misc-template-rule.d.ts → migrations/misc-template.d.ts} +6 -6
- package/schematics/ng-update/migrations/misc-template.js +47 -0
- package/schematics/ng-update/{upgrade-rules/output-names-rule.d.ts → migrations/output-names.d.ts} +6 -6
- package/schematics/ng-update/migrations/output-names.js +56 -0
- package/schematics/ng-update/{upgrade-rules/property-names-rule.d.ts → migrations/property-names.d.ts} +6 -6
- package/schematics/ng-update/migrations/property-names.js +56 -0
- package/schematics/ng-update/public-api.d.ts +3 -2
- package/schematics/ng-update/public-api.js +5 -4
- package/schematics/ng-update/upgrade-data.d.ts +7 -8
- package/schematics/ng-update/upgrade-data.js +6 -7
- package/schematics/update-tool/component-resource-collector.d.ts +3 -1
- package/schematics/update-tool/component-resource-collector.js +8 -8
- package/schematics/update-tool/file-system.d.ts +38 -0
- package/schematics/update-tool/file-system.js +20 -0
- package/schematics/update-tool/index.d.ts +41 -11
- package/schematics/update-tool/index.js +135 -106
- package/schematics/update-tool/logger.d.ts +16 -0
- package/schematics/update-tool/logger.js +27 -0
- package/schematics/update-tool/{migration-rule.d.ts → migration.d.ts} +23 -45
- package/schematics/update-tool/migration.js +76 -0
- package/schematics/update-tool/public-api.d.ts +5 -4
- package/schematics/update-tool/public-api.js +6 -6
- package/schematics/update-tool/update-recorder.d.ts +14 -0
- package/schematics/update-tool/update-recorder.js +20 -0
- package/schematics/update-tool/utils/parse-tsconfig.js +1 -1
- package/schematics/update-tool/version-changes.js +3 -4
- package/schematics/utils/build-component.js +15 -4
- package/scrolling/index.metadata.json +1 -1
- package/scrolling/scrolling-module.d.ts +2 -0
- package/table/index.metadata.json +1 -1
- package/testing/protractor/protractor-element.d.ts +1 -1
- package/testing/test-element.d.ts +4 -2
- package/testing/testbed/fake-events/dispatch-events.d.ts +8 -3
- package/testing/testbed/fake-events/event-objects.d.ts +12 -1
- package/testing/testbed/unit-test-element.d.ts +1 -1
- package/text-field/_text-field.scss +19 -4
- package/text-field/autosize.d.ts +2 -0
- package/text-field/index.metadata.json +1 -1
- package/text-field-prebuilt.css +1 -1
- package/tree/index.metadata.json +1 -1
- package/tree/padding.d.ts +6 -2
- package/schematics/ng-update/upgrade-rules/attribute-selectors-rule.js +0 -76
- package/schematics/ng-update/upgrade-rules/class-inheritance-rule.js +0 -67
- package/schematics/ng-update/upgrade-rules/class-names-rule.js +0 -98
- package/schematics/ng-update/upgrade-rules/constructor-signature-rule.js +0 -144
- package/schematics/ng-update/upgrade-rules/css-selectors-rule.js +0 -83
- package/schematics/ng-update/upgrade-rules/element-selectors-rule.js +0 -74
- package/schematics/ng-update/upgrade-rules/index.d.ts +0 -22
- package/schematics/ng-update/upgrade-rules/index.js +0 -116
- package/schematics/ng-update/upgrade-rules/input-names-rule.js +0 -69
- package/schematics/ng-update/upgrade-rules/method-call-arguments-rule.js +0 -70
- package/schematics/ng-update/upgrade-rules/misc-template-rule.js +0 -47
- package/schematics/ng-update/upgrade-rules/output-names-rule.js +0 -56
- package/schematics/ng-update/upgrade-rules/property-names-rule.js +0 -56
- package/schematics/update-tool/migration-rule.js +0 -101
package/fesm2015/a11y.js
CHANGED
|
@@ -4,7 +4,7 @@ import { Subject, Subscription, of } from 'rxjs';
|
|
|
4
4
|
import { hasModifierKey, A, Z, ZERO, NINE, LEFT_ARROW, RIGHT_ARROW, UP_ARROW, DOWN_ARROW, TAB } from '@angular/cdk/keycodes';
|
|
5
5
|
import { tap, debounceTime, filter, map, take } from 'rxjs/operators';
|
|
6
6
|
import { coerceBooleanProperty, coerceElement } from '@angular/cdk/coercion';
|
|
7
|
-
import { Platform, normalizePassiveListenerOptions, PlatformModule } from '@angular/cdk/platform';
|
|
7
|
+
import { Platform, normalizePassiveListenerOptions, _getShadowRoot, PlatformModule } from '@angular/cdk/platform';
|
|
8
8
|
import { ContentObserver, ObserversModule } from '@angular/cdk/observers';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -20,10 +20,10 @@ import { ContentObserver, ObserversModule } from '@angular/cdk/observers';
|
|
|
20
20
|
* found in the LICENSE file at https://angular.io/license
|
|
21
21
|
*/
|
|
22
22
|
/**
|
|
23
|
-
* IDs are
|
|
23
|
+
* IDs are delimited by an empty space, as per the spec.
|
|
24
24
|
* @type {?}
|
|
25
25
|
*/
|
|
26
|
-
const
|
|
26
|
+
const ID_DELIMITER = ' ';
|
|
27
27
|
/**
|
|
28
28
|
* Adds the given ID to the specified ARIA attribute on an element.
|
|
29
29
|
* Used for attributes such as aria-labelledby, aria-owns, etc.
|
|
@@ -43,7 +43,7 @@ function addAriaReferencedId(el, attr, id) {
|
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
45
|
ids.push(id.trim());
|
|
46
|
-
el.setAttribute(attr, ids.join(
|
|
46
|
+
el.setAttribute(attr, ids.join(ID_DELIMITER));
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
49
|
* Removes the given ID from the specified ARIA attribute on an element.
|
|
@@ -63,7 +63,7 @@ function removeAriaReferencedId(el, attr, id) {
|
|
|
63
63
|
*/
|
|
64
64
|
val => val != id.trim()));
|
|
65
65
|
if (filteredIds.length) {
|
|
66
|
-
el.setAttribute(attr, filteredIds.join(
|
|
66
|
+
el.setAttribute(attr, filteredIds.join(ID_DELIMITER));
|
|
67
67
|
}
|
|
68
68
|
else {
|
|
69
69
|
el.removeAttribute(attr);
|
|
@@ -77,7 +77,7 @@ function removeAriaReferencedId(el, attr, id) {
|
|
|
77
77
|
* @return {?}
|
|
78
78
|
*/
|
|
79
79
|
function getAriaReferenceIds(el, attr) {
|
|
80
|
-
// Get string array of all individual ids (whitespace
|
|
80
|
+
// Get string array of all individual ids (whitespace delimited) in the attribute value
|
|
81
81
|
return (el.getAttribute(attr) || '').match(/\S+/g) || [];
|
|
82
82
|
}
|
|
83
83
|
|
|
@@ -2653,6 +2653,31 @@ if (false) {
|
|
|
2653
2653
|
CdkAriaLive.prototype._ngZone;
|
|
2654
2654
|
}
|
|
2655
2655
|
|
|
2656
|
+
/**
|
|
2657
|
+
* @fileoverview added by tsickle
|
|
2658
|
+
* Generated from: src/cdk/a11y/fake-mousedown.ts
|
|
2659
|
+
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2660
|
+
*/
|
|
2661
|
+
/**
|
|
2662
|
+
* @license
|
|
2663
|
+
* Copyright Google LLC All Rights Reserved.
|
|
2664
|
+
*
|
|
2665
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
2666
|
+
* found in the LICENSE file at https://angular.io/license
|
|
2667
|
+
*/
|
|
2668
|
+
/**
|
|
2669
|
+
* Screenreaders will often fire fake mousedown events when a focusable element
|
|
2670
|
+
* is activated using the keyboard. We can typically distinguish between these faked
|
|
2671
|
+
* mousedown events and real mousedown events using the "buttons" property. While
|
|
2672
|
+
* real mousedowns will indicate the mouse button that was pressed (e.g. "1" for
|
|
2673
|
+
* the left mouse button), faked mousedowns will usually set the property value to 0.
|
|
2674
|
+
* @param {?} event
|
|
2675
|
+
* @return {?}
|
|
2676
|
+
*/
|
|
2677
|
+
function isFakeMousedownFromScreenReader(event) {
|
|
2678
|
+
return event.buttons === 0;
|
|
2679
|
+
}
|
|
2680
|
+
|
|
2656
2681
|
/**
|
|
2657
2682
|
* @fileoverview added by tsickle
|
|
2658
2683
|
* Generated from: src/cdk/a11y/focus-monitor/focus-monitor.ts
|
|
@@ -2743,6 +2768,13 @@ class FocusMonitor {
|
|
|
2743
2768
|
* The number of elements currently being monitored.
|
|
2744
2769
|
*/
|
|
2745
2770
|
this._monitoredElementCount = 0;
|
|
2771
|
+
/**
|
|
2772
|
+
* Keeps track of the root nodes to which we've currently bound a focus/blur handler,
|
|
2773
|
+
* as well as the number of monitored elements that they contain. We have to treat focus/blur
|
|
2774
|
+
* handlers differently from the rest of the events, because the browser won't emit events
|
|
2775
|
+
* to the document when focus moves inside of a shadow root.
|
|
2776
|
+
*/
|
|
2777
|
+
this._rootNodeFocusListenerCount = new Map();
|
|
2746
2778
|
/**
|
|
2747
2779
|
* Event listener for `keydown` events on the document.
|
|
2748
2780
|
* Needs to be an arrow function in order to preserve the context when it gets bound.
|
|
@@ -2760,13 +2792,18 @@ class FocusMonitor {
|
|
|
2760
2792
|
* Needs to be an arrow function in order to preserve the context when it gets bound.
|
|
2761
2793
|
*/
|
|
2762
2794
|
this._documentMousedownListener = (/**
|
|
2795
|
+
* @param {?} event
|
|
2763
2796
|
* @return {?}
|
|
2764
2797
|
*/
|
|
2765
|
-
() => {
|
|
2798
|
+
(event) => {
|
|
2766
2799
|
// On mousedown record the origin only if there is not touch
|
|
2767
2800
|
// target, since a mousedown can happen as a result of a touch event.
|
|
2768
2801
|
if (!this._lastTouchTarget) {
|
|
2769
|
-
|
|
2802
|
+
// In some cases screen readers fire fake `mousedown` events instead of `keydown`.
|
|
2803
|
+
// Resolve the focus source to `keyboard` if we detect one of them.
|
|
2804
|
+
/** @type {?} */
|
|
2805
|
+
const source = isFakeMousedownFromScreenReader(event) ? 'keyboard' : 'mouse';
|
|
2806
|
+
this._setOriginForCurrentEventQueue(source);
|
|
2770
2807
|
}
|
|
2771
2808
|
});
|
|
2772
2809
|
/**
|
|
@@ -2784,10 +2821,7 @@ class FocusMonitor {
|
|
|
2784
2821
|
if (this._touchTimeoutId != null) {
|
|
2785
2822
|
clearTimeout(this._touchTimeoutId);
|
|
2786
2823
|
}
|
|
2787
|
-
|
|
2788
|
-
// will have their `target` set to the shadow root. If available, use `composedPath` to
|
|
2789
|
-
// figure out the event target.
|
|
2790
|
-
this._lastTouchTarget = event.composedPath ? event.composedPath()[0] : event.target;
|
|
2824
|
+
this._lastTouchTarget = getTarget(event);
|
|
2791
2825
|
this._touchTimeoutId = setTimeout((/**
|
|
2792
2826
|
* @return {?}
|
|
2793
2827
|
*/
|
|
@@ -2809,6 +2843,24 @@ class FocusMonitor {
|
|
|
2809
2843
|
*/
|
|
2810
2844
|
() => this._windowFocused = false));
|
|
2811
2845
|
});
|
|
2846
|
+
/**
|
|
2847
|
+
* Event listener for `focus` and 'blur' events on the document.
|
|
2848
|
+
* Needs to be an arrow function in order to preserve the context when it gets bound.
|
|
2849
|
+
*/
|
|
2850
|
+
this._rootNodeFocusAndBlurListener = (/**
|
|
2851
|
+
* @param {?} event
|
|
2852
|
+
* @return {?}
|
|
2853
|
+
*/
|
|
2854
|
+
(event) => {
|
|
2855
|
+
/** @type {?} */
|
|
2856
|
+
const target = getTarget(event);
|
|
2857
|
+
/** @type {?} */
|
|
2858
|
+
const handler = event.type === 'focus' ? this._onFocus : this._onBlur;
|
|
2859
|
+
// We need to walk up the ancestor chain in order to support `checkChildren`.
|
|
2860
|
+
for (let element = target; element; element = element.parentElement) {
|
|
2861
|
+
handler.call(this, (/** @type {?} */ (event)), element);
|
|
2862
|
+
}
|
|
2863
|
+
});
|
|
2812
2864
|
this._document = document;
|
|
2813
2865
|
this._detectionMode = (options === null || options === void 0 ? void 0 : options.detectionMode) || 0 /* IMMEDIATE */;
|
|
2814
2866
|
}
|
|
@@ -2824,53 +2876,32 @@ class FocusMonitor {
|
|
|
2824
2876
|
}
|
|
2825
2877
|
/** @type {?} */
|
|
2826
2878
|
const nativeElement = coerceElement(element);
|
|
2879
|
+
// If the element is inside the shadow DOM, we need to bind our focus/blur listeners to
|
|
2880
|
+
// the shadow root, rather than the `document`, because the browser won't emit focus events
|
|
2881
|
+
// to the `document`, if focus is moving within the same shadow root.
|
|
2882
|
+
/** @type {?} */
|
|
2883
|
+
const rootNode = ((/** @type {?} */ (_getShadowRoot(nativeElement)))) || this._getDocument();
|
|
2884
|
+
/** @type {?} */
|
|
2885
|
+
const cachedInfo = this._elementInfo.get(nativeElement);
|
|
2827
2886
|
// Check if we're already monitoring this element.
|
|
2828
|
-
if (
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2887
|
+
if (cachedInfo) {
|
|
2888
|
+
if (checkChildren) {
|
|
2889
|
+
// TODO(COMP-318): this can be problematic, because it'll turn all non-checkChildren
|
|
2890
|
+
// observers into ones that behave as if `checkChildren` was turned on. We need a more
|
|
2891
|
+
// robust solution.
|
|
2892
|
+
cachedInfo.checkChildren = true;
|
|
2893
|
+
}
|
|
2894
|
+
return cachedInfo.subject.asObservable();
|
|
2833
2895
|
}
|
|
2834
2896
|
// Create monitored element info.
|
|
2835
2897
|
/** @type {?} */
|
|
2836
|
-
|
|
2837
|
-
unlisten: (/**
|
|
2838
|
-
* @return {?}
|
|
2839
|
-
*/
|
|
2840
|
-
() => { }),
|
|
2898
|
+
const info = {
|
|
2841
2899
|
checkChildren: checkChildren,
|
|
2842
|
-
subject: new Subject()
|
|
2900
|
+
subject: new Subject(),
|
|
2901
|
+
rootNode
|
|
2843
2902
|
};
|
|
2844
2903
|
this._elementInfo.set(nativeElement, info);
|
|
2845
|
-
this.
|
|
2846
|
-
// Start listening. We need to listen in capture phase since focus events don't bubble.
|
|
2847
|
-
/** @type {?} */
|
|
2848
|
-
let focusListener = (/**
|
|
2849
|
-
* @param {?} event
|
|
2850
|
-
* @return {?}
|
|
2851
|
-
*/
|
|
2852
|
-
(event) => this._onFocus(event, nativeElement));
|
|
2853
|
-
/** @type {?} */
|
|
2854
|
-
let blurListener = (/**
|
|
2855
|
-
* @param {?} event
|
|
2856
|
-
* @return {?}
|
|
2857
|
-
*/
|
|
2858
|
-
(event) => this._onBlur(event, nativeElement));
|
|
2859
|
-
this._ngZone.runOutsideAngular((/**
|
|
2860
|
-
* @return {?}
|
|
2861
|
-
*/
|
|
2862
|
-
() => {
|
|
2863
|
-
nativeElement.addEventListener('focus', focusListener, true);
|
|
2864
|
-
nativeElement.addEventListener('blur', blurListener, true);
|
|
2865
|
-
}));
|
|
2866
|
-
// Create an unlisten function for later.
|
|
2867
|
-
info.unlisten = (/**
|
|
2868
|
-
* @return {?}
|
|
2869
|
-
*/
|
|
2870
|
-
() => {
|
|
2871
|
-
nativeElement.removeEventListener('focus', focusListener, true);
|
|
2872
|
-
nativeElement.removeEventListener('blur', blurListener, true);
|
|
2873
|
-
});
|
|
2904
|
+
this._registerGlobalListeners(info);
|
|
2874
2905
|
return info.subject.asObservable();
|
|
2875
2906
|
}
|
|
2876
2907
|
/**
|
|
@@ -2883,11 +2914,10 @@ class FocusMonitor {
|
|
|
2883
2914
|
/** @type {?} */
|
|
2884
2915
|
const elementInfo = this._elementInfo.get(nativeElement);
|
|
2885
2916
|
if (elementInfo) {
|
|
2886
|
-
elementInfo.unlisten();
|
|
2887
2917
|
elementInfo.subject.complete();
|
|
2888
2918
|
this._setClasses(nativeElement);
|
|
2889
2919
|
this._elementInfo.delete(nativeElement);
|
|
2890
|
-
this.
|
|
2920
|
+
this._removeGlobalListeners(elementInfo);
|
|
2891
2921
|
}
|
|
2892
2922
|
}
|
|
2893
2923
|
/**
|
|
@@ -2950,6 +2980,31 @@ class FocusMonitor {
|
|
|
2950
2980
|
element.classList.remove(className);
|
|
2951
2981
|
}
|
|
2952
2982
|
}
|
|
2983
|
+
/**
|
|
2984
|
+
* @private
|
|
2985
|
+
* @param {?} event
|
|
2986
|
+
* @return {?}
|
|
2987
|
+
*/
|
|
2988
|
+
_getFocusOrigin(event) {
|
|
2989
|
+
// If we couldn't detect a cause for the focus event, it's due to one of three reasons:
|
|
2990
|
+
// 1) The window has just regained focus, in which case we want to restore the focused state of
|
|
2991
|
+
// the element from before the window blurred.
|
|
2992
|
+
// 2) It was caused by a touch event, in which case we mark the origin as 'touch'.
|
|
2993
|
+
// 3) The element was programmatically focused, in which case we should mark the origin as
|
|
2994
|
+
// 'program'.
|
|
2995
|
+
if (this._origin) {
|
|
2996
|
+
return this._origin;
|
|
2997
|
+
}
|
|
2998
|
+
if (this._windowFocused && this._lastFocusOrigin) {
|
|
2999
|
+
return this._lastFocusOrigin;
|
|
3000
|
+
}
|
|
3001
|
+
else if (this._wasCausedByTouch(event)) {
|
|
3002
|
+
return 'touch';
|
|
3003
|
+
}
|
|
3004
|
+
else {
|
|
3005
|
+
return 'program';
|
|
3006
|
+
}
|
|
3007
|
+
}
|
|
2953
3008
|
/**
|
|
2954
3009
|
* Sets the focus classes on the element based on the given focus origin.
|
|
2955
3010
|
* @private
|
|
@@ -2958,15 +3013,11 @@ class FocusMonitor {
|
|
|
2958
3013
|
* @return {?}
|
|
2959
3014
|
*/
|
|
2960
3015
|
_setClasses(element, origin) {
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
this._toggleClass(element, 'cdk-keyboard-focused', origin === 'keyboard');
|
|
2967
|
-
this._toggleClass(element, 'cdk-mouse-focused', origin === 'mouse');
|
|
2968
|
-
this._toggleClass(element, 'cdk-program-focused', origin === 'program');
|
|
2969
|
-
}
|
|
3016
|
+
this._toggleClass(element, 'cdk-focused', !!origin);
|
|
3017
|
+
this._toggleClass(element, 'cdk-touch-focused', origin === 'touch');
|
|
3018
|
+
this._toggleClass(element, 'cdk-keyboard-focused', origin === 'keyboard');
|
|
3019
|
+
this._toggleClass(element, 'cdk-mouse-focused', origin === 'mouse');
|
|
3020
|
+
this._toggleClass(element, 'cdk-program-focused', origin === 'program');
|
|
2970
3021
|
}
|
|
2971
3022
|
/**
|
|
2972
3023
|
* Sets the origin and schedules an async function to clear it at the end of the event queue.
|
|
@@ -3017,7 +3068,7 @@ class FocusMonitor {
|
|
|
3017
3068
|
// focus event. When that blur event fires we know that whatever follows is not a result of the
|
|
3018
3069
|
// touchstart.
|
|
3019
3070
|
/** @type {?} */
|
|
3020
|
-
|
|
3071
|
+
const focusTarget = getTarget(event);
|
|
3021
3072
|
return this._lastTouchTarget instanceof Node && focusTarget instanceof Node &&
|
|
3022
3073
|
(focusTarget === this._lastTouchTarget || focusTarget.contains(this._lastTouchTarget));
|
|
3023
3074
|
}
|
|
@@ -3041,28 +3092,11 @@ class FocusMonitor {
|
|
|
3041
3092
|
// monitored element itself.
|
|
3042
3093
|
/** @type {?} */
|
|
3043
3094
|
const elementInfo = this._elementInfo.get(element);
|
|
3044
|
-
if (!elementInfo || (!elementInfo.checkChildren && element !== event
|
|
3095
|
+
if (!elementInfo || (!elementInfo.checkChildren && element !== getTarget(event))) {
|
|
3045
3096
|
return;
|
|
3046
3097
|
}
|
|
3047
|
-
// If we couldn't detect a cause for the focus event, it's due to one of three reasons:
|
|
3048
|
-
// 1) The window has just regained focus, in which case we want to restore the focused state of
|
|
3049
|
-
// the element from before the window blurred.
|
|
3050
|
-
// 2) It was caused by a touch event, in which case we mark the origin as 'touch'.
|
|
3051
|
-
// 3) The element was programmatically focused, in which case we should mark the origin as
|
|
3052
|
-
// 'program'.
|
|
3053
3098
|
/** @type {?} */
|
|
3054
|
-
|
|
3055
|
-
if (!origin) {
|
|
3056
|
-
if (this._windowFocused && this._lastFocusOrigin) {
|
|
3057
|
-
origin = this._lastFocusOrigin;
|
|
3058
|
-
}
|
|
3059
|
-
else if (this._wasCausedByTouch(event)) {
|
|
3060
|
-
origin = 'touch';
|
|
3061
|
-
}
|
|
3062
|
-
else {
|
|
3063
|
-
origin = 'program';
|
|
3064
|
-
}
|
|
3065
|
-
}
|
|
3099
|
+
const origin = this._getFocusOrigin(event);
|
|
3066
3100
|
this._setClasses(element, origin);
|
|
3067
3101
|
this._emitOrigin(elementInfo.subject, origin);
|
|
3068
3102
|
this._lastFocusOrigin = origin;
|
|
@@ -3099,11 +3133,29 @@ class FocusMonitor {
|
|
|
3099
3133
|
}
|
|
3100
3134
|
/**
|
|
3101
3135
|
* @private
|
|
3136
|
+
* @param {?} elementInfo
|
|
3102
3137
|
* @return {?}
|
|
3103
3138
|
*/
|
|
3104
|
-
|
|
3139
|
+
_registerGlobalListeners(elementInfo) {
|
|
3140
|
+
if (!this._platform.isBrowser) {
|
|
3141
|
+
return;
|
|
3142
|
+
}
|
|
3143
|
+
/** @type {?} */
|
|
3144
|
+
const rootNode = elementInfo.rootNode;
|
|
3145
|
+
/** @type {?} */
|
|
3146
|
+
const rootNodeFocusListeners = this._rootNodeFocusListenerCount.get(rootNode) || 0;
|
|
3147
|
+
if (!rootNodeFocusListeners) {
|
|
3148
|
+
this._ngZone.runOutsideAngular((/**
|
|
3149
|
+
* @return {?}
|
|
3150
|
+
*/
|
|
3151
|
+
() => {
|
|
3152
|
+
rootNode.addEventListener('focus', this._rootNodeFocusAndBlurListener, captureEventListenerOptions);
|
|
3153
|
+
rootNode.addEventListener('blur', this._rootNodeFocusAndBlurListener, captureEventListenerOptions);
|
|
3154
|
+
}));
|
|
3155
|
+
}
|
|
3156
|
+
this._rootNodeFocusListenerCount.set(rootNode, rootNodeFocusListeners + 1);
|
|
3105
3157
|
// Register global listeners when first element is monitored.
|
|
3106
|
-
if (++this._monitoredElementCount
|
|
3158
|
+
if (++this._monitoredElementCount === 1) {
|
|
3107
3159
|
// Note: we listen to events in the capture phase so we
|
|
3108
3160
|
// can detect them even if the user stops propagation.
|
|
3109
3161
|
this._ngZone.runOutsideAngular((/**
|
|
@@ -3123,9 +3175,24 @@ class FocusMonitor {
|
|
|
3123
3175
|
}
|
|
3124
3176
|
/**
|
|
3125
3177
|
* @private
|
|
3178
|
+
* @param {?} elementInfo
|
|
3126
3179
|
* @return {?}
|
|
3127
3180
|
*/
|
|
3128
|
-
|
|
3181
|
+
_removeGlobalListeners(elementInfo) {
|
|
3182
|
+
/** @type {?} */
|
|
3183
|
+
const rootNode = elementInfo.rootNode;
|
|
3184
|
+
if (this._rootNodeFocusListenerCount.has(rootNode)) {
|
|
3185
|
+
/** @type {?} */
|
|
3186
|
+
const rootNodeFocusListeners = (/** @type {?} */ (this._rootNodeFocusListenerCount.get(rootNode)));
|
|
3187
|
+
if (rootNodeFocusListeners > 1) {
|
|
3188
|
+
this._rootNodeFocusListenerCount.set(rootNode, rootNodeFocusListeners - 1);
|
|
3189
|
+
}
|
|
3190
|
+
else {
|
|
3191
|
+
rootNode.removeEventListener('focus', this._rootNodeFocusAndBlurListener, captureEventListenerOptions);
|
|
3192
|
+
rootNode.removeEventListener('blur', this._rootNodeFocusAndBlurListener, captureEventListenerOptions);
|
|
3193
|
+
this._rootNodeFocusListenerCount.delete(rootNode);
|
|
3194
|
+
}
|
|
3195
|
+
}
|
|
3129
3196
|
// Unregister global listeners when last element is unmonitored.
|
|
3130
3197
|
if (!--this._monitoredElementCount) {
|
|
3131
3198
|
/** @type {?} */
|
|
@@ -3209,6 +3276,15 @@ if (false) {
|
|
|
3209
3276
|
* @private
|
|
3210
3277
|
*/
|
|
3211
3278
|
FocusMonitor.prototype._monitoredElementCount;
|
|
3279
|
+
/**
|
|
3280
|
+
* Keeps track of the root nodes to which we've currently bound a focus/blur handler,
|
|
3281
|
+
* as well as the number of monitored elements that they contain. We have to treat focus/blur
|
|
3282
|
+
* handlers differently from the rest of the events, because the browser won't emit events
|
|
3283
|
+
* to the document when focus moves inside of a shadow root.
|
|
3284
|
+
* @type {?}
|
|
3285
|
+
* @private
|
|
3286
|
+
*/
|
|
3287
|
+
FocusMonitor.prototype._rootNodeFocusListenerCount;
|
|
3212
3288
|
/**
|
|
3213
3289
|
* The specified detection mode, used for attributing the origin of a focus
|
|
3214
3290
|
* event.
|
|
@@ -3250,6 +3326,13 @@ if (false) {
|
|
|
3250
3326
|
* @protected
|
|
3251
3327
|
*/
|
|
3252
3328
|
FocusMonitor.prototype._document;
|
|
3329
|
+
/**
|
|
3330
|
+
* Event listener for `focus` and 'blur' events on the document.
|
|
3331
|
+
* Needs to be an arrow function in order to preserve the context when it gets bound.
|
|
3332
|
+
* @type {?}
|
|
3333
|
+
* @private
|
|
3334
|
+
*/
|
|
3335
|
+
FocusMonitor.prototype._rootNodeFocusAndBlurListener;
|
|
3253
3336
|
/**
|
|
3254
3337
|
* @type {?}
|
|
3255
3338
|
* @private
|
|
@@ -3261,6 +3344,16 @@ if (false) {
|
|
|
3261
3344
|
*/
|
|
3262
3345
|
FocusMonitor.prototype._platform;
|
|
3263
3346
|
}
|
|
3347
|
+
/**
|
|
3348
|
+
* Gets the target of an event, accounting for Shadow DOM.
|
|
3349
|
+
* @param {?} event
|
|
3350
|
+
* @return {?}
|
|
3351
|
+
*/
|
|
3352
|
+
function getTarget(event) {
|
|
3353
|
+
// If an event is bound outside the Shadow DOM, the `event.target` will
|
|
3354
|
+
// point to the shadow root so we have to use `composedPath` instead.
|
|
3355
|
+
return (/** @type {?} */ ((event.composedPath ? event.composedPath()[0] : event.target)));
|
|
3356
|
+
}
|
|
3264
3357
|
/**
|
|
3265
3358
|
* Directive that determines how a particular element was focused (via keyboard, mouse, touch, or
|
|
3266
3359
|
* programmatically) and adds corresponding classes to the element.
|
|
@@ -3327,31 +3420,6 @@ if (false) {
|
|
|
3327
3420
|
CdkMonitorFocus.prototype._focusMonitor;
|
|
3328
3421
|
}
|
|
3329
3422
|
|
|
3330
|
-
/**
|
|
3331
|
-
* @fileoverview added by tsickle
|
|
3332
|
-
* Generated from: src/cdk/a11y/fake-mousedown.ts
|
|
3333
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3334
|
-
*/
|
|
3335
|
-
/**
|
|
3336
|
-
* @license
|
|
3337
|
-
* Copyright Google LLC All Rights Reserved.
|
|
3338
|
-
*
|
|
3339
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
3340
|
-
* found in the LICENSE file at https://angular.io/license
|
|
3341
|
-
*/
|
|
3342
|
-
/**
|
|
3343
|
-
* Screenreaders will often fire fake mousedown events when a focusable element
|
|
3344
|
-
* is activated using the keyboard. We can typically distinguish between these faked
|
|
3345
|
-
* mousedown events and real mousedown events using the "buttons" property. While
|
|
3346
|
-
* real mousedowns will indicate the mouse button that was pressed (e.g. "1" for
|
|
3347
|
-
* the left mouse button), faked mousedowns will usually set the property value to 0.
|
|
3348
|
-
* @param {?} event
|
|
3349
|
-
* @return {?}
|
|
3350
|
-
*/
|
|
3351
|
-
function isFakeMousedownFromScreenReader(event) {
|
|
3352
|
-
return event.buttons === 0;
|
|
3353
|
-
}
|
|
3354
|
-
|
|
3355
3423
|
/**
|
|
3356
3424
|
* @fileoverview added by tsickle
|
|
3357
3425
|
* Generated from: src/cdk/a11y/high-contrast-mode/high-contrast-mode-detector.ts
|
|
@@ -3379,7 +3447,7 @@ const WHITE_ON_BLACK_CSS_CLASS = 'cdk-high-contrast-white-on-black';
|
|
|
3379
3447
|
*/
|
|
3380
3448
|
const HIGH_CONTRAST_MODE_ACTIVE_CSS_CLASS = 'cdk-high-contrast-active';
|
|
3381
3449
|
/**
|
|
3382
|
-
* Service to determine whether the browser is currently in a high-
|
|
3450
|
+
* Service to determine whether the browser is currently in a high-contrast-mode environment.
|
|
3383
3451
|
*
|
|
3384
3452
|
* Microsoft Windows supports an accessibility feature called "High Contrast Mode". This mode
|
|
3385
3453
|
* changes the appearance of all applications, including web applications, to dramatically increase
|
|
@@ -3399,7 +3467,7 @@ class HighContrastModeDetector {
|
|
|
3399
3467
|
this._document = document;
|
|
3400
3468
|
}
|
|
3401
3469
|
/**
|
|
3402
|
-
* Gets the current high-
|
|
3470
|
+
* Gets the current high-contrast-mode for the page.
|
|
3403
3471
|
* @return {?}
|
|
3404
3472
|
*/
|
|
3405
3473
|
getHighContrastMode() {
|
|
@@ -3416,11 +3484,15 @@ class HighContrastModeDetector {
|
|
|
3416
3484
|
this._document.body.appendChild(testElement);
|
|
3417
3485
|
// Get the computed style for the background color, collapsing spaces to normalize between
|
|
3418
3486
|
// browsers. Once we get this color, we no longer need the test element. Access the `window`
|
|
3419
|
-
// via the document so we can fake it in tests.
|
|
3487
|
+
// via the document so we can fake it in tests. Note that we have extra null checks, because
|
|
3488
|
+
// this logic will likely run during app bootstrap and throwing can break the entire app.
|
|
3489
|
+
/** @type {?} */
|
|
3490
|
+
const documentWindow = this._document.defaultView || window;
|
|
3420
3491
|
/** @type {?} */
|
|
3421
|
-
const
|
|
3492
|
+
const computedStyle = (documentWindow && documentWindow.getComputedStyle) ?
|
|
3493
|
+
documentWindow.getComputedStyle(testElement) : null;
|
|
3422
3494
|
/** @type {?} */
|
|
3423
|
-
const computedColor = (
|
|
3495
|
+
const computedColor = (computedStyle && computedStyle.backgroundColor || '').replace(/ /g, '');
|
|
3424
3496
|
this._document.body.removeChild(testElement);
|
|
3425
3497
|
switch (computedColor) {
|
|
3426
3498
|
case 'rgb(0,0,0)': return 2 /* WHITE_ON_BLACK */;
|