@angular/cdk 9.1.3 → 9.2.2
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/focus-monitor/focus-monitor.d.ts +43 -4
- 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 +140 -90
- package/bundles/cdk-a11y.umd.js.map +1 -1
- package/bundles/cdk-a11y.umd.min.js +14 -7
- package/bundles/cdk-a11y.umd.min.js.map +1 -1
- package/bundles/cdk-coercion.umd.js +0 -1
- package/bundles/cdk-coercion.umd.js.map +1 -1
- package/bundles/cdk-coercion.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.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 +58 -27
- package/bundles/cdk-table.umd.js.map +1 -1
- package/bundles/cdk-table.umd.min.js +12 -5
- package/bundles/cdk-table.umd.min.js.map +1 -1
- package/bundles/cdk-testing-protractor.umd.js +15 -9
- package/bundles/cdk-testing-protractor.umd.js.map +1 -1
- package/bundles/cdk-testing-protractor.umd.min.js +2 -2
- package/bundles/cdk-testing-protractor.umd.min.js.map +1 -1
- package/bundles/cdk-testing-testbed.umd.js +77 -19
- package/bundles/cdk-testing-testbed.umd.js.map +1 -1
- package/bundles/cdk-testing-testbed.umd.min.js +8 -8
- package/bundles/cdk-testing-testbed.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/coercion/array.d.ts +1 -0
- 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 +198 -92
- package/esm2015/a11y/focus-trap/configurable-focus-trap-factory.js +3 -3
- package/esm2015/a11y/focus-trap/focus-trap.js +1 -1
- package/esm2015/a11y/high-contrast-mode/high-contrast-mode-detector.js +10 -6
- package/esm2015/a11y/live-announcer/live-announcer.js +1 -1
- package/esm2015/a11y/public-api.js +2 -2
- package/esm2015/coercion/array.js +1 -2
- 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/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/cell.js +18 -8
- package/esm2015/table/public-api.js +3 -2
- package/esm2015/table/row.js +24 -8
- package/esm2015/table/table.js +26 -12
- package/esm2015/table/text-column.js +3 -26
- package/esm2015/table/tokens.js +44 -0
- package/esm2015/testing/protractor/protractor-harness-environment.js +13 -8
- 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/testbed-harness-environment.js +16 -10
- package/esm2015/testing/testbed/unit-test-element.js +13 -2
- 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 +112 -65
- package/esm5/a11y/high-contrast-mode/high-contrast-mode-detector.js +9 -6
- package/esm5/coercion/array.js +1 -2
- 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/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/cell.js +13 -8
- package/esm5/table/public-api.js +2 -1
- package/esm5/table/row.js +21 -11
- package/esm5/table/table.js +16 -11
- package/esm5/table/text-column.js +3 -4
- package/esm5/table/tokens.js +16 -0
- package/esm5/testing/protractor/protractor-harness-environment.js +17 -11
- 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/testbed-harness-environment.js +17 -11
- package/esm5/testing/testbed/unit-test-element.js +10 -3
- package/esm5/tree/padding.js +9 -5
- package/esm5/tree/tree.js +2 -1
- package/esm5/version.js +1 -1
- package/fesm2015/a11y.js +234 -126
- package/fesm2015/a11y.js.map +1 -1
- package/fesm2015/cdk.js +1 -1
- package/fesm2015/cdk.js.map +1 -1
- package/fesm2015/coercion.js +0 -1
- package/fesm2015/coercion.js.map +1 -1
- package/fesm2015/drag-drop.js +448 -247
- package/fesm2015/drag-drop.js.map +1 -1
- 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 +98 -49
- package/fesm2015/table.js.map +1 -1
- package/fesm2015/testing/protractor.js +13 -8
- package/fesm2015/testing/protractor.js.map +1 -1
- package/fesm2015/testing/testbed.js +71 -13
- package/fesm2015/testing/testbed.js.map +1 -1
- package/fesm2015/tree.js +9 -9
- package/fesm2015/tree.js.map +1 -1
- package/fesm5/a11y.js +141 -92
- package/fesm5/a11y.js.map +1 -1
- package/fesm5/cdk.js +1 -1
- package/fesm5/cdk.js.map +1 -1
- package/fesm5/coercion.js +0 -1
- package/fesm5/coercion.js.map +1 -1
- package/fesm5/drag-drop.js +294 -181
- package/fesm5/drag-drop.js.map +1 -1
- 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 +59 -29
- package/fesm5/table.js.map +1 -1
- package/fesm5/testing/protractor.js +17 -11
- package/fesm5/testing/protractor.js.map +1 -1
- package/fesm5/testing/testbed.js +78 -20
- package/fesm5/testing/testbed.js.map +1 -1
- package/fesm5/tree.js +9 -4
- package/fesm5/tree.js.map +1 -1
- 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/ast/ng-module-imports.js +3 -2
- package/scrolling/index.metadata.json +1 -1
- package/scrolling/scrolling-module.d.ts +2 -0
- package/table/cell.d.ts +2 -0
- package/table/index.metadata.json +1 -1
- package/table/public-api.d.ts +1 -0
- package/table/row.d.ts +6 -3
- package/table/table.d.ts +2 -0
- package/table/text-column.d.ts +2 -13
- package/table/tokens.d.ts +25 -0
- package/testing/protractor/protractor-harness-environment.d.ts +10 -3
- 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/testbed-harness-environment.d.ts +12 -4
- 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 -96
- 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/bundles/cdk-a11y.umd.js
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
* Use of this source code is governed by an MIT-style license that can be
|
|
12
12
|
* found in the LICENSE file at https://angular.io/license
|
|
13
13
|
*/
|
|
14
|
-
/** IDs are
|
|
15
|
-
var
|
|
14
|
+
/** IDs are delimited by an empty space, as per the spec. */
|
|
15
|
+
var ID_DELIMITER = ' ';
|
|
16
16
|
/**
|
|
17
17
|
* Adds the given ID to the specified ARIA attribute on an element.
|
|
18
18
|
* Used for attributes such as aria-labelledby, aria-owns, etc.
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
25
|
ids.push(id.trim());
|
|
26
|
-
el.setAttribute(attr, ids.join(
|
|
26
|
+
el.setAttribute(attr, ids.join(ID_DELIMITER));
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
29
|
* Removes the given ID from the specified ARIA attribute on an element.
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
var ids = getAriaReferenceIds(el, attr);
|
|
34
34
|
var filteredIds = ids.filter(function (val) { return val != id.trim(); });
|
|
35
35
|
if (filteredIds.length) {
|
|
36
|
-
el.setAttribute(attr, filteredIds.join(
|
|
36
|
+
el.setAttribute(attr, filteredIds.join(ID_DELIMITER));
|
|
37
37
|
}
|
|
38
38
|
else {
|
|
39
39
|
el.removeAttribute(attr);
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
* Used for attributes such as aria-labelledby, aria-owns, etc.
|
|
45
45
|
*/
|
|
46
46
|
function getAriaReferenceIds(el, attr) {
|
|
47
|
-
// Get string array of all individual ids (whitespace
|
|
47
|
+
// Get string array of all individual ids (whitespace delimited) in the attribute value
|
|
48
48
|
return (el.getAttribute(attr) || '').match(/\S+/g) || [];
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -1881,6 +1881,24 @@
|
|
|
1881
1881
|
return CdkAriaLive;
|
|
1882
1882
|
}());
|
|
1883
1883
|
|
|
1884
|
+
/**
|
|
1885
|
+
* @license
|
|
1886
|
+
* Copyright Google LLC All Rights Reserved.
|
|
1887
|
+
*
|
|
1888
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
1889
|
+
* found in the LICENSE file at https://angular.io/license
|
|
1890
|
+
*/
|
|
1891
|
+
/**
|
|
1892
|
+
* Screenreaders will often fire fake mousedown events when a focusable element
|
|
1893
|
+
* is activated using the keyboard. We can typically distinguish between these faked
|
|
1894
|
+
* mousedown events and real mousedown events using the "buttons" property. While
|
|
1895
|
+
* real mousedowns will indicate the mouse button that was pressed (e.g. "1" for
|
|
1896
|
+
* the left mouse button), faked mousedowns will usually set the property value to 0.
|
|
1897
|
+
*/
|
|
1898
|
+
function isFakeMousedownFromScreenReader(event) {
|
|
1899
|
+
return event.buttons === 0;
|
|
1900
|
+
}
|
|
1901
|
+
|
|
1884
1902
|
/**
|
|
1885
1903
|
* @license
|
|
1886
1904
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -1891,6 +1909,8 @@
|
|
|
1891
1909
|
// This is the value used by AngularJS Material. Through trial and error (on iPhone 6S) they found
|
|
1892
1910
|
// that a value of around 650ms seems appropriate.
|
|
1893
1911
|
var TOUCH_BUFFER_MS = 650;
|
|
1912
|
+
/** InjectionToken for FocusMonitorOptions. */
|
|
1913
|
+
var FOCUS_MONITOR_DEFAULT_OPTIONS = new i0.InjectionToken('cdk-focus-monitor-default-options');
|
|
1894
1914
|
/**
|
|
1895
1915
|
* Event listener options that enable capturing and also
|
|
1896
1916
|
* mark the listener as passive if the browser supports it.
|
|
@@ -1903,7 +1923,7 @@
|
|
|
1903
1923
|
var FocusMonitor = /** @class */ (function () {
|
|
1904
1924
|
function FocusMonitor(_ngZone, _platform,
|
|
1905
1925
|
/** @breaking-change 11.0.0 make document required */
|
|
1906
|
-
document) {
|
|
1926
|
+
document, options) {
|
|
1907
1927
|
var _this = this;
|
|
1908
1928
|
this._ngZone = _ngZone;
|
|
1909
1929
|
this._platform = _platform;
|
|
@@ -1915,6 +1935,13 @@
|
|
|
1915
1935
|
this._elementInfo = new Map();
|
|
1916
1936
|
/** The number of elements currently being monitored. */
|
|
1917
1937
|
this._monitoredElementCount = 0;
|
|
1938
|
+
/**
|
|
1939
|
+
* Keeps track of the root nodes to which we've currently bound a focus/blur handler,
|
|
1940
|
+
* as well as the number of monitored elements that they contain. We have to treat focus/blur
|
|
1941
|
+
* handlers differently from the rest of the events, because the browser won't emit events
|
|
1942
|
+
* to the document when focus moves inside of a shadow root.
|
|
1943
|
+
*/
|
|
1944
|
+
this._rootNodeFocusListenerCount = new Map();
|
|
1918
1945
|
/**
|
|
1919
1946
|
* Event listener for `keydown` events on the document.
|
|
1920
1947
|
* Needs to be an arrow function in order to preserve the context when it gets bound.
|
|
@@ -1928,11 +1955,14 @@
|
|
|
1928
1955
|
* Event listener for `mousedown` events on the document.
|
|
1929
1956
|
* Needs to be an arrow function in order to preserve the context when it gets bound.
|
|
1930
1957
|
*/
|
|
1931
|
-
this._documentMousedownListener = function () {
|
|
1958
|
+
this._documentMousedownListener = function (event) {
|
|
1932
1959
|
// On mousedown record the origin only if there is not touch
|
|
1933
1960
|
// target, since a mousedown can happen as a result of a touch event.
|
|
1934
1961
|
if (!_this._lastTouchTarget) {
|
|
1935
|
-
|
|
1962
|
+
// In some cases screen readers fire fake `mousedown` events instead of `keydown`.
|
|
1963
|
+
// Resolve the focus source to `keyboard` if we detect one of them.
|
|
1964
|
+
var source = isFakeMousedownFromScreenReader(event) ? 'keyboard' : 'mouse';
|
|
1965
|
+
_this._setOriginForCurrentEventQueue(source);
|
|
1936
1966
|
}
|
|
1937
1967
|
};
|
|
1938
1968
|
/**
|
|
@@ -1946,10 +1976,7 @@
|
|
|
1946
1976
|
if (_this._touchTimeoutId != null) {
|
|
1947
1977
|
clearTimeout(_this._touchTimeoutId);
|
|
1948
1978
|
}
|
|
1949
|
-
|
|
1950
|
-
// will have their `target` set to the shadow root. If available, use `composedPath` to
|
|
1951
|
-
// figure out the event target.
|
|
1952
|
-
_this._lastTouchTarget = event.composedPath ? event.composedPath()[0] : event.target;
|
|
1979
|
+
_this._lastTouchTarget = getTarget(event);
|
|
1953
1980
|
_this._touchTimeoutId = setTimeout(function () { return _this._lastTouchTarget = null; }, TOUCH_BUFFER_MS);
|
|
1954
1981
|
};
|
|
1955
1982
|
/**
|
|
@@ -1962,16 +1989,32 @@
|
|
|
1962
1989
|
_this._windowFocused = true;
|
|
1963
1990
|
_this._windowFocusTimeoutId = setTimeout(function () { return _this._windowFocused = false; });
|
|
1964
1991
|
};
|
|
1992
|
+
/**
|
|
1993
|
+
* Event listener for `focus` and 'blur' events on the document.
|
|
1994
|
+
* Needs to be an arrow function in order to preserve the context when it gets bound.
|
|
1995
|
+
*/
|
|
1996
|
+
this._rootNodeFocusAndBlurListener = function (event) {
|
|
1997
|
+
var target = getTarget(event);
|
|
1998
|
+
var handler = event.type === 'focus' ? _this._onFocus : _this._onBlur;
|
|
1999
|
+
// We need to walk up the ancestor chain in order to support `checkChildren`.
|
|
2000
|
+
for (var element = target; element; element = element.parentElement) {
|
|
2001
|
+
handler.call(_this, event, element);
|
|
2002
|
+
}
|
|
2003
|
+
};
|
|
1965
2004
|
this._document = document;
|
|
2005
|
+
this._detectionMode = (options === null || options === void 0 ? void 0 : options.detectionMode) || 0 /* IMMEDIATE */;
|
|
1966
2006
|
}
|
|
1967
2007
|
FocusMonitor.prototype.monitor = function (element, checkChildren) {
|
|
1968
|
-
var _this = this;
|
|
1969
2008
|
if (checkChildren === void 0) { checkChildren = false; }
|
|
1970
2009
|
// Do nothing if we're not on the browser platform.
|
|
1971
2010
|
if (!this._platform.isBrowser) {
|
|
1972
2011
|
return rxjs.of(null);
|
|
1973
2012
|
}
|
|
1974
2013
|
var nativeElement = coercion.coerceElement(element);
|
|
2014
|
+
// If the element is inside the shadow DOM, we need to bind our focus/blur listeners to
|
|
2015
|
+
// the shadow root, rather than the `document`, because the browser won't emit focus events
|
|
2016
|
+
// to the `document`, if focus is moving within the same shadow root.
|
|
2017
|
+
var rootNode = i1._getShadowRoot(nativeElement) || this._getDocument();
|
|
1975
2018
|
// Check if we're already monitoring this element.
|
|
1976
2019
|
if (this._elementInfo.has(nativeElement)) {
|
|
1977
2020
|
var cachedInfo = this._elementInfo.get(nativeElement);
|
|
@@ -1980,35 +2023,22 @@
|
|
|
1980
2023
|
}
|
|
1981
2024
|
// Create monitored element info.
|
|
1982
2025
|
var info = {
|
|
1983
|
-
unlisten: function () { },
|
|
1984
2026
|
checkChildren: checkChildren,
|
|
1985
|
-
subject: new rxjs.Subject()
|
|
2027
|
+
subject: new rxjs.Subject(),
|
|
2028
|
+
rootNode: rootNode
|
|
1986
2029
|
};
|
|
1987
2030
|
this._elementInfo.set(nativeElement, info);
|
|
1988
|
-
this.
|
|
1989
|
-
// Start listening. We need to listen in capture phase since focus events don't bubble.
|
|
1990
|
-
var focusListener = function (event) { return _this._onFocus(event, nativeElement); };
|
|
1991
|
-
var blurListener = function (event) { return _this._onBlur(event, nativeElement); };
|
|
1992
|
-
this._ngZone.runOutsideAngular(function () {
|
|
1993
|
-
nativeElement.addEventListener('focus', focusListener, true);
|
|
1994
|
-
nativeElement.addEventListener('blur', blurListener, true);
|
|
1995
|
-
});
|
|
1996
|
-
// Create an unlisten function for later.
|
|
1997
|
-
info.unlisten = function () {
|
|
1998
|
-
nativeElement.removeEventListener('focus', focusListener, true);
|
|
1999
|
-
nativeElement.removeEventListener('blur', blurListener, true);
|
|
2000
|
-
};
|
|
2031
|
+
this._registerGlobalListeners(info);
|
|
2001
2032
|
return info.subject.asObservable();
|
|
2002
2033
|
};
|
|
2003
2034
|
FocusMonitor.prototype.stopMonitoring = function (element) {
|
|
2004
2035
|
var nativeElement = coercion.coerceElement(element);
|
|
2005
2036
|
var elementInfo = this._elementInfo.get(nativeElement);
|
|
2006
2037
|
if (elementInfo) {
|
|
2007
|
-
elementInfo.unlisten();
|
|
2008
2038
|
elementInfo.subject.complete();
|
|
2009
2039
|
this._setClasses(nativeElement);
|
|
2010
2040
|
this._elementInfo.delete(nativeElement);
|
|
2011
|
-
this.
|
|
2041
|
+
this._removeGlobalListeners(elementInfo);
|
|
2012
2042
|
}
|
|
2013
2043
|
};
|
|
2014
2044
|
FocusMonitor.prototype.focusVia = function (element, origin, options) {
|
|
@@ -2041,33 +2071,53 @@
|
|
|
2041
2071
|
element.classList.remove(className);
|
|
2042
2072
|
}
|
|
2043
2073
|
};
|
|
2074
|
+
FocusMonitor.prototype._getFocusOrigin = function (event) {
|
|
2075
|
+
// If we couldn't detect a cause for the focus event, it's due to one of three reasons:
|
|
2076
|
+
// 1) The window has just regained focus, in which case we want to restore the focused state of
|
|
2077
|
+
// the element from before the window blurred.
|
|
2078
|
+
// 2) It was caused by a touch event, in which case we mark the origin as 'touch'.
|
|
2079
|
+
// 3) The element was programmatically focused, in which case we should mark the origin as
|
|
2080
|
+
// 'program'.
|
|
2081
|
+
if (this._origin) {
|
|
2082
|
+
return this._origin;
|
|
2083
|
+
}
|
|
2084
|
+
if (this._windowFocused && this._lastFocusOrigin) {
|
|
2085
|
+
return this._lastFocusOrigin;
|
|
2086
|
+
}
|
|
2087
|
+
else if (this._wasCausedByTouch(event)) {
|
|
2088
|
+
return 'touch';
|
|
2089
|
+
}
|
|
2090
|
+
else {
|
|
2091
|
+
return 'program';
|
|
2092
|
+
}
|
|
2093
|
+
};
|
|
2044
2094
|
/**
|
|
2045
2095
|
* Sets the focus classes on the element based on the given focus origin.
|
|
2046
2096
|
* @param element The element to update the classes on.
|
|
2047
2097
|
* @param origin The focus origin.
|
|
2048
2098
|
*/
|
|
2049
2099
|
FocusMonitor.prototype._setClasses = function (element, origin) {
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
this._toggleClass(element, 'cdk-mouse-focused', origin === 'mouse');
|
|
2056
|
-
this._toggleClass(element, 'cdk-program-focused', origin === 'program');
|
|
2057
|
-
}
|
|
2100
|
+
this._toggleClass(element, 'cdk-focused', !!origin);
|
|
2101
|
+
this._toggleClass(element, 'cdk-touch-focused', origin === 'touch');
|
|
2102
|
+
this._toggleClass(element, 'cdk-keyboard-focused', origin === 'keyboard');
|
|
2103
|
+
this._toggleClass(element, 'cdk-mouse-focused', origin === 'mouse');
|
|
2104
|
+
this._toggleClass(element, 'cdk-program-focused', origin === 'program');
|
|
2058
2105
|
};
|
|
2059
2106
|
/**
|
|
2060
2107
|
* Sets the origin and schedules an async function to clear it at the end of the event queue.
|
|
2108
|
+
* If the detection mode is 'eventual', the origin is never cleared.
|
|
2061
2109
|
* @param origin The origin to set.
|
|
2062
2110
|
*/
|
|
2063
2111
|
FocusMonitor.prototype._setOriginForCurrentEventQueue = function (origin) {
|
|
2064
2112
|
var _this = this;
|
|
2065
2113
|
this._ngZone.runOutsideAngular(function () {
|
|
2066
2114
|
_this._origin = origin;
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2115
|
+
if (_this._detectionMode === 0 /* IMMEDIATE */) {
|
|
2116
|
+
// Sometimes the focus origin won't be valid in Firefox because Firefox seems to focus *one*
|
|
2117
|
+
// tick after the interaction event fired. To ensure the focus origin is always correct,
|
|
2118
|
+
// the focus origin will be determined at the beginning of the next tick.
|
|
2119
|
+
_this._originTimeoutId = setTimeout(function () { return _this._origin = null; }, 1);
|
|
2120
|
+
}
|
|
2071
2121
|
});
|
|
2072
2122
|
};
|
|
2073
2123
|
/**
|
|
@@ -2093,7 +2143,7 @@
|
|
|
2093
2143
|
// for the first focus event after the touchstart, and then the first blur event after that
|
|
2094
2144
|
// focus event. When that blur event fires we know that whatever follows is not a result of the
|
|
2095
2145
|
// touchstart.
|
|
2096
|
-
var focusTarget = event
|
|
2146
|
+
var focusTarget = getTarget(event);
|
|
2097
2147
|
return this._lastTouchTarget instanceof Node && focusTarget instanceof Node &&
|
|
2098
2148
|
(focusTarget === this._lastTouchTarget || focusTarget.contains(this._lastTouchTarget));
|
|
2099
2149
|
};
|
|
@@ -2110,27 +2160,10 @@
|
|
|
2110
2160
|
// If we are not counting child-element-focus as focused, make sure that the event target is the
|
|
2111
2161
|
// monitored element itself.
|
|
2112
2162
|
var elementInfo = this._elementInfo.get(element);
|
|
2113
|
-
if (!elementInfo || (!elementInfo.checkChildren && element !== event
|
|
2163
|
+
if (!elementInfo || (!elementInfo.checkChildren && element !== getTarget(event))) {
|
|
2114
2164
|
return;
|
|
2115
2165
|
}
|
|
2116
|
-
|
|
2117
|
-
// 1) The window has just regained focus, in which case we want to restore the focused state of
|
|
2118
|
-
// the element from before the window blurred.
|
|
2119
|
-
// 2) It was caused by a touch event, in which case we mark the origin as 'touch'.
|
|
2120
|
-
// 3) The element was programmatically focused, in which case we should mark the origin as
|
|
2121
|
-
// 'program'.
|
|
2122
|
-
var origin = this._origin;
|
|
2123
|
-
if (!origin) {
|
|
2124
|
-
if (this._windowFocused && this._lastFocusOrigin) {
|
|
2125
|
-
origin = this._lastFocusOrigin;
|
|
2126
|
-
}
|
|
2127
|
-
else if (this._wasCausedByTouch(event)) {
|
|
2128
|
-
origin = 'touch';
|
|
2129
|
-
}
|
|
2130
|
-
else {
|
|
2131
|
-
origin = 'program';
|
|
2132
|
-
}
|
|
2133
|
-
}
|
|
2166
|
+
var origin = this._getFocusOrigin(event);
|
|
2134
2167
|
this._setClasses(element, origin);
|
|
2135
2168
|
this._emitOrigin(elementInfo.subject, origin);
|
|
2136
2169
|
this._lastFocusOrigin = origin;
|
|
@@ -2154,10 +2187,22 @@
|
|
|
2154
2187
|
FocusMonitor.prototype._emitOrigin = function (subject, origin) {
|
|
2155
2188
|
this._ngZone.run(function () { return subject.next(origin); });
|
|
2156
2189
|
};
|
|
2157
|
-
FocusMonitor.prototype.
|
|
2190
|
+
FocusMonitor.prototype._registerGlobalListeners = function (elementInfo) {
|
|
2158
2191
|
var _this = this;
|
|
2192
|
+
if (!this._platform.isBrowser) {
|
|
2193
|
+
return;
|
|
2194
|
+
}
|
|
2195
|
+
var rootNode = elementInfo.rootNode;
|
|
2196
|
+
var rootNodeFocusListeners = this._rootNodeFocusListenerCount.get(rootNode) || 0;
|
|
2197
|
+
if (!rootNodeFocusListeners) {
|
|
2198
|
+
this._ngZone.runOutsideAngular(function () {
|
|
2199
|
+
rootNode.addEventListener('focus', _this._rootNodeFocusAndBlurListener, captureEventListenerOptions);
|
|
2200
|
+
rootNode.addEventListener('blur', _this._rootNodeFocusAndBlurListener, captureEventListenerOptions);
|
|
2201
|
+
});
|
|
2202
|
+
}
|
|
2203
|
+
this._rootNodeFocusListenerCount.set(rootNode, rootNodeFocusListeners + 1);
|
|
2159
2204
|
// Register global listeners when first element is monitored.
|
|
2160
|
-
if (++this._monitoredElementCount
|
|
2205
|
+
if (++this._monitoredElementCount === 1) {
|
|
2161
2206
|
// Note: we listen to events in the capture phase so we
|
|
2162
2207
|
// can detect them even if the user stops propagation.
|
|
2163
2208
|
this._ngZone.runOutsideAngular(function () {
|
|
@@ -2170,7 +2215,19 @@
|
|
|
2170
2215
|
});
|
|
2171
2216
|
}
|
|
2172
2217
|
};
|
|
2173
|
-
FocusMonitor.prototype.
|
|
2218
|
+
FocusMonitor.prototype._removeGlobalListeners = function (elementInfo) {
|
|
2219
|
+
var rootNode = elementInfo.rootNode;
|
|
2220
|
+
if (this._rootNodeFocusListenerCount.has(rootNode)) {
|
|
2221
|
+
var rootNodeFocusListeners = this._rootNodeFocusListenerCount.get(rootNode);
|
|
2222
|
+
if (rootNodeFocusListeners > 1) {
|
|
2223
|
+
this._rootNodeFocusListenerCount.set(rootNode, rootNodeFocusListeners - 1);
|
|
2224
|
+
}
|
|
2225
|
+
else {
|
|
2226
|
+
rootNode.removeEventListener('focus', this._rootNodeFocusAndBlurListener, captureEventListenerOptions);
|
|
2227
|
+
rootNode.removeEventListener('blur', this._rootNodeFocusAndBlurListener, captureEventListenerOptions);
|
|
2228
|
+
this._rootNodeFocusListenerCount.delete(rootNode);
|
|
2229
|
+
}
|
|
2230
|
+
}
|
|
2174
2231
|
// Unregister global listeners when last element is unmonitored.
|
|
2175
2232
|
if (!--this._monitoredElementCount) {
|
|
2176
2233
|
var document_1 = this._getDocument();
|
|
@@ -2192,11 +2249,18 @@
|
|
|
2192
2249
|
FocusMonitor.ctorParameters = function () { return [
|
|
2193
2250
|
{ type: i0.NgZone },
|
|
2194
2251
|
{ type: i1.Platform },
|
|
2195
|
-
{ type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [i2.DOCUMENT,] }] }
|
|
2252
|
+
{ type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [i2.DOCUMENT,] }] },
|
|
2253
|
+
{ type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [FOCUS_MONITOR_DEFAULT_OPTIONS,] }] }
|
|
2196
2254
|
]; };
|
|
2197
|
-
FocusMonitor.ɵprov = i0.ɵɵdefineInjectable({ factory: function FocusMonitor_Factory() { return new FocusMonitor(i0.ɵɵinject(i0.NgZone), i0.ɵɵinject(i1.Platform), i0.ɵɵinject(i2.DOCUMENT, 8)); }, token: FocusMonitor, providedIn: "root" });
|
|
2255
|
+
FocusMonitor.ɵprov = i0.ɵɵdefineInjectable({ factory: function FocusMonitor_Factory() { return new FocusMonitor(i0.ɵɵinject(i0.NgZone), i0.ɵɵinject(i1.Platform), i0.ɵɵinject(i2.DOCUMENT, 8), i0.ɵɵinject(FOCUS_MONITOR_DEFAULT_OPTIONS, 8)); }, token: FocusMonitor, providedIn: "root" });
|
|
2198
2256
|
return FocusMonitor;
|
|
2199
2257
|
}());
|
|
2258
|
+
/** Gets the target of an event, accounting for Shadow DOM. */
|
|
2259
|
+
function getTarget(event) {
|
|
2260
|
+
// If an event is bound outside the Shadow DOM, the `event.target` will
|
|
2261
|
+
// point to the shadow root so we have to use `composedPath` instead.
|
|
2262
|
+
return (event.composedPath ? event.composedPath()[0] : event.target);
|
|
2263
|
+
}
|
|
2200
2264
|
/**
|
|
2201
2265
|
* Directive that determines how a particular element was focused (via keyboard, mouse, touch, or
|
|
2202
2266
|
* programmatically) and adds corresponding classes to the element.
|
|
@@ -2235,24 +2299,6 @@
|
|
|
2235
2299
|
return CdkMonitorFocus;
|
|
2236
2300
|
}());
|
|
2237
2301
|
|
|
2238
|
-
/**
|
|
2239
|
-
* @license
|
|
2240
|
-
* Copyright Google LLC All Rights Reserved.
|
|
2241
|
-
*
|
|
2242
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
2243
|
-
* found in the LICENSE file at https://angular.io/license
|
|
2244
|
-
*/
|
|
2245
|
-
/**
|
|
2246
|
-
* Screenreaders will often fire fake mousedown events when a focusable element
|
|
2247
|
-
* is activated using the keyboard. We can typically distinguish between these faked
|
|
2248
|
-
* mousedown events and real mousedown events using the "buttons" property. While
|
|
2249
|
-
* real mousedowns will indicate the mouse button that was pressed (e.g. "1" for
|
|
2250
|
-
* the left mouse button), faked mousedowns will usually set the property value to 0.
|
|
2251
|
-
*/
|
|
2252
|
-
function isFakeMousedownFromScreenReader(event) {
|
|
2253
|
-
return event.buttons === 0;
|
|
2254
|
-
}
|
|
2255
|
-
|
|
2256
2302
|
/**
|
|
2257
2303
|
* @license
|
|
2258
2304
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -2267,7 +2313,7 @@
|
|
|
2267
2313
|
/** CSS class applied to the document body when in high-contrast mode. */
|
|
2268
2314
|
var HIGH_CONTRAST_MODE_ACTIVE_CSS_CLASS = 'cdk-high-contrast-active';
|
|
2269
2315
|
/**
|
|
2270
|
-
* Service to determine whether the browser is currently in a high-
|
|
2316
|
+
* Service to determine whether the browser is currently in a high-contrast-mode environment.
|
|
2271
2317
|
*
|
|
2272
2318
|
* Microsoft Windows supports an accessibility feature called "High Contrast Mode". This mode
|
|
2273
2319
|
* changes the appearance of all applications, including web applications, to dramatically increase
|
|
@@ -2282,7 +2328,7 @@
|
|
|
2282
2328
|
this._platform = _platform;
|
|
2283
2329
|
this._document = document;
|
|
2284
2330
|
}
|
|
2285
|
-
/** Gets the current high-
|
|
2331
|
+
/** Gets the current high-contrast-mode for the page. */
|
|
2286
2332
|
HighContrastModeDetector.prototype.getHighContrastMode = function () {
|
|
2287
2333
|
if (!this._platform.isBrowser) {
|
|
2288
2334
|
return 0 /* NONE */;
|
|
@@ -2296,9 +2342,12 @@
|
|
|
2296
2342
|
this._document.body.appendChild(testElement);
|
|
2297
2343
|
// Get the computed style for the background color, collapsing spaces to normalize between
|
|
2298
2344
|
// browsers. Once we get this color, we no longer need the test element. Access the `window`
|
|
2299
|
-
// via the document so we can fake it in tests.
|
|
2300
|
-
|
|
2301
|
-
var
|
|
2345
|
+
// via the document so we can fake it in tests. Note that we have extra null checks, because
|
|
2346
|
+
// this logic will likely run during app bootstrap and throwing can break the entire app.
|
|
2347
|
+
var documentWindow = this._document.defaultView || window;
|
|
2348
|
+
var computedStyle = (documentWindow && documentWindow.getComputedStyle) ?
|
|
2349
|
+
documentWindow.getComputedStyle(testElement) : null;
|
|
2350
|
+
var computedColor = (computedStyle && computedStyle.backgroundColor || '').replace(/ /g, '');
|
|
2302
2351
|
this._document.body.removeChild(testElement);
|
|
2303
2352
|
switch (computedColor) {
|
|
2304
2353
|
case 'rgb(0,0,0)': return 2 /* WHITE_ON_BLACK */;
|
|
@@ -2385,6 +2434,7 @@
|
|
|
2385
2434
|
exports.ConfigurableFocusTrap = ConfigurableFocusTrap;
|
|
2386
2435
|
exports.ConfigurableFocusTrapFactory = ConfigurableFocusTrapFactory;
|
|
2387
2436
|
exports.EventListenerFocusTrapInertStrategy = EventListenerFocusTrapInertStrategy;
|
|
2437
|
+
exports.FOCUS_MONITOR_DEFAULT_OPTIONS = FOCUS_MONITOR_DEFAULT_OPTIONS;
|
|
2388
2438
|
exports.FOCUS_TRAP_INERT_STRATEGY = FOCUS_TRAP_INERT_STRATEGY;
|
|
2389
2439
|
exports.FocusKeyManager = FocusKeyManager;
|
|
2390
2440
|
exports.FocusMonitor = FocusMonitor;
|