@angular/cdk 9.1.2 → 9.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (199) hide show
  1. package/a11y/focus-monitor/focus-monitor.d.ts +42 -2
  2. package/a11y/index.metadata.json +1 -1
  3. package/bundles/cdk-a11y.umd.js +107 -75
  4. package/bundles/cdk-a11y.umd.js.map +1 -1
  5. package/bundles/cdk-a11y.umd.min.js +7 -7
  6. package/bundles/cdk-a11y.umd.min.js.map +1 -1
  7. package/bundles/cdk-clipboard.umd.js +1 -1
  8. package/bundles/cdk-clipboard.umd.js.map +1 -1
  9. package/bundles/cdk-clipboard.umd.min.js +1 -1
  10. package/bundles/cdk-clipboard.umd.min.js.map +1 -1
  11. package/bundles/cdk-coercion.umd.js +0 -1
  12. package/bundles/cdk-coercion.umd.js.map +1 -1
  13. package/bundles/cdk-coercion.umd.min.js.map +1 -1
  14. package/bundles/cdk-drag-drop.umd.js +121 -95
  15. package/bundles/cdk-drag-drop.umd.js.map +1 -1
  16. package/bundles/cdk-drag-drop.umd.min.js +15 -8
  17. package/bundles/cdk-drag-drop.umd.min.js.map +1 -1
  18. package/bundles/cdk-overlay.umd.js +2 -1
  19. package/bundles/cdk-overlay.umd.js.map +1 -1
  20. package/bundles/cdk-overlay.umd.min.js +4 -4
  21. package/bundles/cdk-overlay.umd.min.js.map +1 -1
  22. package/bundles/cdk-platform.umd.js +11 -0
  23. package/bundles/cdk-platform.umd.js.map +1 -1
  24. package/bundles/cdk-platform.umd.min.js +6 -6
  25. package/bundles/cdk-platform.umd.min.js.map +1 -1
  26. package/bundles/cdk-scrolling.umd.js +41 -10
  27. package/bundles/cdk-scrolling.umd.js.map +1 -1
  28. package/bundles/cdk-scrolling.umd.min.js +8 -8
  29. package/bundles/cdk-scrolling.umd.min.js.map +1 -1
  30. package/bundles/cdk-table.umd.js +58 -27
  31. package/bundles/cdk-table.umd.js.map +1 -1
  32. package/bundles/cdk-table.umd.min.js +12 -5
  33. package/bundles/cdk-table.umd.min.js.map +1 -1
  34. package/bundles/cdk-testing-protractor.umd.js +15 -9
  35. package/bundles/cdk-testing-protractor.umd.js.map +1 -1
  36. package/bundles/cdk-testing-protractor.umd.min.js +2 -2
  37. package/bundles/cdk-testing-protractor.umd.min.js.map +1 -1
  38. package/bundles/cdk-testing-testbed.umd.js +15 -9
  39. package/bundles/cdk-testing-testbed.umd.js.map +1 -1
  40. package/bundles/cdk-testing-testbed.umd.min.js +8 -8
  41. package/bundles/cdk-testing-testbed.umd.min.js.map +1 -1
  42. package/bundles/cdk-text-field.umd.js +21 -6
  43. package/bundles/cdk-text-field.umd.js.map +1 -1
  44. package/bundles/cdk-text-field.umd.min.js +3 -3
  45. package/bundles/cdk-text-field.umd.min.js.map +1 -1
  46. package/bundles/cdk-tree.umd.js +8 -4
  47. package/bundles/cdk-tree.umd.js.map +1 -1
  48. package/bundles/cdk-tree.umd.min.js +1 -1
  49. package/bundles/cdk-tree.umd.min.js.map +1 -1
  50. package/bundles/cdk.umd.js +1 -1
  51. package/bundles/cdk.umd.js.map +1 -1
  52. package/bundles/cdk.umd.min.js +1 -1
  53. package/bundles/cdk.umd.min.js.map +1 -1
  54. package/coercion/array.d.ts +1 -0
  55. package/drag-drop/client-rect.d.ts +31 -0
  56. package/drag-drop/directives/config.d.ts +1 -0
  57. package/drag-drop/directives/drop-list.d.ts +4 -3
  58. package/drag-drop/drag-ref.d.ts +4 -0
  59. package/drag-drop/index.metadata.json +1 -1
  60. package/esm2015/a11y/focus-monitor/focus-monitor.js +163 -76
  61. package/esm2015/a11y/focus-trap/configurable-focus-trap-factory.js +3 -3
  62. package/esm2015/a11y/focus-trap/focus-trap.js +1 -1
  63. package/esm2015/a11y/high-contrast-mode/high-contrast-mode-detector.js +8 -4
  64. package/esm2015/a11y/live-announcer/live-announcer.js +1 -1
  65. package/esm2015/a11y/public-api.js +2 -2
  66. package/esm2015/bidi/directionality.js +1 -1
  67. package/esm2015/clipboard/pending-copy.js +3 -3
  68. package/esm2015/coercion/array.js +1 -2
  69. package/esm2015/drag-drop/client-rect.js +75 -0
  70. package/esm2015/drag-drop/directives/config.js +3 -1
  71. package/esm2015/drag-drop/directives/drag.js +3 -2
  72. package/esm2015/drag-drop/directives/drop-list.js +24 -18
  73. package/esm2015/drag-drop/drag-drop.js +1 -1
  74. package/esm2015/drag-drop/drag-ref.js +61 -25
  75. package/esm2015/drag-drop/drop-list-ref.js +15 -82
  76. package/esm2015/layout/breakpoints-observer.js +1 -1
  77. package/esm2015/overlay/position/flexible-connected-position-strategy.js +3 -2
  78. package/esm2015/overlay/position/overlay-position-builder.js +1 -1
  79. package/esm2015/platform/features/shadow-dom.js +16 -1
  80. package/esm2015/platform/public-api.js +2 -2
  81. package/esm2015/scrolling/scroll-dispatcher.js +38 -5
  82. package/esm2015/scrolling/viewport-ruler.js +44 -5
  83. package/esm2015/table/cell.js +18 -8
  84. package/esm2015/table/public-api.js +3 -2
  85. package/esm2015/table/row.js +24 -8
  86. package/esm2015/table/table.js +26 -12
  87. package/esm2015/table/text-column.js +3 -26
  88. package/esm2015/table/tokens.js +44 -0
  89. package/esm2015/testing/protractor/protractor-harness-environment.js +13 -8
  90. package/esm2015/testing/testbed/testbed-harness-environment.js +16 -10
  91. package/esm2015/text-field/autosize.js +38 -4
  92. package/esm2015/tree/padding.js +9 -10
  93. package/esm2015/version.js +1 -1
  94. package/esm5/a11y/focus-monitor/focus-monitor.js +87 -56
  95. package/esm5/a11y/focus-trap/configurable-focus-trap-factory.js +3 -3
  96. package/esm5/a11y/focus-trap/focus-trap.js +1 -1
  97. package/esm5/a11y/high-contrast-mode/high-contrast-mode-detector.js +7 -4
  98. package/esm5/a11y/live-announcer/live-announcer.js +1 -1
  99. package/esm5/bidi/directionality.js +1 -1
  100. package/esm5/clipboard/pending-copy.js +2 -2
  101. package/esm5/coercion/array.js +1 -2
  102. package/esm5/drag-drop/client-rect.js +60 -0
  103. package/esm5/drag-drop/directives/config.js +1 -1
  104. package/esm5/drag-drop/directives/drag.js +3 -2
  105. package/esm5/drag-drop/directives/drop-list.js +13 -10
  106. package/esm5/drag-drop/drag-drop.js +1 -1
  107. package/esm5/drag-drop/drag-ref.js +39 -21
  108. package/esm5/drag-drop/drop-list-ref.js +13 -67
  109. package/esm5/layout/breakpoints-observer.js +1 -1
  110. package/esm5/overlay/position/flexible-connected-position-strategy.js +3 -2
  111. package/esm5/overlay/position/overlay-position-builder.js +1 -1
  112. package/esm5/platform/features/shadow-dom.js +11 -1
  113. package/esm5/scrolling/scroll-dispatcher.js +21 -5
  114. package/esm5/scrolling/viewport-ruler.js +24 -5
  115. package/esm5/table/cell.js +13 -8
  116. package/esm5/table/public-api.js +2 -1
  117. package/esm5/table/row.js +21 -11
  118. package/esm5/table/table.js +16 -11
  119. package/esm5/table/text-column.js +3 -4
  120. package/esm5/table/tokens.js +16 -0
  121. package/esm5/testing/protractor/protractor-harness-environment.js +17 -11
  122. package/esm5/testing/testbed/testbed-harness-environment.js +17 -11
  123. package/esm5/text-field/autosize.js +20 -4
  124. package/esm5/tree/padding.js +9 -5
  125. package/esm5/version.js +1 -1
  126. package/fesm2015/a11y.js +190 -103
  127. package/fesm2015/a11y.js.map +1 -1
  128. package/fesm2015/cdk.js +1 -1
  129. package/fesm2015/cdk.js.map +1 -1
  130. package/fesm2015/clipboard.js +2 -2
  131. package/fesm2015/clipboard.js.map +1 -1
  132. package/fesm2015/coercion.js +0 -1
  133. package/fesm2015/coercion.js.map +1 -1
  134. package/fesm2015/drag-drop.js +174 -123
  135. package/fesm2015/drag-drop.js.map +1 -1
  136. package/fesm2015/overlay.js +2 -1
  137. package/fesm2015/overlay.js.map +1 -1
  138. package/fesm2015/platform.js +16 -1
  139. package/fesm2015/platform.js.map +1 -1
  140. package/fesm2015/scrolling.js +76 -7
  141. package/fesm2015/scrolling.js.map +1 -1
  142. package/fesm2015/table.js +98 -49
  143. package/fesm2015/table.js.map +1 -1
  144. package/fesm2015/testing/protractor.js +13 -8
  145. package/fesm2015/testing/protractor.js.map +1 -1
  146. package/fesm2015/testing/testbed.js +15 -9
  147. package/fesm2015/testing/testbed.js.map +1 -1
  148. package/fesm2015/text-field.js +37 -3
  149. package/fesm2015/text-field.js.map +1 -1
  150. package/fesm2015/tree.js +8 -9
  151. package/fesm2015/tree.js.map +1 -1
  152. package/fesm5/a11y.js +107 -76
  153. package/fesm5/a11y.js.map +1 -1
  154. package/fesm5/cdk.js +1 -1
  155. package/fesm5/cdk.js.map +1 -1
  156. package/fesm5/clipboard.js +1 -1
  157. package/fesm5/clipboard.js.map +1 -1
  158. package/fesm5/coercion.js +0 -1
  159. package/fesm5/coercion.js.map +1 -1
  160. package/fesm5/drag-drop.js +122 -96
  161. package/fesm5/drag-drop.js.map +1 -1
  162. package/fesm5/overlay.js +2 -1
  163. package/fesm5/overlay.js.map +1 -1
  164. package/fesm5/platform.js +11 -1
  165. package/fesm5/platform.js.map +1 -1
  166. package/fesm5/scrolling.js +39 -7
  167. package/fesm5/scrolling.js.map +1 -1
  168. package/fesm5/table.js +59 -29
  169. package/fesm5/table.js.map +1 -1
  170. package/fesm5/testing/protractor.js +17 -11
  171. package/fesm5/testing/protractor.js.map +1 -1
  172. package/fesm5/testing/testbed.js +16 -10
  173. package/fesm5/testing/testbed.js.map +1 -1
  174. package/fesm5/text-field.js +19 -3
  175. package/fesm5/text-field.js.map +1 -1
  176. package/fesm5/tree.js +8 -4
  177. package/fesm5/tree.js.map +1 -1
  178. package/package.json +1 -1
  179. package/platform/features/shadow-dom.d.ts +2 -0
  180. package/platform/index.metadata.json +1 -1
  181. package/schematics/ng-add/index.js +1 -1
  182. package/schematics/ng-update/upgrade-rules/class-names-rule.js +3 -1
  183. package/schematics/utils/ast/ng-module-imports.js +3 -2
  184. package/scrolling/index.metadata.json +1 -1
  185. package/scrolling/scroll-dispatcher.d.ts +9 -1
  186. package/scrolling/viewport-ruler.d.ts +9 -1
  187. package/table/cell.d.ts +2 -0
  188. package/table/index.metadata.json +1 -1
  189. package/table/public-api.d.ts +1 -0
  190. package/table/row.d.ts +6 -3
  191. package/table/table.d.ts +2 -0
  192. package/table/text-column.d.ts +2 -13
  193. package/table/tokens.d.ts +25 -0
  194. package/testing/protractor/protractor-harness-environment.d.ts +10 -3
  195. package/testing/testbed/testbed-harness-environment.d.ts +12 -4
  196. package/text-field/autosize.d.ts +9 -1
  197. package/text-field/index.metadata.json +1 -1
  198. package/tree/index.metadata.json +1 -1
  199. package/tree/padding.d.ts +6 -2
