@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/fesm5/a11y.js
CHANGED
|
@@ -5,7 +5,7 @@ import { Subject, Subscription, of } from 'rxjs';
|
|
|
5
5
|
import { hasModifierKey, A, Z, ZERO, NINE, LEFT_ARROW, RIGHT_ARROW, UP_ARROW, DOWN_ARROW, TAB } from '@angular/cdk/keycodes';
|
|
6
6
|
import { tap, debounceTime, filter, map, take } from 'rxjs/operators';
|
|
7
7
|
import { coerceBooleanProperty, coerceElement } from '@angular/cdk/coercion';
|
|
8
|
-
import { Platform, normalizePassiveListenerOptions, PlatformModule } from '@angular/cdk/platform';
|
|
8
|
+
import { Platform, normalizePassiveListenerOptions, _getShadowRoot, PlatformModule } from '@angular/cdk/platform';
|
|
9
9
|
import { ContentObserver, ObserversModule } from '@angular/cdk/observers';
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -15,8 +15,8 @@ import { ContentObserver, ObserversModule } from '@angular/cdk/observers';
|
|
|
15
15
|
* Use of this source code is governed by an MIT-style license that can be
|
|
16
16
|
* found in the LICENSE file at https://angular.io/license
|
|
17
17
|
*/
|
|
18
|
-
/** IDs are
|
|
19
|
-
var
|
|
18
|
+
/** IDs are delimited by an empty space, as per the spec. */
|
|
19
|
+
var ID_DELIMITER = ' ';
|
|
20
20
|
/**
|
|
21
21
|
* Adds the given ID to the specified ARIA attribute on an element.
|
|
22
22
|
* Used for attributes such as aria-labelledby, aria-owns, etc.
|
|
@@ -27,7 +27,7 @@ function addAriaReferencedId(el, attr, id) {
|
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
29
|
ids.push(id.trim());
|
|
30
|
-
el.setAttribute(attr, ids.join(
|
|
30
|
+
el.setAttribute(attr, ids.join(ID_DELIMITER));
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
33
|
* Removes the given ID from the specified ARIA attribute on an element.
|
|
@@ -37,7 +37,7 @@ function removeAriaReferencedId(el, attr, id) {
|
|
|
37
37
|
var ids = getAriaReferenceIds(el, attr);
|
|
38
38
|
var filteredIds = ids.filter(function (val) { return val != id.trim(); });
|
|
39
39
|
if (filteredIds.length) {
|
|
40
|
-
el.setAttribute(attr, filteredIds.join(
|
|
40
|
+
el.setAttribute(attr, filteredIds.join(ID_DELIMITER));
|
|
41
41
|
}
|
|
42
42
|
else {
|
|
43
43
|
el.removeAttribute(attr);
|
|
@@ -48,7 +48,7 @@ function removeAriaReferencedId(el, attr, id) {
|
|
|
48
48
|
* Used for attributes such as aria-labelledby, aria-owns, etc.
|
|
49
49
|
*/
|
|
50
50
|
function getAriaReferenceIds(el, attr) {
|
|
51
|
-
// Get string array of all individual ids (whitespace
|
|
51
|
+
// Get string array of all individual ids (whitespace delimited) in the attribute value
|
|
52
52
|
return (el.getAttribute(attr) || '').match(/\S+/g) || [];
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -1688,6 +1688,24 @@ var CdkAriaLive = /** @class */ (function () {
|
|
|
1688
1688
|
return CdkAriaLive;
|
|
1689
1689
|
}());
|
|
1690
1690
|
|
|
1691
|
+
/**
|
|
1692
|
+
* @license
|
|
1693
|
+
* Copyright Google LLC All Rights Reserved.
|
|
1694
|
+
*
|
|
1695
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
1696
|
+
* found in the LICENSE file at https://angular.io/license
|
|
1697
|
+
*/
|
|
1698
|
+
/**
|
|
1699
|
+
* Screenreaders will often fire fake mousedown events when a focusable element
|
|
1700
|
+
* is activated using the keyboard. We can typically distinguish between these faked
|
|
1701
|
+
* mousedown events and real mousedown events using the "buttons" property. While
|
|
1702
|
+
* real mousedowns will indicate the mouse button that was pressed (e.g. "1" for
|
|
1703
|
+
* the left mouse button), faked mousedowns will usually set the property value to 0.
|
|
1704
|
+
*/
|
|
1705
|
+
function isFakeMousedownFromScreenReader(event) {
|
|
1706
|
+
return event.buttons === 0;
|
|
1707
|
+
}
|
|
1708
|
+
|
|
1691
1709
|
/**
|
|
1692
1710
|
* @license
|
|
1693
1711
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -1724,6 +1742,13 @@ var FocusMonitor = /** @class */ (function () {
|
|
|
1724
1742
|
this._elementInfo = new Map();
|
|
1725
1743
|
/** The number of elements currently being monitored. */
|
|
1726
1744
|
this._monitoredElementCount = 0;
|
|
1745
|
+
/**
|
|
1746
|
+
* Keeps track of the root nodes to which we've currently bound a focus/blur handler,
|
|
1747
|
+
* as well as the number of monitored elements that they contain. We have to treat focus/blur
|
|
1748
|
+
* handlers differently from the rest of the events, because the browser won't emit events
|
|
1749
|
+
* to the document when focus moves inside of a shadow root.
|
|
1750
|
+
*/
|
|
1751
|
+
this._rootNodeFocusListenerCount = new Map();
|
|
1727
1752
|
/**
|
|
1728
1753
|
* Event listener for `keydown` events on the document.
|
|
1729
1754
|
* Needs to be an arrow function in order to preserve the context when it gets bound.
|
|
@@ -1737,11 +1762,14 @@ var FocusMonitor = /** @class */ (function () {
|
|
|
1737
1762
|
* Event listener for `mousedown` events on the document.
|
|
1738
1763
|
* Needs to be an arrow function in order to preserve the context when it gets bound.
|
|
1739
1764
|
*/
|
|
1740
|
-
this._documentMousedownListener = function () {
|
|
1765
|
+
this._documentMousedownListener = function (event) {
|
|
1741
1766
|
// On mousedown record the origin only if there is not touch
|
|
1742
1767
|
// target, since a mousedown can happen as a result of a touch event.
|
|
1743
1768
|
if (!_this._lastTouchTarget) {
|
|
1744
|
-
|
|
1769
|
+
// In some cases screen readers fire fake `mousedown` events instead of `keydown`.
|
|
1770
|
+
// Resolve the focus source to `keyboard` if we detect one of them.
|
|
1771
|
+
var source = isFakeMousedownFromScreenReader(event) ? 'keyboard' : 'mouse';
|
|
1772
|
+
_this._setOriginForCurrentEventQueue(source);
|
|
1745
1773
|
}
|
|
1746
1774
|
};
|
|
1747
1775
|
/**
|
|
@@ -1755,10 +1783,7 @@ var FocusMonitor = /** @class */ (function () {
|
|
|
1755
1783
|
if (_this._touchTimeoutId != null) {
|
|
1756
1784
|
clearTimeout(_this._touchTimeoutId);
|
|
1757
1785
|
}
|
|
1758
|
-
|
|
1759
|
-
// will have their `target` set to the shadow root. If available, use `composedPath` to
|
|
1760
|
-
// figure out the event target.
|
|
1761
|
-
_this._lastTouchTarget = event.composedPath ? event.composedPath()[0] : event.target;
|
|
1786
|
+
_this._lastTouchTarget = getTarget(event);
|
|
1762
1787
|
_this._touchTimeoutId = setTimeout(function () { return _this._lastTouchTarget = null; }, TOUCH_BUFFER_MS);
|
|
1763
1788
|
};
|
|
1764
1789
|
/**
|
|
@@ -1771,54 +1796,61 @@ var FocusMonitor = /** @class */ (function () {
|
|
|
1771
1796
|
_this._windowFocused = true;
|
|
1772
1797
|
_this._windowFocusTimeoutId = setTimeout(function () { return _this._windowFocused = false; });
|
|
1773
1798
|
};
|
|
1799
|
+
/**
|
|
1800
|
+
* Event listener for `focus` and 'blur' events on the document.
|
|
1801
|
+
* Needs to be an arrow function in order to preserve the context when it gets bound.
|
|
1802
|
+
*/
|
|
1803
|
+
this._rootNodeFocusAndBlurListener = function (event) {
|
|
1804
|
+
var target = getTarget(event);
|
|
1805
|
+
var handler = event.type === 'focus' ? _this._onFocus : _this._onBlur;
|
|
1806
|
+
// We need to walk up the ancestor chain in order to support `checkChildren`.
|
|
1807
|
+
for (var element = target; element; element = element.parentElement) {
|
|
1808
|
+
handler.call(_this, event, element);
|
|
1809
|
+
}
|
|
1810
|
+
};
|
|
1774
1811
|
this._document = document;
|
|
1775
1812
|
this._detectionMode = (options === null || options === void 0 ? void 0 : options.detectionMode) || 0 /* IMMEDIATE */;
|
|
1776
1813
|
}
|
|
1777
1814
|
FocusMonitor.prototype.monitor = function (element, checkChildren) {
|
|
1778
|
-
var _this = this;
|
|
1779
1815
|
if (checkChildren === void 0) { checkChildren = false; }
|
|
1780
1816
|
// Do nothing if we're not on the browser platform.
|
|
1781
1817
|
if (!this._platform.isBrowser) {
|
|
1782
1818
|
return of(null);
|
|
1783
1819
|
}
|
|
1784
1820
|
var nativeElement = coerceElement(element);
|
|
1821
|
+
// If the element is inside the shadow DOM, we need to bind our focus/blur listeners to
|
|
1822
|
+
// the shadow root, rather than the `document`, because the browser won't emit focus events
|
|
1823
|
+
// to the `document`, if focus is moving within the same shadow root.
|
|
1824
|
+
var rootNode = _getShadowRoot(nativeElement) || this._getDocument();
|
|
1825
|
+
var cachedInfo = this._elementInfo.get(nativeElement);
|
|
1785
1826
|
// Check if we're already monitoring this element.
|
|
1786
|
-
if (
|
|
1787
|
-
|
|
1788
|
-
|
|
1827
|
+
if (cachedInfo) {
|
|
1828
|
+
if (checkChildren) {
|
|
1829
|
+
// TODO(COMP-318): this can be problematic, because it'll turn all non-checkChildren
|
|
1830
|
+
// observers into ones that behave as if `checkChildren` was turned on. We need a more
|
|
1831
|
+
// robust solution.
|
|
1832
|
+
cachedInfo.checkChildren = true;
|
|
1833
|
+
}
|
|
1789
1834
|
return cachedInfo.subject.asObservable();
|
|
1790
1835
|
}
|
|
1791
1836
|
// Create monitored element info.
|
|
1792
1837
|
var info = {
|
|
1793
|
-
unlisten: function () { },
|
|
1794
1838
|
checkChildren: checkChildren,
|
|
1795
|
-
subject: new Subject()
|
|
1839
|
+
subject: new Subject(),
|
|
1840
|
+
rootNode: rootNode
|
|
1796
1841
|
};
|
|
1797
1842
|
this._elementInfo.set(nativeElement, info);
|
|
1798
|
-
this.
|
|
1799
|
-
// Start listening. We need to listen in capture phase since focus events don't bubble.
|
|
1800
|
-
var focusListener = function (event) { return _this._onFocus(event, nativeElement); };
|
|
1801
|
-
var blurListener = function (event) { return _this._onBlur(event, nativeElement); };
|
|
1802
|
-
this._ngZone.runOutsideAngular(function () {
|
|
1803
|
-
nativeElement.addEventListener('focus', focusListener, true);
|
|
1804
|
-
nativeElement.addEventListener('blur', blurListener, true);
|
|
1805
|
-
});
|
|
1806
|
-
// Create an unlisten function for later.
|
|
1807
|
-
info.unlisten = function () {
|
|
1808
|
-
nativeElement.removeEventListener('focus', focusListener, true);
|
|
1809
|
-
nativeElement.removeEventListener('blur', blurListener, true);
|
|
1810
|
-
};
|
|
1843
|
+
this._registerGlobalListeners(info);
|
|
1811
1844
|
return info.subject.asObservable();
|
|
1812
1845
|
};
|
|
1813
1846
|
FocusMonitor.prototype.stopMonitoring = function (element) {
|
|
1814
1847
|
var nativeElement = coerceElement(element);
|
|
1815
1848
|
var elementInfo = this._elementInfo.get(nativeElement);
|
|
1816
1849
|
if (elementInfo) {
|
|
1817
|
-
elementInfo.unlisten();
|
|
1818
1850
|
elementInfo.subject.complete();
|
|
1819
1851
|
this._setClasses(nativeElement);
|
|
1820
1852
|
this._elementInfo.delete(nativeElement);
|
|
1821
|
-
this.
|
|
1853
|
+
this._removeGlobalListeners(elementInfo);
|
|
1822
1854
|
}
|
|
1823
1855
|
};
|
|
1824
1856
|
FocusMonitor.prototype.focusVia = function (element, origin, options) {
|
|
@@ -1851,20 +1883,37 @@ var FocusMonitor = /** @class */ (function () {
|
|
|
1851
1883
|
element.classList.remove(className);
|
|
1852
1884
|
}
|
|
1853
1885
|
};
|
|
1886
|
+
FocusMonitor.prototype._getFocusOrigin = function (event) {
|
|
1887
|
+
// If we couldn't detect a cause for the focus event, it's due to one of three reasons:
|
|
1888
|
+
// 1) The window has just regained focus, in which case we want to restore the focused state of
|
|
1889
|
+
// the element from before the window blurred.
|
|
1890
|
+
// 2) It was caused by a touch event, in which case we mark the origin as 'touch'.
|
|
1891
|
+
// 3) The element was programmatically focused, in which case we should mark the origin as
|
|
1892
|
+
// 'program'.
|
|
1893
|
+
if (this._origin) {
|
|
1894
|
+
return this._origin;
|
|
1895
|
+
}
|
|
1896
|
+
if (this._windowFocused && this._lastFocusOrigin) {
|
|
1897
|
+
return this._lastFocusOrigin;
|
|
1898
|
+
}
|
|
1899
|
+
else if (this._wasCausedByTouch(event)) {
|
|
1900
|
+
return 'touch';
|
|
1901
|
+
}
|
|
1902
|
+
else {
|
|
1903
|
+
return 'program';
|
|
1904
|
+
}
|
|
1905
|
+
};
|
|
1854
1906
|
/**
|
|
1855
1907
|
* Sets the focus classes on the element based on the given focus origin.
|
|
1856
1908
|
* @param element The element to update the classes on.
|
|
1857
1909
|
* @param origin The focus origin.
|
|
1858
1910
|
*/
|
|
1859
1911
|
FocusMonitor.prototype._setClasses = function (element, origin) {
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
this._toggleClass(element, 'cdk-mouse-focused', origin === 'mouse');
|
|
1866
|
-
this._toggleClass(element, 'cdk-program-focused', origin === 'program');
|
|
1867
|
-
}
|
|
1912
|
+
this._toggleClass(element, 'cdk-focused', !!origin);
|
|
1913
|
+
this._toggleClass(element, 'cdk-touch-focused', origin === 'touch');
|
|
1914
|
+
this._toggleClass(element, 'cdk-keyboard-focused', origin === 'keyboard');
|
|
1915
|
+
this._toggleClass(element, 'cdk-mouse-focused', origin === 'mouse');
|
|
1916
|
+
this._toggleClass(element, 'cdk-program-focused', origin === 'program');
|
|
1868
1917
|
};
|
|
1869
1918
|
/**
|
|
1870
1919
|
* Sets the origin and schedules an async function to clear it at the end of the event queue.
|
|
@@ -1906,7 +1955,7 @@ var FocusMonitor = /** @class */ (function () {
|
|
|
1906
1955
|
// for the first focus event after the touchstart, and then the first blur event after that
|
|
1907
1956
|
// focus event. When that blur event fires we know that whatever follows is not a result of the
|
|
1908
1957
|
// touchstart.
|
|
1909
|
-
var focusTarget = event
|
|
1958
|
+
var focusTarget = getTarget(event);
|
|
1910
1959
|
return this._lastTouchTarget instanceof Node && focusTarget instanceof Node &&
|
|
1911
1960
|
(focusTarget === this._lastTouchTarget || focusTarget.contains(this._lastTouchTarget));
|
|
1912
1961
|
};
|
|
@@ -1923,27 +1972,10 @@ var FocusMonitor = /** @class */ (function () {
|
|
|
1923
1972
|
// If we are not counting child-element-focus as focused, make sure that the event target is the
|
|
1924
1973
|
// monitored element itself.
|
|
1925
1974
|
var elementInfo = this._elementInfo.get(element);
|
|
1926
|
-
if (!elementInfo || (!elementInfo.checkChildren && element !== event
|
|
1975
|
+
if (!elementInfo || (!elementInfo.checkChildren && element !== getTarget(event))) {
|
|
1927
1976
|
return;
|
|
1928
1977
|
}
|
|
1929
|
-
|
|
1930
|
-
// 1) The window has just regained focus, in which case we want to restore the focused state of
|
|
1931
|
-
// the element from before the window blurred.
|
|
1932
|
-
// 2) It was caused by a touch event, in which case we mark the origin as 'touch'.
|
|
1933
|
-
// 3) The element was programmatically focused, in which case we should mark the origin as
|
|
1934
|
-
// 'program'.
|
|
1935
|
-
var origin = this._origin;
|
|
1936
|
-
if (!origin) {
|
|
1937
|
-
if (this._windowFocused && this._lastFocusOrigin) {
|
|
1938
|
-
origin = this._lastFocusOrigin;
|
|
1939
|
-
}
|
|
1940
|
-
else if (this._wasCausedByTouch(event)) {
|
|
1941
|
-
origin = 'touch';
|
|
1942
|
-
}
|
|
1943
|
-
else {
|
|
1944
|
-
origin = 'program';
|
|
1945
|
-
}
|
|
1946
|
-
}
|
|
1978
|
+
var origin = this._getFocusOrigin(event);
|
|
1947
1979
|
this._setClasses(element, origin);
|
|
1948
1980
|
this._emitOrigin(elementInfo.subject, origin);
|
|
1949
1981
|
this._lastFocusOrigin = origin;
|
|
@@ -1967,10 +1999,22 @@ var FocusMonitor = /** @class */ (function () {
|
|
|
1967
1999
|
FocusMonitor.prototype._emitOrigin = function (subject, origin) {
|
|
1968
2000
|
this._ngZone.run(function () { return subject.next(origin); });
|
|
1969
2001
|
};
|
|
1970
|
-
FocusMonitor.prototype.
|
|
2002
|
+
FocusMonitor.prototype._registerGlobalListeners = function (elementInfo) {
|
|
1971
2003
|
var _this = this;
|
|
2004
|
+
if (!this._platform.isBrowser) {
|
|
2005
|
+
return;
|
|
2006
|
+
}
|
|
2007
|
+
var rootNode = elementInfo.rootNode;
|
|
2008
|
+
var rootNodeFocusListeners = this._rootNodeFocusListenerCount.get(rootNode) || 0;
|
|
2009
|
+
if (!rootNodeFocusListeners) {
|
|
2010
|
+
this._ngZone.runOutsideAngular(function () {
|
|
2011
|
+
rootNode.addEventListener('focus', _this._rootNodeFocusAndBlurListener, captureEventListenerOptions);
|
|
2012
|
+
rootNode.addEventListener('blur', _this._rootNodeFocusAndBlurListener, captureEventListenerOptions);
|
|
2013
|
+
});
|
|
2014
|
+
}
|
|
2015
|
+
this._rootNodeFocusListenerCount.set(rootNode, rootNodeFocusListeners + 1);
|
|
1972
2016
|
// Register global listeners when first element is monitored.
|
|
1973
|
-
if (++this._monitoredElementCount
|
|
2017
|
+
if (++this._monitoredElementCount === 1) {
|
|
1974
2018
|
// Note: we listen to events in the capture phase so we
|
|
1975
2019
|
// can detect them even if the user stops propagation.
|
|
1976
2020
|
this._ngZone.runOutsideAngular(function () {
|
|
@@ -1983,7 +2027,19 @@ var FocusMonitor = /** @class */ (function () {
|
|
|
1983
2027
|
});
|
|
1984
2028
|
}
|
|
1985
2029
|
};
|
|
1986
|
-
FocusMonitor.prototype.
|
|
2030
|
+
FocusMonitor.prototype._removeGlobalListeners = function (elementInfo) {
|
|
2031
|
+
var rootNode = elementInfo.rootNode;
|
|
2032
|
+
if (this._rootNodeFocusListenerCount.has(rootNode)) {
|
|
2033
|
+
var rootNodeFocusListeners = this._rootNodeFocusListenerCount.get(rootNode);
|
|
2034
|
+
if (rootNodeFocusListeners > 1) {
|
|
2035
|
+
this._rootNodeFocusListenerCount.set(rootNode, rootNodeFocusListeners - 1);
|
|
2036
|
+
}
|
|
2037
|
+
else {
|
|
2038
|
+
rootNode.removeEventListener('focus', this._rootNodeFocusAndBlurListener, captureEventListenerOptions);
|
|
2039
|
+
rootNode.removeEventListener('blur', this._rootNodeFocusAndBlurListener, captureEventListenerOptions);
|
|
2040
|
+
this._rootNodeFocusListenerCount.delete(rootNode);
|
|
2041
|
+
}
|
|
2042
|
+
}
|
|
1987
2043
|
// Unregister global listeners when last element is unmonitored.
|
|
1988
2044
|
if (!--this._monitoredElementCount) {
|
|
1989
2045
|
var document_1 = this._getDocument();
|
|
@@ -2011,6 +2067,12 @@ var FocusMonitor = /** @class */ (function () {
|
|
|
2011
2067
|
FocusMonitor.ɵprov = ɵɵdefineInjectable({ factory: function FocusMonitor_Factory() { return new FocusMonitor(ɵɵinject(NgZone), ɵɵinject(Platform), ɵɵinject(DOCUMENT, 8), ɵɵinject(FOCUS_MONITOR_DEFAULT_OPTIONS, 8)); }, token: FocusMonitor, providedIn: "root" });
|
|
2012
2068
|
return FocusMonitor;
|
|
2013
2069
|
}());
|
|
2070
|
+
/** Gets the target of an event, accounting for Shadow DOM. */
|
|
2071
|
+
function getTarget(event) {
|
|
2072
|
+
// If an event is bound outside the Shadow DOM, the `event.target` will
|
|
2073
|
+
// point to the shadow root so we have to use `composedPath` instead.
|
|
2074
|
+
return (event.composedPath ? event.composedPath()[0] : event.target);
|
|
2075
|
+
}
|
|
2014
2076
|
/**
|
|
2015
2077
|
* Directive that determines how a particular element was focused (via keyboard, mouse, touch, or
|
|
2016
2078
|
* programmatically) and adds corresponding classes to the element.
|
|
@@ -2049,24 +2111,6 @@ var CdkMonitorFocus = /** @class */ (function () {
|
|
|
2049
2111
|
return CdkMonitorFocus;
|
|
2050
2112
|
}());
|
|
2051
2113
|
|
|
2052
|
-
/**
|
|
2053
|
-
* @license
|
|
2054
|
-
* Copyright Google LLC All Rights Reserved.
|
|
2055
|
-
*
|
|
2056
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
2057
|
-
* found in the LICENSE file at https://angular.io/license
|
|
2058
|
-
*/
|
|
2059
|
-
/**
|
|
2060
|
-
* Screenreaders will often fire fake mousedown events when a focusable element
|
|
2061
|
-
* is activated using the keyboard. We can typically distinguish between these faked
|
|
2062
|
-
* mousedown events and real mousedown events using the "buttons" property. While
|
|
2063
|
-
* real mousedowns will indicate the mouse button that was pressed (e.g. "1" for
|
|
2064
|
-
* the left mouse button), faked mousedowns will usually set the property value to 0.
|
|
2065
|
-
*/
|
|
2066
|
-
function isFakeMousedownFromScreenReader(event) {
|
|
2067
|
-
return event.buttons === 0;
|
|
2068
|
-
}
|
|
2069
|
-
|
|
2070
2114
|
/**
|
|
2071
2115
|
* @license
|
|
2072
2116
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -2081,7 +2125,7 @@ var WHITE_ON_BLACK_CSS_CLASS = 'cdk-high-contrast-white-on-black';
|
|
|
2081
2125
|
/** CSS class applied to the document body when in high-contrast mode. */
|
|
2082
2126
|
var HIGH_CONTRAST_MODE_ACTIVE_CSS_CLASS = 'cdk-high-contrast-active';
|
|
2083
2127
|
/**
|
|
2084
|
-
* Service to determine whether the browser is currently in a high-
|
|
2128
|
+
* Service to determine whether the browser is currently in a high-contrast-mode environment.
|
|
2085
2129
|
*
|
|
2086
2130
|
* Microsoft Windows supports an accessibility feature called "High Contrast Mode". This mode
|
|
2087
2131
|
* changes the appearance of all applications, including web applications, to dramatically increase
|
|
@@ -2096,7 +2140,7 @@ var HighContrastModeDetector = /** @class */ (function () {
|
|
|
2096
2140
|
this._platform = _platform;
|
|
2097
2141
|
this._document = document;
|
|
2098
2142
|
}
|
|
2099
|
-
/** Gets the current high-
|
|
2143
|
+
/** Gets the current high-contrast-mode for the page. */
|
|
2100
2144
|
HighContrastModeDetector.prototype.getHighContrastMode = function () {
|
|
2101
2145
|
if (!this._platform.isBrowser) {
|
|
2102
2146
|
return 0 /* NONE */;
|
|
@@ -2110,9 +2154,12 @@ var HighContrastModeDetector = /** @class */ (function () {
|
|
|
2110
2154
|
this._document.body.appendChild(testElement);
|
|
2111
2155
|
// Get the computed style for the background color, collapsing spaces to normalize between
|
|
2112
2156
|
// browsers. Once we get this color, we no longer need the test element. Access the `window`
|
|
2113
|
-
// via the document so we can fake it in tests.
|
|
2114
|
-
|
|
2115
|
-
var
|
|
2157
|
+
// via the document so we can fake it in tests. Note that we have extra null checks, because
|
|
2158
|
+
// this logic will likely run during app bootstrap and throwing can break the entire app.
|
|
2159
|
+
var documentWindow = this._document.defaultView || window;
|
|
2160
|
+
var computedStyle = (documentWindow && documentWindow.getComputedStyle) ?
|
|
2161
|
+
documentWindow.getComputedStyle(testElement) : null;
|
|
2162
|
+
var computedColor = (computedStyle && computedStyle.backgroundColor || '').replace(/ /g, '');
|
|
2116
2163
|
this._document.body.removeChild(testElement);
|
|
2117
2164
|
switch (computedColor) {
|
|
2118
2165
|
case 'rgb(0,0,0)': return 2 /* WHITE_ON_BLACK */;
|