package/fesm5/a11y.js CHANGED
@@ -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.
@@ -1698,6 +1716,8 @@ var CdkAriaLive = /** @class */ (function () {
1698
1716
  // This is the value used by AngularJS Material. Through trial and error (on iPhone 6S) they found
1699
1717
  // that a value of around 650ms seems appropriate.
1700
1718
  var TOUCH_BUFFER_MS = 650;
1719
+ /** InjectionToken for FocusMonitorOptions. */
1720
+ var FOCUS_MONITOR_DEFAULT_OPTIONS = new InjectionToken('cdk-focus-monitor-default-options');
1701
1721
  /**
1702
1722
  * Event listener options that enable capturing and also
1703
1723
  * mark the listener as passive if the browser supports it.
@@ -1708,7 +1728,9 @@ var captureEventListenerOptions = normalizePassiveListenerOptions({
1708
1728
  });
1709
1729
  /** Monitors mouse and keyboard events to determine the cause of focus events. */
1710
1730
  var FocusMonitor = /** @class */ (function () {
1711
- function FocusMonitor(_ngZone, _platform) {
1731
+ function FocusMonitor(_ngZone, _platform,
1732
+ /** @breaking-change 11.0.0 make document required */
1733
+ document, options) {
1712
1734
  var _this = this;
1713
1735
  this._ngZone = _ngZone;
1714
1736
  this._platform = _platform;
@@ -1733,11 +1755,14 @@ var FocusMonitor = /** @class */ (function () {
1733
1755
  * Event listener for `mousedown` events on the document.
1734
1756
  * Needs to be an arrow function in order to preserve the context when it gets bound.
1735
1757
  */
1736
- this._documentMousedownListener = function () {
1758
+ this._documentMousedownListener = function (event) {
1737
1759
  // On mousedown record the origin only if there is not touch
1738
1760
  // target, since a mousedown can happen as a result of a touch event.
1739
1761
  if (!_this._lastTouchTarget) {
1740
- _this._setOriginForCurrentEventQueue('mouse');
1762
+ // In some cases screen readers fire fake `mousedown` events instead of `keydown`.
1763
+ // Resolve the focus source to `keyboard` if we detect one of them.
1764
+ var source = isFakeMousedownFromScreenReader(event) ? 'keyboard' : 'mouse';
1765
+ _this._setOriginForCurrentEventQueue(source);
1741
1766
  }
1742
1767
  };
1743
1768
  /**
@@ -1767,9 +1792,22 @@ var FocusMonitor = /** @class */ (function () {
1767
1792
  _this._windowFocused = true;
1768
1793
  _this._windowFocusTimeoutId = setTimeout(function () { return _this._windowFocused = false; });
1769
1794
  };
1795
+ /**
1796
+ * Event listener for `focus` and 'blur' events on the document.
1797
+ * Needs to be an arrow function in order to preserve the context when it gets bound.
1798
+ */
1799
+ this._documentFocusAndBlurListener = function (event) {
1800
+ var target = event.target;
1801
+ var handler = event.type === 'focus' ? _this._onFocus : _this._onBlur;
1802
+ // We need to walk up the ancestor chain in order to support `checkChildren`.
1803
+ for (var el = target; el; el = el.parentElement) {
1804
+ handler.call(_this, event, el);
1805
+ }
1806
+ };
1807
+ this._document = document;
1808
+ this._detectionMode = (options === null || options === void 0 ? void 0 : options.detectionMode) || 0 /* IMMEDIATE */;
1770
1809
  }
1771
1810
  FocusMonitor.prototype.monitor = function (element, checkChildren) {
1772
- var _this = this;
1773
1811
  if (checkChildren === void 0) { checkChildren = false; }
1774
1812
  // Do nothing if we're not on the browser platform.
1775
1813
  if (!this._platform.isBrowser) {
@@ -1784,31 +1822,17 @@ var FocusMonitor = /** @class */ (function () {
1784
1822
  }
1785
1823
  // Create monitored element info.
1786
1824
  var info = {
1787
- unlisten: function () { },
1788
1825
  checkChildren: checkChildren,
1789
1826
  subject: new Subject()
1790
1827
  };
1791
1828
  this._elementInfo.set(nativeElement, info);
1792
1829
  this._incrementMonitoredElementCount();
1793
- // Start listening. We need to listen in capture phase since focus events don't bubble.
1794
- var focusListener = function (event) { return _this._onFocus(event, nativeElement); };
1795
- var blurListener = function (event) { return _this._onBlur(event, nativeElement); };
1796
- this._ngZone.runOutsideAngular(function () {
1797
- nativeElement.addEventListener('focus', focusListener, true);
1798
- nativeElement.addEventListener('blur', blurListener, true);
1799
- });
1800
- // Create an unlisten function for later.
1801
- info.unlisten = function () {
1802
- nativeElement.removeEventListener('focus', focusListener, true);
1803
- nativeElement.removeEventListener('blur', blurListener, true);
1804
- };
1805
1830
  return info.subject.asObservable();
1806
1831
  };
1807
1832
  FocusMonitor.prototype.stopMonitoring = function (element) {
1808
1833
  var nativeElement = coerceElement(element);
1809
1834
  var elementInfo = this._elementInfo.get(nativeElement);
1810
1835
  if (elementInfo) {
1811
- elementInfo.unlisten();
1812
1836
  elementInfo.subject.complete();
1813
1837
  this._setClasses(nativeElement);
1814
1838
  this._elementInfo.delete(nativeElement);
@@ -1828,6 +1852,15 @@ var FocusMonitor = /** @class */ (function () {
1828
1852
  var _this = this;
1829
1853
  this._elementInfo.forEach(function (_info, element) { return _this.stopMonitoring(element); });
1830
1854
  };
1855
+ /** Access injected document if available or fallback to global document reference */
1856
+ FocusMonitor.prototype._getDocument = function () {
1857
+ return this._document || document;
1858
+ };
1859
+ /** Use defaultView of injected document if available or fallback to global window reference */
1860
+ FocusMonitor.prototype._getWindow = function () {
1861
+ var doc = this._getDocument();
1862
+ return doc.defaultView || window;
1863
+ };
1831
1864
  FocusMonitor.prototype._toggleClass = function (element, className, shouldSet) {
1832
1865
  if (shouldSet) {
1833
1866
  element.classList.add(className);
@@ -1836,33 +1869,53 @@ var FocusMonitor = /** @class */ (function () {
1836
1869
  element.classList.remove(className);
1837
1870
  }
1838
1871
  };
1872
+ FocusMonitor.prototype._getFocusOrigin = function (event) {
1873
+ // If we couldn't detect a cause for the focus event, it's due to one of three reasons:
1874
+ // 1) The window has just regained focus, in which case we want to restore the focused state of
1875
+ // the element from before the window blurred.
1876
+ // 2) It was caused by a touch event, in which case we mark the origin as 'touch'.
1877
+ // 3) The element was programmatically focused, in which case we should mark the origin as
1878
+ // 'program'.
1879
+ if (this._origin) {
1880
+ return this._origin;
1881
+ }
1882
+ if (this._windowFocused && this._lastFocusOrigin) {
1883
+ return this._lastFocusOrigin;
1884
+ }
1885
+ else if (this._wasCausedByTouch(event)) {
1886
+ return 'touch';
1887
+ }
1888
+ else {
1889
+ return 'program';
1890
+ }
1891
+ };
1839
1892
  /**
1840
1893
  * Sets the focus classes on the element based on the given focus origin.
1841
1894
  * @param element The element to update the classes on.
1842
1895
  * @param origin The focus origin.
1843
1896
  */
1844
1897
  FocusMonitor.prototype._setClasses = function (element, origin) {
1845
- var elementInfo = this._elementInfo.get(element);
1846
- if (elementInfo) {
1847
- this._toggleClass(element, 'cdk-focused', !!origin);
1848
- this._toggleClass(element, 'cdk-touch-focused', origin === 'touch');
1849
- this._toggleClass(element, 'cdk-keyboard-focused', origin === 'keyboard');
1850
- this._toggleClass(element, 'cdk-mouse-focused', origin === 'mouse');
1851
- this._toggleClass(element, 'cdk-program-focused', origin === 'program');
1852
- }
1898
+ this._toggleClass(element, 'cdk-focused', !!origin);
1899
+ this._toggleClass(element, 'cdk-touch-focused', origin === 'touch');
1900
+ this._toggleClass(element, 'cdk-keyboard-focused', origin === 'keyboard');
1901
+ this._toggleClass(element, 'cdk-mouse-focused', origin === 'mouse');
1902
+ this._toggleClass(element, 'cdk-program-focused', origin === 'program');
1853
1903
  };
1854
1904
  /**
1855
1905
  * Sets the origin and schedules an async function to clear it at the end of the event queue.
1906
+ * If the detection mode is 'eventual', the origin is never cleared.
1856
1907
  * @param origin The origin to set.
1857
1908
  */
1858
1909
  FocusMonitor.prototype._setOriginForCurrentEventQueue = function (origin) {
1859
1910
  var _this = this;
1860
1911
  this._ngZone.runOutsideAngular(function () {
1861
1912
  _this._origin = origin;
1862
- // Sometimes the focus origin won't be valid in Firefox because Firefox seems to focus *one*
1863
- // tick after the interaction event fired. To ensure the focus origin is always correct,
1864
- // the focus origin will be determined at the beginning of the next tick.
1865
- _this._originTimeoutId = setTimeout(function () { return _this._origin = null; }, 1);
1913
+ if (_this._detectionMode === 0 /* IMMEDIATE */) {
1914
+ // Sometimes the focus origin won't be valid in Firefox because Firefox seems to focus *one*
1915
+ // tick after the interaction event fired. To ensure the focus origin is always correct,
1916
+ // the focus origin will be determined at the beginning of the next tick.
1917
+ _this._originTimeoutId = setTimeout(function () { return _this._origin = null; }, 1);
1918
+ }
1866
1919
  });
1867
1920
  };
1868
1921
  /**
@@ -1908,24 +1961,7 @@ var FocusMonitor = /** @class */ (function () {
1908
1961
  if (!elementInfo || (!elementInfo.checkChildren && element !== event.target)) {
1909
1962
  return;
1910
1963
  }
1911
- // If we couldn't detect a cause for the focus event, it's due to one of three reasons:
1912
- // 1) The window has just regained focus, in which case we want to restore the focused state of
1913
- // the element from before the window blurred.
1914
- // 2) It was caused by a touch event, in which case we mark the origin as 'touch'.
1915
- // 3) The element was programmatically focused, in which case we should mark the origin as
1916
- // 'program'.
1917
- var origin = this._origin;
1918
- if (!origin) {
1919
- if (this._windowFocused && this._lastFocusOrigin) {
1920
- origin = this._lastFocusOrigin;
1921
- }
1922
- else if (this._wasCausedByTouch(event)) {
1923
- origin = 'touch';
1924
- }
1925
- else {
1926
- origin = 'program';
1927
- }
1928
- }
1964
+ var origin = this._getFocusOrigin(event);
1929
1965
  this._setClasses(element, origin);
1930
1966
  this._emitOrigin(elementInfo.subject, origin);
1931
1967
  this._lastFocusOrigin = origin;
@@ -1956,6 +1992,10 @@ var FocusMonitor = /** @class */ (function () {
1956
1992
  // Note: we listen to events in the capture phase so we
1957
1993
  // can detect them even if the user stops propagation.
1958
1994
  this._ngZone.runOutsideAngular(function () {
1995
+ var document = _this._getDocument();
1996
+ var window = _this._getWindow();
1997
+ document.addEventListener('focus', _this._documentFocusAndBlurListener, captureEventListenerOptions);
1998
+ document.addEventListener('blur', _this._documentFocusAndBlurListener, captureEventListenerOptions);
1959
1999
  document.addEventListener('keydown', _this._documentKeydownListener, captureEventListenerOptions);
1960
2000
  document.addEventListener('mousedown', _this._documentMousedownListener, captureEventListenerOptions);
1961
2001
  document.addEventListener('touchstart', _this._documentTouchstartListener, captureEventListenerOptions);
@@ -1966,10 +2006,14 @@ var FocusMonitor = /** @class */ (function () {
1966
2006
  FocusMonitor.prototype._decrementMonitoredElementCount = function () {
1967
2007
  // Unregister global listeners when last element is unmonitored.
1968
2008
  if (!--this._monitoredElementCount) {
1969
- document.removeEventListener('keydown', this._documentKeydownListener, captureEventListenerOptions);
1970
- document.removeEventListener('mousedown', this._documentMousedownListener, captureEventListenerOptions);
1971
- document.removeEventListener('touchstart', this._documentTouchstartListener, captureEventListenerOptions);
1972
- window.removeEventListener('focus', this._windowFocusListener);
2009
+ var document_1 = this._getDocument();
2010
+ var window_1 = this._getWindow();
2011
+ document_1.removeEventListener('focus', this._documentFocusAndBlurListener, captureEventListenerOptions);
2012
+ document_1.removeEventListener('blur', this._documentFocusAndBlurListener, captureEventListenerOptions);
2013
+ document_1.removeEventListener('keydown', this._documentKeydownListener, captureEventListenerOptions);
2014
+ document_1.removeEventListener('mousedown', this._documentMousedownListener, captureEventListenerOptions);
2015
+ document_1.removeEventListener('touchstart', this._documentTouchstartListener, captureEventListenerOptions);
2016
+ window_1.removeEventListener('focus', this._windowFocusListener);
1973
2017
  // Clear timeouts for all potentially pending timeouts to prevent the leaks.
1974
2018
  clearTimeout(this._windowFocusTimeoutId);
1975
2019
  clearTimeout(this._touchTimeoutId);
@@ -1982,9 +2026,11 @@ var FocusMonitor = /** @class */ (function () {
1982
2026
  /** @nocollapse */
1983
2027
  FocusMonitor.ctorParameters = function () { return [
1984
2028
  { type: NgZone },
1985
- { type: Platform }
2029
+ { type: Platform },
2030
+ { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [DOCUMENT,] }] },
2031
+ { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [FOCUS_MONITOR_DEFAULT_OPTIONS,] }] }
1986
2032
  ]; };
1987
- FocusMonitor.ɵprov = ɵɵdefineInjectable({ factory: function FocusMonitor_Factory() { return new FocusMonitor(ɵɵinject(NgZone), ɵɵinject(Platform)); }, token: FocusMonitor, providedIn: "root" });
2033
+ 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" });
1988
2034
  return FocusMonitor;
1989
2035
  }());
1990
2036
  /**
@@ -2025,24 +2071,6 @@ var CdkMonitorFocus = /** @class */ (function () {
2025
2071
  return CdkMonitorFocus;
2026
2072
  }());
2027
2073
 
2028
- /**
2029
- * @license
2030
- * Copyright Google LLC All Rights Reserved.
2031
- *
2032
- * Use of this source code is governed by an MIT-style license that can be
2033
- * found in the LICENSE file at https://angular.io/license
2034
- */
2035
- /**
2036
- * Screenreaders will often fire fake mousedown events when a focusable element
2037
- * is activated using the keyboard. We can typically distinguish between these faked
2038
- * mousedown events and real mousedown events using the "buttons" property. While
2039
- * real mousedowns will indicate the mouse button that was pressed (e.g. "1" for
2040
- * the left mouse button), faked mousedowns will usually set the property value to 0.
2041
- */
2042
- function isFakeMousedownFromScreenReader(event) {
2043
- return event.buttons === 0;
2044
- }
2045
-
2046
2074
  /**
2047
2075
  * @license
2048
2076
  * Copyright Google LLC All Rights Reserved.
@@ -2086,9 +2114,12 @@ var HighContrastModeDetector = /** @class */ (function () {
2086
2114
  this._document.body.appendChild(testElement);
2087
2115
  // Get the computed style for the background color, collapsing spaces to normalize between
2088
2116
  // browsers. Once we get this color, we no longer need the test element. Access the `window`
2089
- // via the document so we can fake it in tests.
2090
- var documentWindow = this._document.defaultView;
2091
- var computedColor = (documentWindow.getComputedStyle(testElement).backgroundColor || '').replace(/ /g, '');
2117
+ // via the document so we can fake it in tests. Note that we have extra null checks, because
2118
+ // this logic will likely run during app bootstrap and throwing can break the entire app.
2119
+ var documentWindow = this._document.defaultView || window;
2120
+ var computedStyle = (documentWindow && documentWindow.getComputedStyle) ?
2121
+ documentWindow.getComputedStyle(testElement) : null;
2122
+ var computedColor = (computedStyle && computedStyle.backgroundColor || '').replace(/ /g, '');
2092
2123
  this._document.body.removeChild(testElement);
2093
2124
  switch (computedColor) {
2094
2125
  case 'rgb(0,0,0)': return 2 /* WHITE_ON_BLACK */;
@@ -2164,5 +2195,5 @@ var A11yModule = /** @class */ (function () {
2164
2195
  * Generated bundle index. Do not edit.
2165
2196
  */
2166
2197
 
2167
- export { A11yModule, ActiveDescendantKeyManager, AriaDescriber, CDK_DESCRIBEDBY_HOST_ATTRIBUTE, CDK_DESCRIBEDBY_ID_PREFIX, CdkAriaLive, CdkMonitorFocus, CdkTrapFocus, ConfigurableFocusTrap, ConfigurableFocusTrapFactory, EventListenerFocusTrapInertStrategy, FOCUS_TRAP_INERT_STRATEGY, FocusKeyManager, FocusMonitor, FocusTrap, FocusTrapFactory, HighContrastModeDetector, InteractivityChecker, LIVE_ANNOUNCER_DEFAULT_OPTIONS, LIVE_ANNOUNCER_ELEMENT_TOKEN, LIVE_ANNOUNCER_ELEMENT_TOKEN_FACTORY, ListKeyManager, LiveAnnouncer, MESSAGES_CONTAINER_ID, TOUCH_BUFFER_MS, isFakeMousedownFromScreenReader, FocusTrapManager as ɵangular_material_src_cdk_a11y_a11y_a, ConfigurableFocusTrapConfig as ɵangular_material_src_cdk_a11y_a11y_b };
2198
+ export { A11yModule, ActiveDescendantKeyManager, AriaDescriber, CDK_DESCRIBEDBY_HOST_ATTRIBUTE, CDK_DESCRIBEDBY_ID_PREFIX, CdkAriaLive, CdkMonitorFocus, CdkTrapFocus, ConfigurableFocusTrap, ConfigurableFocusTrapFactory, EventListenerFocusTrapInertStrategy, FOCUS_MONITOR_DEFAULT_OPTIONS, FOCUS_TRAP_INERT_STRATEGY, FocusKeyManager, FocusMonitor, FocusTrap, FocusTrapFactory, HighContrastModeDetector, InteractivityChecker, LIVE_ANNOUNCER_DEFAULT_OPTIONS, LIVE_ANNOUNCER_ELEMENT_TOKEN, LIVE_ANNOUNCER_ELEMENT_TOKEN_FACTORY, ListKeyManager, LiveAnnouncer, MESSAGES_CONTAINER_ID, TOUCH_BUFFER_MS, isFakeMousedownFromScreenReader, FocusTrapManager as ɵangular_material_src_cdk_a11y_a11y_a, ConfigurableFocusTrapConfig as ɵangular_material_src_cdk_a11y_a11y_b };
2168
2199
  //# sourceMappingURL=a11y.js.map