@angular/cdk 7.1.0 → 7.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.
Files changed (267) hide show
  1. package/LICENSE +1 -1
  2. package/_a11y.scss +1 -1
  3. package/a11y/typings/focus-monitor/focus-monitor.d.ts +20 -5
  4. package/a11y/typings/focus-trap/focus-trap.d.ts +2 -0
  5. package/a11y/typings/index.metadata.json +1 -1
  6. package/bundles/cdk-a11y.umd.js +428 -197
  7. package/bundles/cdk-a11y.umd.js.map +1 -1
  8. package/bundles/cdk-a11y.umd.min.js +1 -1
  9. package/bundles/cdk-a11y.umd.min.js.map +1 -1
  10. package/bundles/cdk-accordion.umd.js +16 -9
  11. package/bundles/cdk-accordion.umd.js.map +1 -1
  12. package/bundles/cdk-accordion.umd.min.js.map +1 -1
  13. package/bundles/cdk-bidi.umd.js +11 -6
  14. package/bundles/cdk-bidi.umd.js.map +1 -1
  15. package/bundles/cdk-bidi.umd.min.js.map +1 -1
  16. package/bundles/cdk-coercion.umd.js +25 -9
  17. package/bundles/cdk-coercion.umd.js.map +1 -1
  18. package/bundles/cdk-coercion.umd.min.js +1 -1
  19. package/bundles/cdk-coercion.umd.min.js.map +1 -1
  20. package/bundles/cdk-collections.umd.js +28 -5
  21. package/bundles/cdk-collections.umd.js.map +1 -1
  22. package/bundles/cdk-collections.umd.min.js.map +1 -1
  23. package/bundles/cdk-drag-drop.umd.js +2297 -973
  24. package/bundles/cdk-drag-drop.umd.js.map +1 -1
  25. package/bundles/cdk-drag-drop.umd.min.js +2 -1
  26. package/bundles/cdk-drag-drop.umd.min.js.map +1 -1
  27. package/bundles/cdk-keycodes.umd.js +12 -2
  28. package/bundles/cdk-keycodes.umd.js.map +1 -1
  29. package/bundles/cdk-layout.umd.js +29 -22
  30. package/bundles/cdk-layout.umd.js.map +1 -1
  31. package/bundles/cdk-layout.umd.min.js +1 -1
  32. package/bundles/cdk-layout.umd.min.js.map +1 -1
  33. package/bundles/cdk-observers.umd.js +27 -8
  34. package/bundles/cdk-observers.umd.js.map +1 -1
  35. package/bundles/cdk-observers.umd.min.js +1 -1
  36. package/bundles/cdk-observers.umd.min.js.map +1 -1
  37. package/bundles/cdk-overlay.umd.js +586 -240
  38. package/bundles/cdk-overlay.umd.js.map +1 -1
  39. package/bundles/cdk-overlay.umd.min.js +2 -2
  40. package/bundles/cdk-overlay.umd.min.js.map +1 -1
  41. package/bundles/cdk-platform.umd.js +50 -28
  42. package/bundles/cdk-platform.umd.js.map +1 -1
  43. package/bundles/cdk-platform.umd.min.js.map +1 -1
  44. package/bundles/cdk-portal.umd.js +17 -10
  45. package/bundles/cdk-portal.umd.js.map +1 -1
  46. package/bundles/cdk-portal.umd.min.js.map +1 -1
  47. package/bundles/cdk-scrolling.umd.js +148 -50
  48. package/bundles/cdk-scrolling.umd.js.map +1 -1
  49. package/bundles/cdk-scrolling.umd.min.js +1 -1
  50. package/bundles/cdk-scrolling.umd.min.js.map +1 -1
  51. package/bundles/cdk-stepper.umd.js +69 -27
  52. package/bundles/cdk-stepper.umd.js.map +1 -1
  53. package/bundles/cdk-stepper.umd.min.js +1 -1
  54. package/bundles/cdk-stepper.umd.min.js.map +1 -1
  55. package/bundles/cdk-table.umd.js +189 -51
  56. package/bundles/cdk-table.umd.js.map +1 -1
  57. package/bundles/cdk-table.umd.min.js +1 -1
  58. package/bundles/cdk-table.umd.min.js.map +1 -1
  59. package/bundles/cdk-text-field.umd.js +76 -38
  60. package/bundles/cdk-text-field.umd.js.map +1 -1
  61. package/bundles/cdk-text-field.umd.min.js +1 -1
  62. package/bundles/cdk-text-field.umd.min.js.map +1 -1
  63. package/bundles/cdk-tree.umd.js +71 -34
  64. package/bundles/cdk-tree.umd.js.map +1 -1
  65. package/bundles/cdk-tree.umd.min.js +1 -1
  66. package/bundles/cdk-tree.umd.min.js.map +1 -1
  67. package/bundles/cdk.umd.js +5 -4
  68. package/bundles/cdk.umd.js.map +1 -1
  69. package/bundles/cdk.umd.min.js +1 -1
  70. package/bundles/cdk.umd.min.js.map +1 -1
  71. package/coercion/typings/element.d.ts +13 -0
  72. package/coercion/typings/index.metadata.json +1 -1
  73. package/coercion/typings/public-api.d.ts +1 -0
  74. package/drag-drop/typings/{drag-handle.d.ts → directives/drag-handle.d.ts} +6 -2
  75. package/drag-drop/typings/{drag-placeholder.d.ts → directives/drag-placeholder.d.ts} +0 -0
  76. package/drag-drop/typings/{drag-preview.d.ts → directives/drag-preview.d.ts} +0 -0
  77. package/drag-drop/typings/directives/drag.d.ts +110 -0
  78. package/{typings/esm5/drag-drop → drag-drop/typings/directives}/drop-list-group.d.ts +3 -0
  79. package/drag-drop/typings/{drop-list.d.ts → directives/drop-list.d.ts} +32 -72
  80. package/drag-drop/typings/drag-drop-registry.d.ts +8 -3
  81. package/drag-drop/typings/drag-events.d.ts +14 -7
  82. package/{typings/esm5/drag-drop/drag.d.ts → drag-drop/typings/drag-ref.d.ts} +152 -83
  83. package/drag-drop/typings/drop-list-container.d.ts +19 -3
  84. package/drag-drop/typings/drop-list-ref.d.ts +234 -0
  85. package/drag-drop/typings/index.d.ts +1 -0
  86. package/drag-drop/typings/index.metadata.json +1 -1
  87. package/drag-drop/typings/public-api.d.ts +13 -6
  88. package/esm2015/a11y.js +306 -182
  89. package/esm2015/a11y.js.map +1 -1
  90. package/esm2015/accordion.js +16 -11
  91. package/esm2015/accordion.js.map +1 -1
  92. package/esm2015/bidi.js +13 -8
  93. package/esm2015/bidi.js.map +1 -1
  94. package/esm2015/cdk.js +7 -6
  95. package/esm2015/cdk.js.map +1 -1
  96. package/esm2015/coercion.js +25 -8
  97. package/esm2015/coercion.js.map +1 -1
  98. package/esm2015/collections.js +22 -7
  99. package/esm2015/collections.js.map +1 -1
  100. package/esm2015/drag-drop.js +1774 -864
  101. package/esm2015/drag-drop.js.map +1 -1
  102. package/esm2015/keycodes.js +14 -4
  103. package/esm2015/keycodes.js.map +1 -1
  104. package/esm2015/layout.js +29 -19
  105. package/esm2015/layout.js.map +1 -1
  106. package/esm2015/observers.js +16 -11
  107. package/esm2015/observers.js.map +1 -1
  108. package/esm2015/overlay.js +373 -213
  109. package/esm2015/overlay.js.map +1 -1
  110. package/esm2015/platform.js +53 -31
  111. package/esm2015/platform.js.map +1 -1
  112. package/esm2015/portal.js +14 -10
  113. package/esm2015/portal.js.map +1 -1
  114. package/esm2015/scrolling.js +111 -51
  115. package/esm2015/scrolling.js.map +1 -1
  116. package/esm2015/stepper.js +56 -30
  117. package/esm2015/stepper.js.map +1 -1
  118. package/esm2015/table.js +96 -48
  119. package/esm2015/table.js.map +1 -1
  120. package/esm2015/text-field.js +54 -37
  121. package/esm2015/text-field.js.map +1 -1
  122. package/esm2015/tree.js +55 -36
  123. package/esm2015/tree.js.map +1 -1
  124. package/esm5/a11y.es5.js +432 -201
  125. package/esm5/a11y.es5.js.map +1 -1
  126. package/esm5/accordion.es5.js +18 -11
  127. package/esm5/accordion.es5.js.map +1 -1
  128. package/esm5/bidi.es5.js +13 -8
  129. package/esm5/bidi.es5.js.map +1 -1
  130. package/esm5/cdk.es5.js +7 -6
  131. package/esm5/cdk.es5.js.map +1 -1
  132. package/esm5/coercion.es5.js +25 -8
  133. package/esm5/coercion.es5.js.map +1 -1
  134. package/esm5/collections.es5.js +35 -7
  135. package/esm5/collections.es5.js.map +1 -1
  136. package/esm5/drag-drop.es5.js +2358 -1035
  137. package/esm5/drag-drop.es5.js.map +1 -1
  138. package/esm5/keycodes.es5.js +14 -4
  139. package/esm5/keycodes.es5.js.map +1 -1
  140. package/esm5/layout.es5.js +31 -24
  141. package/esm5/layout.es5.js.map +1 -1
  142. package/esm5/observers.es5.js +30 -11
  143. package/esm5/observers.es5.js.map +1 -1
  144. package/esm5/overlay.es5.js +590 -244
  145. package/esm5/overlay.es5.js.map +1 -1
  146. package/esm5/platform.es5.js +52 -30
  147. package/esm5/platform.es5.js.map +1 -1
  148. package/esm5/portal.es5.js +19 -12
  149. package/esm5/portal.es5.js.map +1 -1
  150. package/esm5/scrolling.es5.js +150 -52
  151. package/esm5/scrolling.es5.js.map +1 -1
  152. package/esm5/stepper.es5.js +71 -30
  153. package/esm5/stepper.es5.js.map +1 -1
  154. package/esm5/table.es5.js +191 -53
  155. package/esm5/table.es5.js.map +1 -1
  156. package/esm5/text-field.es5.js +75 -37
  157. package/esm5/text-field.es5.js.map +1 -1
  158. package/esm5/tree.es5.js +74 -37
  159. package/esm5/tree.es5.js.map +1 -1
  160. package/overlay/typings/index.metadata.json +1 -1
  161. package/overlay/typings/overlay-directives.d.ts +0 -2
  162. package/overlay/typings/overlay-ref.d.ts +1 -1
  163. package/package.json +4 -4
  164. package/portal/typings/portal.d.ts +1 -1
  165. package/schematics/migration.json +5 -0
  166. package/schematics/ng-generate/drag-drop/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.ts +2 -2
  167. package/schematics/ng-update/index.d.ts +2 -0
  168. package/schematics/ng-update/index.js +5 -0
  169. package/schematics/ng-update/index.js.map +1 -1
  170. package/schematics/ng-update/target-version.d.ts +7 -1
  171. package/schematics/ng-update/target-version.js +10 -0
  172. package/schematics/ng-update/target-version.js.map +1 -1
  173. package/schematics/ng-update/upgrade-data.js +2 -1
  174. package/schematics/ng-update/upgrade-data.js.map +1 -1
  175. package/schematics/ng-update/upgrade-rules/index.js +3 -2
  176. package/schematics/ng-update/upgrade-rules/index.js.map +1 -1
  177. package/schematics/utils/ast/ng-module-imports.d.ts +1 -1
  178. package/schematics/utils/ast/ng-module-imports.js +25 -13
  179. package/schematics/utils/ast/ng-module-imports.js.map +1 -1
  180. package/schematics/utils/get-project.js +2 -1
  181. package/schematics/utils/get-project.js.map +1 -1
  182. package/schematics/utils/parse5-element.js +3 -2
  183. package/schematics/utils/parse5-element.js.map +1 -1
  184. package/schematics/utils/project-targets.js +2 -1
  185. package/schematics/utils/project-targets.js.map +1 -1
  186. package/schematics/utils/version-agnostic-typescript.js +3 -2
  187. package/schematics/utils/version-agnostic-typescript.js.map +1 -1
  188. package/scrolling/typings/index.metadata.json +1 -1
  189. package/stepper/typings/index.metadata.json +1 -1
  190. package/stepper/typings/stepper.d.ts +13 -1
  191. package/text-field/typings/autosize.d.ts +6 -0
  192. package/text-field/typings/index.metadata.json +1 -1
  193. package/tree/typings/control/base-tree-control.d.ts +1 -1
  194. package/tree/typings/control/nested-tree-control.d.ts +2 -2
  195. package/tree/typings/control/tree-control.d.ts +1 -1
  196. package/tree/typings/nested-node.d.ts +5 -5
  197. package/typings/a11y/focus-monitor/focus-monitor.d.ts +20 -5
  198. package/typings/a11y/focus-trap/focus-trap.d.ts +2 -0
  199. package/typings/a11y/index.metadata.json +1 -1
  200. package/typings/coercion/element.d.ts +13 -0
  201. package/typings/coercion/index.metadata.json +1 -1
  202. package/typings/coercion/public-api.d.ts +1 -0
  203. package/typings/drag-drop/{drag-handle.d.ts → directives/drag-handle.d.ts} +6 -2
  204. package/typings/drag-drop/{drag-placeholder.d.ts → directives/drag-placeholder.d.ts} +0 -0
  205. package/typings/drag-drop/{drag-preview.d.ts → directives/drag-preview.d.ts} +0 -0
  206. package/typings/drag-drop/directives/drag.d.ts +110 -0
  207. package/typings/drag-drop/{drop-list-group.d.ts → directives/drop-list-group.d.ts} +3 -0
  208. package/typings/{esm5/drag-drop → drag-drop/directives}/drop-list.d.ts +32 -72
  209. package/typings/drag-drop/drag-drop-registry.d.ts +8 -3
  210. package/typings/drag-drop/drag-events.d.ts +14 -7
  211. package/typings/drag-drop/{drag.d.ts → drag-ref.d.ts} +152 -83
  212. package/typings/drag-drop/drop-list-container.d.ts +19 -3
  213. package/typings/drag-drop/drop-list-ref.d.ts +234 -0
  214. package/typings/drag-drop/index.d.ts +1 -0
  215. package/typings/drag-drop/index.metadata.json +1 -1
  216. package/typings/drag-drop/public-api.d.ts +13 -6
  217. package/typings/esm5/a11y/focus-monitor/focus-monitor.d.ts +20 -5
  218. package/typings/esm5/a11y/focus-trap/focus-trap.d.ts +2 -0
  219. package/typings/esm5/a11y/index.metadata.json +1 -1
  220. package/typings/esm5/coercion/element.d.ts +13 -0
  221. package/typings/esm5/coercion/index.metadata.json +1 -1
  222. package/typings/esm5/coercion/public-api.d.ts +1 -0
  223. package/typings/esm5/drag-drop/{drag-handle.d.ts → directives/drag-handle.d.ts} +6 -2
  224. package/typings/esm5/drag-drop/{drag-placeholder.d.ts → directives/drag-placeholder.d.ts} +0 -0
  225. package/typings/esm5/drag-drop/{drag-preview.d.ts → directives/drag-preview.d.ts} +0 -0
  226. package/typings/esm5/drag-drop/directives/drag.d.ts +110 -0
  227. package/{drag-drop/typings → typings/esm5/drag-drop/directives}/drop-list-group.d.ts +3 -0
  228. package/typings/{drag-drop → esm5/drag-drop/directives}/drop-list.d.ts +32 -72
  229. package/typings/esm5/drag-drop/drag-drop-registry.d.ts +8 -3
  230. package/typings/esm5/drag-drop/drag-events.d.ts +14 -7
  231. package/{drag-drop/typings/drag.d.ts → typings/esm5/drag-drop/drag-ref.d.ts} +152 -83
  232. package/typings/esm5/drag-drop/drop-list-container.d.ts +19 -3
  233. package/typings/esm5/drag-drop/drop-list-ref.d.ts +234 -0
  234. package/typings/esm5/drag-drop/index.d.ts +1 -0
  235. package/typings/esm5/drag-drop/index.metadata.json +1 -1
  236. package/typings/esm5/drag-drop/public-api.d.ts +13 -6
  237. package/typings/esm5/index.metadata.json +1 -1
  238. package/typings/esm5/overlay/index.metadata.json +1 -1
  239. package/typings/esm5/overlay/overlay-directives.d.ts +0 -2
  240. package/typings/esm5/overlay/overlay-ref.d.ts +1 -1
  241. package/typings/esm5/portal/portal.d.ts +1 -1
  242. package/typings/esm5/scrolling/index.metadata.json +1 -1
  243. package/typings/esm5/stepper/index.metadata.json +1 -1
  244. package/typings/esm5/stepper/stepper.d.ts +13 -1
  245. package/typings/esm5/text-field/autosize.d.ts +6 -0
  246. package/typings/esm5/text-field/index.metadata.json +1 -1
  247. package/typings/esm5/tree/control/base-tree-control.d.ts +1 -1
  248. package/typings/esm5/tree/control/nested-tree-control.d.ts +2 -2
  249. package/typings/esm5/tree/control/tree-control.d.ts +1 -1
  250. package/typings/esm5/tree/nested-node.d.ts +5 -5
  251. package/typings/index.metadata.json +1 -1
  252. package/typings/overlay/index.metadata.json +1 -1
  253. package/typings/overlay/overlay-directives.d.ts +0 -2
  254. package/typings/overlay/overlay-ref.d.ts +1 -1
  255. package/typings/portal/portal.d.ts +1 -1
  256. package/typings/schematics/ng-update/index.d.ts +2 -0
  257. package/typings/schematics/ng-update/target-version.d.ts +7 -1
  258. package/typings/schematics/utils/ast/ng-module-imports.d.ts +1 -1
  259. package/typings/scrolling/index.metadata.json +1 -1
  260. package/typings/stepper/index.metadata.json +1 -1
  261. package/typings/stepper/stepper.d.ts +13 -1
  262. package/typings/text-field/autosize.d.ts +6 -0
  263. package/typings/text-field/index.metadata.json +1 -1
  264. package/typings/tree/control/base-tree-control.d.ts +1 -1
  265. package/typings/tree/control/nested-tree-control.d.ts +2 -2
  266. package/typings/tree/control/tree-control.d.ts +1 -1
  267. package/typings/tree/nested-node.d.ts +5 -5
package/esm5/a11y.es5.js CHANGED
@@ -8,21 +8,22 @@
8
8
  import { DOCUMENT, CommonModule } from '@angular/common';
9
9
  import { Inject, Injectable, Optional, SkipSelf, QueryList, Directive, ElementRef, Input, NgZone, isDevMode, InjectionToken, EventEmitter, Output, NgModule, defineInjectable, inject } from '@angular/core';
10
10
  import { Subject, Subscription, of } from 'rxjs';
11
- import { UP_ARROW, DOWN_ARROW, LEFT_ARROW, RIGHT_ARROW, TAB, A, Z, ZERO, NINE } from '@angular/cdk/keycodes';
11
+ import { UP_ARROW, DOWN_ARROW, LEFT_ARROW, RIGHT_ARROW, TAB, A, Z, ZERO, NINE, hasModifierKey } from '@angular/cdk/keycodes';
12
12
  import { debounceTime, filter, map, tap, take } from 'rxjs/operators';
13
13
  import { __extends } from 'tslib';
14
14
  import { Platform, normalizePassiveListenerOptions, PlatformModule } from '@angular/cdk/platform';
15
- import { coerceBooleanProperty } from '@angular/cdk/coercion';
15
+ import { coerceBooleanProperty, coerceElement } from '@angular/cdk/coercion';
16
16
  import { ContentObserver, ObserversModule } from '@angular/cdk/observers';
17
17
 
18
18
  /**
19
19
  * @fileoverview added by tsickle
20
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
20
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
21
21
  */
22
22
 
23
- /** *
23
+ /**
24
24
  * IDs are deliminated by an empty space, as per the spec.
25
- @type {?} */
25
+ * @type {?}
26
+ */
26
27
  var ID_DELIMINATOR = ' ';
27
28
  /**
28
29
  * Adds the given ID to the specified ARIA attribute on an element.
@@ -70,31 +71,37 @@ function getAriaReferenceIds(el, attr) {
70
71
 
71
72
  /**
72
73
  * @fileoverview added by tsickle
73
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
74
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
74
75
  */
75
- /** *
76
+ /**
76
77
  * ID used for the body container where all messages are appended.
77
- @type {?} */
78
+ * @type {?}
79
+ */
78
80
  var MESSAGES_CONTAINER_ID = 'cdk-describedby-message-container';
79
- /** *
81
+ /**
80
82
  * ID prefix used for each created message element.
81
- @type {?} */
83
+ * @type {?}
84
+ */
82
85
  var CDK_DESCRIBEDBY_ID_PREFIX = 'cdk-describedby-message';
83
- /** *
86
+ /**
84
87
  * Attribute given to each host element that is described by a message element.
85
- @type {?} */
88
+ * @type {?}
89
+ */
86
90
  var CDK_DESCRIBEDBY_HOST_ATTRIBUTE = 'cdk-describedby-host';
87
- /** *
91
+ /**
88
92
  * Global incremental identifier for each registered message element.
89
- @type {?} */
93
+ * @type {?}
94
+ */
90
95
  var nextId = 0;
91
- /** *
96
+ /**
92
97
  * Global map of all registered message elements that have been placed into the document.
93
- @type {?} */
98
+ * @type {?}
99
+ */
94
100
  var messageRegistry = new Map();
95
- /** *
101
+ /**
96
102
  * Container for all registered messages.
97
- @type {?} */
103
+ * @type {?}
104
+ */
98
105
  var messagesContainer = null;
99
106
  /**
100
107
  * Utility that creates visually hidden elements with a message content. Useful for elements that
@@ -191,12 +198,18 @@ var AriaDescriber = /** @class */ (function () {
191
198
  /**
192
199
  * Creates a new element in the visually hidden message container element with the message
193
200
  * as its content and adds it to the message registry.
201
+ */
202
+ /**
203
+ * Creates a new element in the visually hidden message container element with the message
204
+ * as its content and adds it to the message registry.
205
+ * @private
194
206
  * @param {?} message
195
207
  * @return {?}
196
208
  */
197
209
  AriaDescriber.prototype._createMessageElement = /**
198
210
  * Creates a new element in the visually hidden message container element with the message
199
211
  * as its content and adds it to the message registry.
212
+ * @private
200
213
  * @param {?} message
201
214
  * @return {?}
202
215
  */
@@ -204,18 +217,21 @@ var AriaDescriber = /** @class */ (function () {
204
217
  /** @type {?} */
205
218
  var messageElement = this._document.createElement('div');
206
219
  messageElement.setAttribute('id', CDK_DESCRIBEDBY_ID_PREFIX + "-" + nextId++);
207
- messageElement.appendChild(/** @type {?} */ ((this._document.createTextNode(message))));
208
- this._createMessagesContainer(); /** @type {?} */
209
- ((messagesContainer)).appendChild(messageElement);
220
+ messageElement.appendChild((/** @type {?} */ (this._document.createTextNode(message))));
221
+ this._createMessagesContainer();
222
+ (/** @type {?} */ (messagesContainer)).appendChild(messageElement);
210
223
  messageRegistry.set(message, { messageElement: messageElement, referenceCount: 0 });
211
224
  };
225
+ /** Deletes the message element from the global messages container. */
212
226
  /**
213
227
  * Deletes the message element from the global messages container.
228
+ * @private
214
229
  * @param {?} message
215
230
  * @return {?}
216
231
  */
217
232
  AriaDescriber.prototype._deleteMessageElement = /**
218
233
  * Deletes the message element from the global messages container.
234
+ * @private
219
235
  * @param {?} message
220
236
  * @return {?}
221
237
  */
@@ -229,12 +245,15 @@ var AriaDescriber = /** @class */ (function () {
229
245
  }
230
246
  messageRegistry.delete(message);
231
247
  };
248
+ /** Creates the global container for all aria-describedby messages. */
232
249
  /**
233
250
  * Creates the global container for all aria-describedby messages.
251
+ * @private
234
252
  * @return {?}
235
253
  */
236
254
  AriaDescriber.prototype._createMessagesContainer = /**
237
255
  * Creates the global container for all aria-describedby messages.
256
+ * @private
238
257
  * @return {?}
239
258
  */
240
259
  function () {
@@ -246,7 +265,7 @@ var AriaDescriber = /** @class */ (function () {
246
265
  // old container so we don't get duplicates. Doing this, instead of emptying the previous
247
266
  // container, should be slightly faster.
248
267
  if (preExistingContainer) {
249
- /** @type {?} */ ((preExistingContainer.parentNode)).removeChild(preExistingContainer);
268
+ (/** @type {?} */ (preExistingContainer.parentNode)).removeChild(preExistingContainer);
250
269
  }
251
270
  messagesContainer = this._document.createElement('div');
252
271
  messagesContainer.id = MESSAGES_CONTAINER_ID;
@@ -255,12 +274,15 @@ var AriaDescriber = /** @class */ (function () {
255
274
  this._document.body.appendChild(messagesContainer);
256
275
  }
257
276
  };
277
+ /** Deletes the global messages container. */
258
278
  /**
259
279
  * Deletes the global messages container.
280
+ * @private
260
281
  * @return {?}
261
282
  */
262
283
  AriaDescriber.prototype._deleteMessagesContainer = /**
263
284
  * Deletes the global messages container.
285
+ * @private
264
286
  * @return {?}
265
287
  */
266
288
  function () {
@@ -269,17 +291,21 @@ var AriaDescriber = /** @class */ (function () {
269
291
  messagesContainer = null;
270
292
  }
271
293
  };
294
+ /** Removes all cdk-describedby messages that are hosted through the element. */
272
295
  /**
273
296
  * Removes all cdk-describedby messages that are hosted through the element.
297
+ * @private
274
298
  * @param {?} element
275
299
  * @return {?}
276
300
  */
277
301
  AriaDescriber.prototype._removeCdkDescribedByReferenceIds = /**
278
302
  * Removes all cdk-describedby messages that are hosted through the element.
303
+ * @private
279
304
  * @param {?} element
280
305
  * @return {?}
281
306
  */
282
307
  function (element) {
308
+ // Remove all aria-describedby reference IDs that are prefixed by CDK_DESCRIBEDBY_ID_PREFIX
283
309
  /** @type {?} */
284
310
  var originalReferenceIds = getAriaReferenceIds(element, 'aria-describedby')
285
311
  .filter(function (id) { return id.indexOf(CDK_DESCRIBEDBY_ID_PREFIX) != 0; });
@@ -288,6 +314,11 @@ var AriaDescriber = /** @class */ (function () {
288
314
  /**
289
315
  * Adds a message reference to the element using aria-describedby and increments the registered
290
316
  * message's reference count.
317
+ */
318
+ /**
319
+ * Adds a message reference to the element using aria-describedby and increments the registered
320
+ * message's reference count.
321
+ * @private
291
322
  * @param {?} element
292
323
  * @param {?} message
293
324
  * @return {?}
@@ -295,13 +326,14 @@ var AriaDescriber = /** @class */ (function () {
295
326
  AriaDescriber.prototype._addMessageReference = /**
296
327
  * Adds a message reference to the element using aria-describedby and increments the registered
297
328
  * message's reference count.
329
+ * @private
298
330
  * @param {?} element
299
331
  * @param {?} message
300
332
  * @return {?}
301
333
  */
302
334
  function (element, message) {
303
335
  /** @type {?} */
304
- var registeredMessage = /** @type {?} */ ((messageRegistry.get(message)));
336
+ var registeredMessage = (/** @type {?} */ (messageRegistry.get(message)));
305
337
  // Add the aria-describedby reference and set the
306
338
  // describedby_host attribute to mark the element.
307
339
  addAriaReferencedId(element, 'aria-describedby', registeredMessage.messageElement.id);
@@ -311,6 +343,11 @@ var AriaDescriber = /** @class */ (function () {
311
343
  /**
312
344
  * Removes a message reference from the element using aria-describedby
313
345
  * and decrements the registered message's reference count.
346
+ */
347
+ /**
348
+ * Removes a message reference from the element using aria-describedby
349
+ * and decrements the registered message's reference count.
350
+ * @private
314
351
  * @param {?} element
315
352
  * @param {?} message
316
353
  * @return {?}
@@ -318,25 +355,29 @@ var AriaDescriber = /** @class */ (function () {
318
355
  AriaDescriber.prototype._removeMessageReference = /**
319
356
  * Removes a message reference from the element using aria-describedby
320
357
  * and decrements the registered message's reference count.
358
+ * @private
321
359
  * @param {?} element
322
360
  * @param {?} message
323
361
  * @return {?}
324
362
  */
325
363
  function (element, message) {
326
364
  /** @type {?} */
327
- var registeredMessage = /** @type {?} */ ((messageRegistry.get(message)));
365
+ var registeredMessage = (/** @type {?} */ (messageRegistry.get(message)));
328
366
  registeredMessage.referenceCount--;
329
367
  removeAriaReferencedId(element, 'aria-describedby', registeredMessage.messageElement.id);
330
368
  element.removeAttribute(CDK_DESCRIBEDBY_HOST_ATTRIBUTE);
331
369
  };
370
+ /** Returns true if the element has been described by the provided message ID. */
332
371
  /**
333
372
  * Returns true if the element has been described by the provided message ID.
373
+ * @private
334
374
  * @param {?} element
335
375
  * @param {?} message
336
376
  * @return {?}
337
377
  */
338
378
  AriaDescriber.prototype._isElementDescribedByMessage = /**
339
379
  * Returns true if the element has been described by the provided message ID.
380
+ * @private
340
381
  * @param {?} element
341
382
  * @param {?} message
342
383
  * @return {?}
@@ -350,14 +391,17 @@ var AriaDescriber = /** @class */ (function () {
350
391
  var messageId = registeredMessage && registeredMessage.messageElement.id;
351
392
  return !!messageId && referenceIds.indexOf(messageId) != -1;
352
393
  };
394
+ /** Determines whether a message can be described on a particular element. */
353
395
  /**
354
396
  * Determines whether a message can be described on a particular element.
397
+ * @private
355
398
  * @param {?} element
356
399
  * @param {?} message
357
400
  * @return {?}
358
401
  */
359
402
  AriaDescriber.prototype._canBeDescribed = /**
360
403
  * Determines whether a message can be described on a particular element.
404
+ * @private
361
405
  * @param {?} element
362
406
  * @param {?} message
363
407
  * @return {?}
@@ -385,32 +429,30 @@ var AriaDescriber = /** @class */ (function () {
385
429
  function ARIA_DESCRIBER_PROVIDER_FACTORY(parentDispatcher, _document) {
386
430
  return parentDispatcher || new AriaDescriber(_document);
387
431
  }
388
- /** *
432
+ /**
389
433
  * \@docs-private \@deprecated \@breaking-change 8.0.0
390
- @type {?} */
434
+ * @type {?}
435
+ */
391
436
  var ARIA_DESCRIBER_PROVIDER = {
392
437
  // If there is already an AriaDescriber available, use that. Otherwise, provide a new one.
393
438
  provide: AriaDescriber,
394
439
  deps: [
395
440
  [new Optional(), new SkipSelf(), AriaDescriber],
396
- /** @type {?} */ (DOCUMENT)
441
+ (/** @type {?} */ (DOCUMENT))
397
442
  ],
398
443
  useFactory: ARIA_DESCRIBER_PROVIDER_FACTORY
399
444
  };
400
445
 
401
446
  /**
402
447
  * @fileoverview added by tsickle
403
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
448
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
404
449
  */
405
- // unsupported: template constraints.
406
450
  /**
407
451
  * This class manages keyboard events for selectable lists. If you pass it a query list
408
452
  * of items, it will set the active item correctly when arrow events occur.
409
453
  * @template T
410
454
  */
411
- var
412
- // unsupported: template constraints.
413
- /**
455
+ var /**
414
456
  * This class manages keyboard events for selectable lists. If you pass it a query list
415
457
  * of items, it will set the active item correctly when arrow events occur.
416
458
  * @template T
@@ -420,6 +462,7 @@ ListKeyManager = /** @class */ (function () {
420
462
  var _this = this;
421
463
  this._items = _items;
422
464
  this._activeItemIndex = -1;
465
+ this._activeItem = null;
423
466
  this._wrap = false;
424
467
  this._letterKeyStream = new Subject();
425
468
  this._typeaheadSubscription = Subscription.EMPTY;
@@ -430,6 +473,7 @@ ListKeyManager = /** @class */ (function () {
430
473
  * by the key manager. By default, disabled items are skipped.
431
474
  */
432
475
  this._skipPredicateFn = function (item) { return item.disabled; };
476
+ // Buffer for the letters that the user has pressed when the typeahead option is turned on.
433
477
  this._pressedLetters = [];
434
478
  /**
435
479
  * Stream that emits any time the TAB key is pressed, so components can react
@@ -465,18 +509,22 @@ ListKeyManager = /** @class */ (function () {
465
509
  /**
466
510
  * Sets the predicate function that determines which items should be skipped by the
467
511
  * list key manager.
512
+ * @template THIS
513
+ * @this {THIS}
468
514
  * @param {?} predicate Function that determines whether the given item should be skipped.
469
- * @return {?}
515
+ * @return {THIS}
470
516
  */
471
517
  ListKeyManager.prototype.skipPredicate = /**
472
518
  * Sets the predicate function that determines which items should be skipped by the
473
519
  * list key manager.
520
+ * @template THIS
521
+ * @this {THIS}
474
522
  * @param {?} predicate Function that determines whether the given item should be skipped.
475
- * @return {?}
523
+ * @return {THIS}
476
524
  */
477
525
  function (predicate) {
478
- this._skipPredicateFn = predicate;
479
- return this;
526
+ (/** @type {?} */ (this))._skipPredicateFn = predicate;
527
+ return (/** @type {?} */ (this));
480
528
  };
481
529
  /**
482
530
  * Configures wrapping mode, which determines whether the active item will wrap to
@@ -486,19 +534,23 @@ ListKeyManager = /** @class */ (function () {
486
534
  /**
487
535
  * Configures wrapping mode, which determines whether the active item will wrap to
488
536
  * the other end of list when there are no more items in the given direction.
537
+ * @template THIS
538
+ * @this {THIS}
489
539
  * @param {?=} shouldWrap Whether the list should wrap when reaching the end.
490
- * @return {?}
540
+ * @return {THIS}
491
541
  */
492
542
  ListKeyManager.prototype.withWrap = /**
493
543
  * Configures wrapping mode, which determines whether the active item will wrap to
494
544
  * the other end of list when there are no more items in the given direction.
545
+ * @template THIS
546
+ * @this {THIS}
495
547
  * @param {?=} shouldWrap Whether the list should wrap when reaching the end.
496
- * @return {?}
548
+ * @return {THIS}
497
549
  */
498
550
  function (shouldWrap) {
499
551
  if (shouldWrap === void 0) { shouldWrap = true; }
500
- this._wrap = shouldWrap;
501
- return this;
552
+ (/** @type {?} */ (this))._wrap = shouldWrap;
553
+ return (/** @type {?} */ (this));
502
554
  };
503
555
  /**
504
556
  * Configures whether the key manager should be able to move the selection vertically.
@@ -506,18 +558,22 @@ ListKeyManager = /** @class */ (function () {
506
558
  */
507
559
  /**
508
560
  * Configures whether the key manager should be able to move the selection vertically.
561
+ * @template THIS
562
+ * @this {THIS}
509
563
  * @param {?=} enabled Whether vertical selection should be enabled.
510
- * @return {?}
564
+ * @return {THIS}
511
565
  */
512
566
  ListKeyManager.prototype.withVerticalOrientation = /**
513
567
  * Configures whether the key manager should be able to move the selection vertically.
568
+ * @template THIS
569
+ * @this {THIS}
514
570
  * @param {?=} enabled Whether vertical selection should be enabled.
515
- * @return {?}
571
+ * @return {THIS}
516
572
  */
517
573
  function (enabled) {
518
574
  if (enabled === void 0) { enabled = true; }
519
- this._vertical = enabled;
520
- return this;
575
+ (/** @type {?} */ (this))._vertical = enabled;
576
+ return (/** @type {?} */ (this));
521
577
  };
522
578
  /**
523
579
  * Configures the key manager to move the selection horizontally.
@@ -527,18 +583,22 @@ ListKeyManager = /** @class */ (function () {
527
583
  /**
528
584
  * Configures the key manager to move the selection horizontally.
529
585
  * Passing in `null` will disable horizontal movement.
586
+ * @template THIS
587
+ * @this {THIS}
530
588
  * @param {?} direction Direction in which the selection can be moved.
531
- * @return {?}
589
+ * @return {THIS}
532
590
  */
533
591
  ListKeyManager.prototype.withHorizontalOrientation = /**
534
592
  * Configures the key manager to move the selection horizontally.
535
593
  * Passing in `null` will disable horizontal movement.
594
+ * @template THIS
595
+ * @this {THIS}
536
596
  * @param {?} direction Direction in which the selection can be moved.
537
- * @return {?}
597
+ * @return {THIS}
538
598
  */
539
599
  function (direction) {
540
- this._horizontal = direction;
541
- return this;
600
+ (/** @type {?} */ (this))._horizontal = direction;
601
+ return (/** @type {?} */ (this));
542
602
  };
543
603
  /**
544
604
  * Modifier keys which are allowed to be held down and whose default actions will be prevented
@@ -547,18 +607,22 @@ ListKeyManager = /** @class */ (function () {
547
607
  /**
548
608
  * Modifier keys which are allowed to be held down and whose default actions will be prevented
549
609
  * as the user is pressing the arrow keys. Defaults to not allowing any modifier keys.
610
+ * @template THIS
611
+ * @this {THIS}
550
612
  * @param {?} keys
551
- * @return {?}
613
+ * @return {THIS}
552
614
  */
553
615
  ListKeyManager.prototype.withAllowedModifierKeys = /**
554
616
  * Modifier keys which are allowed to be held down and whose default actions will be prevented
555
617
  * as the user is pressing the arrow keys. Defaults to not allowing any modifier keys.
618
+ * @template THIS
619
+ * @this {THIS}
556
620
  * @param {?} keys
557
- * @return {?}
621
+ * @return {THIS}
558
622
  */
559
623
  function (keys) {
560
- this._allowedModifierKeys = keys;
561
- return this;
624
+ (/** @type {?} */ (this))._allowedModifierKeys = keys;
625
+ return (/** @type {?} */ (this));
562
626
  };
563
627
  /**
564
628
  * Turns on typeahead mode which allows users to set the active item by typing.
@@ -566,42 +630,47 @@ ListKeyManager = /** @class */ (function () {
566
630
  */
567
631
  /**
568
632
  * Turns on typeahead mode which allows users to set the active item by typing.
633
+ * @template THIS
634
+ * @this {THIS}
569
635
  * @param {?=} debounceInterval Time to wait after the last keystroke before setting the active item.
570
- * @return {?}
636
+ * @return {THIS}
571
637
  */
572
638
  ListKeyManager.prototype.withTypeAhead = /**
573
639
  * Turns on typeahead mode which allows users to set the active item by typing.
640
+ * @template THIS
641
+ * @this {THIS}
574
642
  * @param {?=} debounceInterval Time to wait after the last keystroke before setting the active item.
575
- * @return {?}
643
+ * @return {THIS}
576
644
  */
577
645
  function (debounceInterval) {
578
646
  var _this = this;
579
647
  if (debounceInterval === void 0) { debounceInterval = 200; }
580
- if (this._items.length && this._items.some(function (item) { return typeof item.getLabel !== 'function'; })) {
648
+ if ((/** @type {?} */ (this))._items.length && (/** @type {?} */ (this))._items.some(function (item) { return typeof item.getLabel !== 'function'; })) {
581
649
  throw Error('ListKeyManager items in typeahead mode must implement the `getLabel` method.');
582
650
  }
583
- this._typeaheadSubscription.unsubscribe();
651
+ (/** @type {?} */ (this))._typeaheadSubscription.unsubscribe();
584
652
  // Debounce the presses of non-navigational keys, collect the ones that correspond to letters
585
653
  // and convert those letters back into a string. Afterwards find the first item that starts
586
654
  // with that string and select it.
587
- this._typeaheadSubscription = this._letterKeyStream.pipe(tap(function (keyCode) { return _this._pressedLetters.push(keyCode); }), debounceTime(debounceInterval), filter(function () { return _this._pressedLetters.length > 0; }), map(function () { return _this._pressedLetters.join(''); })).subscribe(function (inputString) {
655
+ (/** @type {?} */ (this))._typeaheadSubscription = (/** @type {?} */ (this))._letterKeyStream.pipe(tap(function (keyCode) { return (/** @type {?} */ (_this))._pressedLetters.push(keyCode); }), debounceTime(debounceInterval), filter(function () { return (/** @type {?} */ (_this))._pressedLetters.length > 0; }), map(function () { return (/** @type {?} */ (_this))._pressedLetters.join(''); })).subscribe(function (inputString) {
588
656
  /** @type {?} */
589
- var items = _this._getItemsArray();
657
+ var items = (/** @type {?} */ (_this))._getItemsArray();
590
658
  // Start at 1 because we want to start searching at the item immediately
591
659
  // following the current active item.
592
660
  for (var i = 1; i < items.length + 1; i++) {
593
661
  /** @type {?} */
594
- var index = (_this._activeItemIndex + i) % items.length;
662
+ var index = ((/** @type {?} */ (_this))._activeItemIndex + i) % items.length;
595
663
  /** @type {?} */
596
664
  var item = items[index];
597
- if (!_this._skipPredicateFn(item) && /** @type {?} */ ((item.getLabel))().toUpperCase().trim().indexOf(inputString) === 0) {
598
- _this.setActiveItem(index);
665
+ if (!(/** @type {?} */ (_this))._skipPredicateFn(item) &&
666
+ (/** @type {?} */ (item.getLabel))().toUpperCase().trim().indexOf(inputString) === 0) {
667
+ (/** @type {?} */ (_this)).setActiveItem(index);
599
668
  break;
600
669
  }
601
670
  }
602
- _this._pressedLetters = [];
671
+ (/** @type {?} */ (_this))._pressedLetters = [];
603
672
  });
604
- return this;
673
+ return (/** @type {?} */ (this));
605
674
  };
606
675
  /**
607
676
  * @param {?} item
@@ -680,13 +749,15 @@ ListKeyManager = /** @class */ (function () {
680
749
  return;
681
750
  }
682
751
  default:
683
- // Attempt to use the `event.key` which also maps it to the user's keyboard language,
684
- // otherwise fall back to resolving alphanumeric characters via the keyCode.
685
- if (event.key && event.key.length === 1) {
686
- this._letterKeyStream.next(event.key.toLocaleUpperCase());
687
- }
688
- else if ((keyCode >= A && keyCode <= Z) || (keyCode >= ZERO && keyCode <= NINE)) {
689
- this._letterKeyStream.next(String.fromCharCode(keyCode));
752
+ if (isModifierAllowed || hasModifierKey(event, 'shiftKey')) {
753
+ // Attempt to use the `event.key` which also maps it to the user's keyboard language,
754
+ // otherwise fall back to resolving alphanumeric characters via the keyCode.
755
+ if (event.key && event.key.length === 1) {
756
+ this._letterKeyStream.next(event.key.toLocaleUpperCase());
757
+ }
758
+ else if ((keyCode >= A && keyCode <= Z) || (keyCode >= ZERO && keyCode <= NINE)) {
759
+ this._letterKeyStream.next(String.fromCharCode(keyCode));
760
+ }
690
761
  }
691
762
  // Note that we return here, in order to avoid preventing
692
763
  // the default action of non-navigational keys.
@@ -781,8 +852,11 @@ ListKeyManager = /** @class */ (function () {
781
852
  var itemArray = this._getItemsArray();
782
853
  /** @type {?} */
783
854
  var index = typeof item === 'number' ? item : itemArray.indexOf(item);
855
+ /** @type {?} */
856
+ var activeItem = itemArray[index];
857
+ // Explicitly check for `null` and `undefined` because other falsy values are valid.
858
+ this._activeItem = activeItem == null ? null : activeItem;
784
859
  this._activeItemIndex = index;
785
- this._activeItem = itemArray[index];
786
860
  };
787
861
  /**
788
862
  * Allows setting of the activeItemIndex without any other effects.
@@ -811,6 +885,12 @@ ListKeyManager = /** @class */ (function () {
811
885
  * This method sets the active item, given a list of items and the delta between the
812
886
  * currently active item and the new active item. It will calculate differently
813
887
  * depending on whether wrap mode is turned on.
888
+ */
889
+ /**
890
+ * This method sets the active item, given a list of items and the delta between the
891
+ * currently active item and the new active item. It will calculate differently
892
+ * depending on whether wrap mode is turned on.
893
+ * @private
814
894
  * @param {?} delta
815
895
  * @return {?}
816
896
  */
@@ -818,6 +898,7 @@ ListKeyManager = /** @class */ (function () {
818
898
  * This method sets the active item, given a list of items and the delta between the
819
899
  * currently active item and the new active item. It will calculate differently
820
900
  * depending on whether wrap mode is turned on.
901
+ * @private
821
902
  * @param {?} delta
822
903
  * @return {?}
823
904
  */
@@ -828,6 +909,12 @@ ListKeyManager = /** @class */ (function () {
828
909
  * Sets the active item properly given "wrap" mode. In other words, it will continue to move
829
910
  * down the list until it finds an item that is not disabled, and it will wrap if it
830
911
  * encounters either end of the list.
912
+ */
913
+ /**
914
+ * Sets the active item properly given "wrap" mode. In other words, it will continue to move
915
+ * down the list until it finds an item that is not disabled, and it will wrap if it
916
+ * encounters either end of the list.
917
+ * @private
831
918
  * @param {?} delta
832
919
  * @return {?}
833
920
  */
@@ -835,6 +922,7 @@ ListKeyManager = /** @class */ (function () {
835
922
  * Sets the active item properly given "wrap" mode. In other words, it will continue to move
836
923
  * down the list until it finds an item that is not disabled, and it will wrap if it
837
924
  * encounters either end of the list.
925
+ * @private
838
926
  * @param {?} delta
839
927
  * @return {?}
840
928
  */
@@ -856,6 +944,12 @@ ListKeyManager = /** @class */ (function () {
856
944
  * Sets the active item properly given the default mode. In other words, it will
857
945
  * continue to move down the list until it finds an item that is not disabled. If
858
946
  * it encounters either end of the list, it will stop and not wrap.
947
+ */
948
+ /**
949
+ * Sets the active item properly given the default mode. In other words, it will
950
+ * continue to move down the list until it finds an item that is not disabled. If
951
+ * it encounters either end of the list, it will stop and not wrap.
952
+ * @private
859
953
  * @param {?} delta
860
954
  * @return {?}
861
955
  */
@@ -863,6 +957,7 @@ ListKeyManager = /** @class */ (function () {
863
957
  * Sets the active item properly given the default mode. In other words, it will
864
958
  * continue to move down the list until it finds an item that is not disabled. If
865
959
  * it encounters either end of the list, it will stop and not wrap.
960
+ * @private
866
961
  * @param {?} delta
867
962
  * @return {?}
868
963
  */
@@ -873,6 +968,12 @@ ListKeyManager = /** @class */ (function () {
873
968
  * Sets the active item to the first enabled item starting at the index specified. If the
874
969
  * item is disabled, it will move in the fallbackDelta direction until it either
875
970
  * finds an enabled item or encounters the end of the list.
971
+ */
972
+ /**
973
+ * Sets the active item to the first enabled item starting at the index specified. If the
974
+ * item is disabled, it will move in the fallbackDelta direction until it either
975
+ * finds an enabled item or encounters the end of the list.
976
+ * @private
876
977
  * @param {?} index
877
978
  * @param {?} fallbackDelta
878
979
  * @return {?}
@@ -881,6 +982,7 @@ ListKeyManager = /** @class */ (function () {
881
982
  * Sets the active item to the first enabled item starting at the index specified. If the
882
983
  * item is disabled, it will move in the fallbackDelta direction until it either
883
984
  * finds an enabled item or encounters the end of the list.
985
+ * @private
884
986
  * @param {?} index
885
987
  * @param {?} fallbackDelta
886
988
  * @return {?}
@@ -899,12 +1001,15 @@ ListKeyManager = /** @class */ (function () {
899
1001
  }
900
1002
  this.setActiveItem(index);
901
1003
  };
1004
+ /** Returns the items as an array. */
902
1005
  /**
903
1006
  * Returns the items as an array.
1007
+ * @private
904
1008
  * @return {?}
905
1009
  */
906
1010
  ListKeyManager.prototype._getItemsArray = /**
907
1011
  * Returns the items as an array.
1012
+ * @private
908
1013
  * @return {?}
909
1014
  */
910
1015
  function () {
@@ -915,7 +1020,7 @@ ListKeyManager = /** @class */ (function () {
915
1020
 
916
1021
  /**
917
1022
  * @fileoverview added by tsickle
918
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
1023
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
919
1024
  */
920
1025
  /**
921
1026
  * @template T
@@ -950,7 +1055,7 @@ ActiveDescendantKeyManager = /** @class */ (function (_super) {
950
1055
 
951
1056
  /**
952
1057
  * @fileoverview added by tsickle
953
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
1058
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
954
1059
  */
955
1060
  /**
956
1061
  * @template T
@@ -971,17 +1076,21 @@ FocusKeyManager = /** @class */ (function (_super) {
971
1076
  */
972
1077
  /**
973
1078
  * Sets the focus origin that will be passed in to the items for any subsequent `focus` calls.
1079
+ * @template THIS
1080
+ * @this {THIS}
974
1081
  * @param {?} origin Focus origin to be used when focusing items.
975
- * @return {?}
1082
+ * @return {THIS}
976
1083
  */
977
1084
  FocusKeyManager.prototype.setFocusOrigin = /**
978
1085
  * Sets the focus origin that will be passed in to the items for any subsequent `focus` calls.
1086
+ * @template THIS
1087
+ * @this {THIS}
979
1088
  * @param {?} origin Focus origin to be used when focusing items.
980
- * @return {?}
1089
+ * @return {THIS}
981
1090
  */
982
1091
  function (origin) {
983
- this._origin = origin;
984
- return this;
1092
+ (/** @type {?} */ (this))._origin = origin;
1093
+ return (/** @type {?} */ (this));
985
1094
  };
986
1095
  /**
987
1096
  * @param {?} item
@@ -1002,8 +1111,11 @@ FocusKeyManager = /** @class */ (function (_super) {
1002
1111
 
1003
1112
  /**
1004
1113
  * @fileoverview added by tsickle
1005
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
1114
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1006
1115
  */
1116
+ // The InteractivityChecker leans heavily on the ally.js accessibility utilities.
1117
+ // Methods like `isTabbable` are only covering specific edge-cases for the browsers which are
1118
+ // supported.
1007
1119
  /**
1008
1120
  * Utility for checking the interactivity of an element, such as whether is is focusable or
1009
1121
  * tabbable.
@@ -1086,7 +1198,7 @@ var InteractivityChecker = /** @class */ (function () {
1086
1198
  * @return {?} Whether the element is tabbable.
1087
1199
  */
1088
1200
  function (element) {
1089
- // Nothing is tabbable on the the server 😎
1201
+ // Nothing is tabbable on the server 😎
1090
1202
  if (!this._platform.isBrowser) {
1091
1203
  return false;
1092
1204
  }
@@ -1192,7 +1304,7 @@ var InteractivityChecker = /** @class */ (function () {
1192
1304
  */
1193
1305
  function getFrameElement(window) {
1194
1306
  try {
1195
- return /** @type {?} */ (window.frameElement);
1307
+ return (/** @type {?} */ (window.frameElement));
1196
1308
  }
1197
1309
  catch (_a) {
1198
1310
  return null;
@@ -1281,6 +1393,7 @@ function getTabIndexValue(element) {
1281
1393
  if (!hasValidTabIndex(element)) {
1282
1394
  return null;
1283
1395
  }
1396
+ // See browser issue in Gecko https://bugzilla.mozilla.org/show_bug.cgi?id=1128054
1284
1397
  /** @type {?} */
1285
1398
  var tabIndex = parseInt(element.getAttribute('tabindex') || '', 10);
1286
1399
  return isNaN(tabIndex) ? -1 : tabIndex;
@@ -1294,7 +1407,7 @@ function isPotentiallyTabbableIOS(element) {
1294
1407
  /** @type {?} */
1295
1408
  var nodeName = element.nodeName.toLowerCase();
1296
1409
  /** @type {?} */
1297
- var inputType = nodeName === 'input' && (/** @type {?} */ (element)).type;
1410
+ var inputType = nodeName === 'input' && ((/** @type {?} */ (element))).type;
1298
1411
  return inputType === 'text'
1299
1412
  || inputType === 'password'
1300
1413
  || nodeName === 'select'
@@ -1328,7 +1441,7 @@ function getWindow(node) {
1328
1441
 
1329
1442
  /**
1330
1443
  * @fileoverview added by tsickle
1331
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
1444
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1332
1445
  */
1333
1446
  /**
1334
1447
  * Class that allows for trapping focus within a DOM element.
@@ -1347,11 +1460,15 @@ var /**
1347
1460
  FocusTrap = /** @class */ (function () {
1348
1461
  function FocusTrap(_element, _checker, _ngZone, _document, deferAnchors) {
1349
1462
  if (deferAnchors === void 0) { deferAnchors = false; }
1463
+ var _this = this;
1350
1464
  this._element = _element;
1351
1465
  this._checker = _checker;
1352
1466
  this._ngZone = _ngZone;
1353
1467
  this._document = _document;
1354
1468
  this._hasAttached = false;
1469
+ // Event listeners for the anchors. Need to be regular functions so that we can unbind them later.
1470
+ this._startAnchorListener = function () { return _this.focusLastTabbableElement(); };
1471
+ this._endAnchorListener = function () { return _this.focusFirstTabbableElement(); };
1355
1472
  this._enabled = true;
1356
1473
  if (!deferAnchors) {
1357
1474
  this.attachAnchors();
@@ -1388,11 +1505,21 @@ FocusTrap = /** @class */ (function () {
1388
1505
  * @return {?}
1389
1506
  */
1390
1507
  function () {
1391
- if (this._startAnchor && this._startAnchor.parentNode) {
1392
- this._startAnchor.parentNode.removeChild(this._startAnchor);
1508
+ /** @type {?} */
1509
+ var startAnchor = this._startAnchor;
1510
+ /** @type {?} */
1511
+ var endAnchor = this._endAnchor;
1512
+ if (startAnchor) {
1513
+ startAnchor.removeEventListener('focus', this._startAnchorListener);
1514
+ if (startAnchor.parentNode) {
1515
+ startAnchor.parentNode.removeChild(startAnchor);
1516
+ }
1393
1517
  }
1394
- if (this._endAnchor && this._endAnchor.parentNode) {
1395
- this._endAnchor.parentNode.removeChild(this._endAnchor);
1518
+ if (endAnchor) {
1519
+ endAnchor.removeEventListener('focus', this._endAnchorListener);
1520
+ if (endAnchor.parentNode) {
1521
+ endAnchor.parentNode.removeChild(endAnchor);
1522
+ }
1396
1523
  }
1397
1524
  this._startAnchor = this._endAnchor = null;
1398
1525
  };
@@ -1422,17 +1549,17 @@ FocusTrap = /** @class */ (function () {
1422
1549
  }
1423
1550
  this._ngZone.runOutsideAngular(function () {
1424
1551
  if (!_this._startAnchor) {
1425
- _this._startAnchor = _this._createAnchor(); /** @type {?} */
1426
- ((_this._startAnchor)).addEventListener('focus', function () { return _this.focusLastTabbableElement(); });
1552
+ _this._startAnchor = _this._createAnchor();
1553
+ (/** @type {?} */ (_this._startAnchor)).addEventListener('focus', _this._startAnchorListener);
1427
1554
  }
1428
1555
  if (!_this._endAnchor) {
1429
- _this._endAnchor = _this._createAnchor(); /** @type {?} */
1430
- ((_this._endAnchor)).addEventListener('focus', function () { return _this.focusFirstTabbableElement(); });
1556
+ _this._endAnchor = _this._createAnchor();
1557
+ (/** @type {?} */ (_this._endAnchor)).addEventListener('focus', _this._endAnchorListener);
1431
1558
  }
1432
1559
  });
1433
1560
  if (this._element.parentNode) {
1434
- this._element.parentNode.insertBefore(/** @type {?} */ ((this._startAnchor)), this._element);
1435
- this._element.parentNode.insertBefore(/** @type {?} */ ((this._endAnchor)), this._element.nextSibling);
1561
+ this._element.parentNode.insertBefore((/** @type {?} */ (this._startAnchor)), this._element);
1562
+ this._element.parentNode.insertBefore((/** @type {?} */ (this._endAnchor)), this._element.nextSibling);
1436
1563
  this._hasAttached = true;
1437
1564
  }
1438
1565
  return this._hasAttached;
@@ -1511,19 +1638,27 @@ FocusTrap = /** @class */ (function () {
1511
1638
  };
1512
1639
  /**
1513
1640
  * Get the specified boundary element of the trapped region.
1641
+ * @param bound The boundary to get (start or end of trapped region).
1642
+ * @returns The boundary element.
1643
+ */
1644
+ /**
1645
+ * Get the specified boundary element of the trapped region.
1646
+ * @private
1514
1647
  * @param {?} bound The boundary to get (start or end of trapped region).
1515
1648
  * @return {?} The boundary element.
1516
1649
  */
1517
1650
  FocusTrap.prototype._getRegionBoundary = /**
1518
1651
  * Get the specified boundary element of the trapped region.
1652
+ * @private
1519
1653
  * @param {?} bound The boundary to get (start or end of trapped region).
1520
1654
  * @return {?} The boundary element.
1521
1655
  */
1522
1656
  function (bound) {
1657
+ // Contains the deprecated version of selector, for temporary backwards comparability.
1523
1658
  /** @type {?} */
1524
- var markers = /** @type {?} */ (this._element.querySelectorAll("[cdk-focus-region-" + bound + "], " +
1659
+ var markers = (/** @type {?} */ (this._element.querySelectorAll("[cdk-focus-region-" + bound + "], " +
1525
1660
  ("[cdkFocusRegion" + bound + "], ") +
1526
- ("[cdk-focus-" + bound + "]")));
1661
+ ("[cdk-focus-" + bound + "]"))));
1527
1662
  for (var i = 0; i < markers.length; i++) {
1528
1663
  // @breaking-change 8.0.0
1529
1664
  if (markers[i].hasAttribute("cdk-focus-" + bound)) {
@@ -1556,9 +1691,10 @@ FocusTrap = /** @class */ (function () {
1556
1691
  * @return {?} Whether focus was moved successfuly.
1557
1692
  */
1558
1693
  function () {
1694
+ // Contains the deprecated version of selector, for temporary backwards comparability.
1559
1695
  /** @type {?} */
1560
- var redirectToElement = /** @type {?} */ (this._element.querySelector("[cdk-focus-initial], " +
1561
- "[cdkFocusInitial]"));
1696
+ var redirectToElement = (/** @type {?} */ (this._element.querySelector("[cdk-focus-initial], " +
1697
+ "[cdkFocusInitial]")));
1562
1698
  if (redirectToElement) {
1563
1699
  // @breaking-change 8.0.0
1564
1700
  if (redirectToElement.hasAttribute("cdk-focus-initial")) {
@@ -1630,13 +1766,16 @@ FocusTrap = /** @class */ (function () {
1630
1766
  function () {
1631
1767
  return this._hasAttached;
1632
1768
  };
1769
+ /** Get the first tabbable element from a DOM subtree (inclusive). */
1633
1770
  /**
1634
1771
  * Get the first tabbable element from a DOM subtree (inclusive).
1772
+ * @private
1635
1773
  * @param {?} root
1636
1774
  * @return {?}
1637
1775
  */
1638
1776
  FocusTrap.prototype._getFirstTabbableElement = /**
1639
1777
  * Get the first tabbable element from a DOM subtree (inclusive).
1778
+ * @private
1640
1779
  * @param {?} root
1641
1780
  * @return {?}
1642
1781
  */
@@ -1644,12 +1783,14 @@ FocusTrap = /** @class */ (function () {
1644
1783
  if (this._checker.isFocusable(root) && this._checker.isTabbable(root)) {
1645
1784
  return root;
1646
1785
  }
1786
+ // Iterate in DOM order. Note that IE doesn't have `children` for SVG so we fall
1787
+ // back to `childNodes` which includes text nodes, comments etc.
1647
1788
  /** @type {?} */
1648
1789
  var children = root.children || root.childNodes;
1649
1790
  for (var i = 0; i < children.length; i++) {
1650
1791
  /** @type {?} */
1651
1792
  var tabbableChild = children[i].nodeType === this._document.ELEMENT_NODE ?
1652
- this._getFirstTabbableElement(/** @type {?} */ (children[i])) :
1793
+ this._getFirstTabbableElement((/** @type {?} */ (children[i]))) :
1653
1794
  null;
1654
1795
  if (tabbableChild) {
1655
1796
  return tabbableChild;
@@ -1657,13 +1798,16 @@ FocusTrap = /** @class */ (function () {
1657
1798
  }
1658
1799
  return null;
1659
1800
  };
1801
+ /** Get the last tabbable element from a DOM subtree (inclusive). */
1660
1802
  /**
1661
1803
  * Get the last tabbable element from a DOM subtree (inclusive).
1804
+ * @private
1662
1805
  * @param {?} root
1663
1806
  * @return {?}
1664
1807
  */
1665
1808
  FocusTrap.prototype._getLastTabbableElement = /**
1666
1809
  * Get the last tabbable element from a DOM subtree (inclusive).
1810
+ * @private
1667
1811
  * @param {?} root
1668
1812
  * @return {?}
1669
1813
  */
@@ -1671,12 +1815,13 @@ FocusTrap = /** @class */ (function () {
1671
1815
  if (this._checker.isFocusable(root) && this._checker.isTabbable(root)) {
1672
1816
  return root;
1673
1817
  }
1818
+ // Iterate in reverse DOM order.
1674
1819
  /** @type {?} */
1675
1820
  var children = root.children || root.childNodes;
1676
1821
  for (var i = children.length - 1; i >= 0; i--) {
1677
1822
  /** @type {?} */
1678
1823
  var tabbableChild = children[i].nodeType === this._document.ELEMENT_NODE ?
1679
- this._getLastTabbableElement(/** @type {?} */ (children[i])) :
1824
+ this._getLastTabbableElement((/** @type {?} */ (children[i]))) :
1680
1825
  null;
1681
1826
  if (tabbableChild) {
1682
1827
  return tabbableChild;
@@ -1684,12 +1829,15 @@ FocusTrap = /** @class */ (function () {
1684
1829
  }
1685
1830
  return null;
1686
1831
  };
1832
+ /** Creates an anchor element. */
1687
1833
  /**
1688
1834
  * Creates an anchor element.
1835
+ * @private
1689
1836
  * @return {?}
1690
1837
  */
1691
1838
  FocusTrap.prototype._createAnchor = /**
1692
1839
  * Creates an anchor element.
1840
+ * @private
1693
1841
  * @return {?}
1694
1842
  */
1695
1843
  function () {
@@ -1698,16 +1846,24 @@ FocusTrap = /** @class */ (function () {
1698
1846
  this._toggleAnchorTabIndex(this._enabled, anchor);
1699
1847
  anchor.classList.add('cdk-visually-hidden');
1700
1848
  anchor.classList.add('cdk-focus-trap-anchor');
1849
+ anchor.setAttribute('aria-hidden', 'true');
1701
1850
  return anchor;
1702
1851
  };
1703
1852
  /**
1704
1853
  * Toggles the `tabindex` of an anchor, based on the enabled state of the focus trap.
1854
+ * @param isEnabled Whether the focus trap is enabled.
1855
+ * @param anchor Anchor on which to toggle the tabindex.
1856
+ */
1857
+ /**
1858
+ * Toggles the `tabindex` of an anchor, based on the enabled state of the focus trap.
1859
+ * @private
1705
1860
  * @param {?} isEnabled Whether the focus trap is enabled.
1706
1861
  * @param {?} anchor Anchor on which to toggle the tabindex.
1707
1862
  * @return {?}
1708
1863
  */
1709
1864
  FocusTrap.prototype._toggleAnchorTabIndex = /**
1710
1865
  * Toggles the `tabindex` of an anchor, based on the enabled state of the focus trap.
1866
+ * @private
1711
1867
  * @param {?} isEnabled Whether the focus trap is enabled.
1712
1868
  * @param {?} anchor Anchor on which to toggle the tabindex.
1713
1869
  * @return {?}
@@ -1717,13 +1873,16 @@ FocusTrap = /** @class */ (function () {
1717
1873
  // element has a tabindex, the user might still hit it when navigating with the arrow keys.
1718
1874
  isEnabled ? anchor.setAttribute('tabindex', '0') : anchor.removeAttribute('tabindex');
1719
1875
  };
1876
+ /** Executes a function when the zone is stable. */
1720
1877
  /**
1721
1878
  * Executes a function when the zone is stable.
1879
+ * @private
1722
1880
  * @param {?} fn
1723
1881
  * @return {?}
1724
1882
  */
1725
1883
  FocusTrap.prototype._executeOnStable = /**
1726
1884
  * Executes a function when the zone is stable.
1885
+ * @private
1727
1886
  * @param {?} fn
1728
1887
  * @return {?}
1729
1888
  */
@@ -1855,7 +2014,7 @@ var CdkTrapFocus = /** @class */ (function () {
1855
2014
  function () {
1856
2015
  this.focusTrap.attachAnchors();
1857
2016
  if (this.autoCapture) {
1858
- this._previouslyFocusedElement = /** @type {?} */ (this._document.activeElement);
2017
+ this._previouslyFocusedElement = (/** @type {?} */ (this._document.activeElement));
1859
2018
  this.focusTrap.focusInitialElementWhenReady();
1860
2019
  }
1861
2020
  };
@@ -1891,8 +2050,10 @@ var CdkTrapFocus = /** @class */ (function () {
1891
2050
 
1892
2051
  /**
1893
2052
  * @fileoverview added by tsickle
1894
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
2053
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1895
2054
  */
2055
+ // The token for the live announcer element is defined in a separate file from LiveAnnouncer
2056
+ // as a workaround for https://github.com/angular/angular/issues/22559
1896
2057
  /** @type {?} */
1897
2058
  var LIVE_ANNOUNCER_ELEMENT_TOKEN = new InjectionToken('liveAnnouncerElement', {
1898
2059
  providedIn: 'root',
@@ -1908,7 +2069,7 @@ function LIVE_ANNOUNCER_ELEMENT_TOKEN_FACTORY() {
1908
2069
 
1909
2070
  /**
1910
2071
  * @fileoverview added by tsickle
1911
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
2072
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1912
2073
  */
1913
2074
  var LiveAnnouncer = /** @class */ (function () {
1914
2075
  function LiveAnnouncer(elementToken, _ngZone, _document) {
@@ -1948,7 +2109,7 @@ var LiveAnnouncer = /** @class */ (function () {
1948
2109
  this.clear();
1949
2110
  clearTimeout(this._previousTimeout);
1950
2111
  // TODO: ensure changing the politeness works on all environments we support.
1951
- this._liveElement.setAttribute('aria-live', /** @type {?} */ ((politeness)) || 'polite');
2112
+ this._liveElement.setAttribute('aria-live', (/** @type {?} */ (politeness)) || 'polite');
1952
2113
  // This 100ms timeout is necessary for some browser + screen-reader combinations:
1953
2114
  // - Both JAWS and NVDA over IE11 will not announce anything without a non-zero timeout.
1954
2115
  // - With Chrome and IE11 with NVDA or JAWS, a repeated (identical) message won't be read a
@@ -1999,13 +2160,15 @@ var LiveAnnouncer = /** @class */ (function () {
1999
2160
  clearTimeout(this._previousTimeout);
2000
2161
  if (this._liveElement && this._liveElement.parentNode) {
2001
2162
  this._liveElement.parentNode.removeChild(this._liveElement);
2002
- this._liveElement = /** @type {?} */ ((null));
2163
+ this._liveElement = (/** @type {?} */ (null));
2003
2164
  }
2004
2165
  };
2005
2166
  /**
2167
+ * @private
2006
2168
  * @return {?}
2007
2169
  */
2008
2170
  LiveAnnouncer.prototype._createLiveElement = /**
2171
+ * @private
2009
2172
  * @return {?}
2010
2173
  */
2011
2174
  function () {
@@ -2017,7 +2180,7 @@ var LiveAnnouncer = /** @class */ (function () {
2017
2180
  var liveEl = this._document.createElement('div');
2018
2181
  // Remove any old containers. This can happen when coming in from a server-side-rendered page.
2019
2182
  for (var i = 0; i < previousElements.length; i++) {
2020
- /** @type {?} */ ((previousElements[i].parentNode)).removeChild(previousElements[i]);
2183
+ (/** @type {?} */ (previousElements[i].parentNode)).removeChild(previousElements[i]);
2021
2184
  }
2022
2185
  liveEl.classList.add(elementClass);
2023
2186
  liveEl.classList.add('cdk-visually-hidden');
@@ -2075,6 +2238,7 @@ var CdkAriaLive = /** @class */ (function () {
2075
2238
  return _this._contentObserver
2076
2239
  .observe(_this._elementRef)
2077
2240
  .subscribe(function () {
2241
+ // Note that we use textContent here, rather than innerText, in order to avoid a reflow.
2078
2242
  /** @type {?} */
2079
2243
  var elementText = _this._elementRef.nativeElement.textContent;
2080
2244
  // The `MutationObserver` fires also for attribute
@@ -2130,9 +2294,10 @@ var CdkAriaLive = /** @class */ (function () {
2130
2294
  function LIVE_ANNOUNCER_PROVIDER_FACTORY(parentAnnouncer, liveElement, _document, ngZone) {
2131
2295
  return parentAnnouncer || new LiveAnnouncer(liveElement, ngZone, _document);
2132
2296
  }
2133
- /** *
2297
+ /**
2134
2298
  * \@docs-private \@deprecated \@breaking-change 8.0.0
2135
- @type {?} */
2299
+ * @type {?}
2300
+ */
2136
2301
  var LIVE_ANNOUNCER_PROVIDER = {
2137
2302
  // If there is already a LiveAnnouncer available, use that. Otherwise, provide a new one.
2138
2303
  provide: LiveAnnouncer,
@@ -2147,15 +2312,27 @@ var LIVE_ANNOUNCER_PROVIDER = {
2147
2312
 
2148
2313
  /**
2149
2314
  * @fileoverview added by tsickle
2150
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
2315
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2151
2316
  */
2317
+ // This is the value used by AngularJS Material. Through trial and error (on iPhone 6S) they found
2318
+ // that a value of around 650ms seems appropriate.
2152
2319
  /** @type {?} */
2153
2320
  var TOUCH_BUFFER_MS = 650;
2321
+ /**
2322
+ * Event listener options that enable capturing and also
2323
+ * mark the the listener as passive if the browser supports it.
2324
+ * @type {?}
2325
+ */
2326
+ var captureEventListenerOptions = normalizePassiveListenerOptions({
2327
+ passive: true,
2328
+ capture: true
2329
+ });
2154
2330
  /**
2155
2331
  * Monitors mouse and keyboard events to determine the cause of focus events.
2156
2332
  */
2157
2333
  var FocusMonitor = /** @class */ (function () {
2158
2334
  function FocusMonitor(_ngZone, _platform) {
2335
+ var _this = this;
2159
2336
  this._ngZone = _ngZone;
2160
2337
  this._platform = _platform;
2161
2338
  /**
@@ -2170,14 +2347,54 @@ var FocusMonitor = /** @class */ (function () {
2170
2347
  * Map of elements being monitored to their info.
2171
2348
  */
2172
2349
  this._elementInfo = new Map();
2173
- /**
2174
- * A map of global objects to lists of current listeners.
2175
- */
2176
- this._unregisterGlobalListeners = function () { };
2177
2350
  /**
2178
2351
  * The number of elements currently being monitored.
2179
2352
  */
2180
2353
  this._monitoredElementCount = 0;
2354
+ /**
2355
+ * Event listener for `keydown` events on the document.
2356
+ * Needs to be an arrow function in order to preserve the context when it gets bound.
2357
+ */
2358
+ this._documentKeydownListener = function () {
2359
+ // On keydown record the origin and clear any touch event that may be in progress.
2360
+ _this._lastTouchTarget = null;
2361
+ _this._setOriginForCurrentEventQueue('keyboard');
2362
+ };
2363
+ /**
2364
+ * Event listener for `mousedown` events on the document.
2365
+ * Needs to be an arrow function in order to preserve the context when it gets bound.
2366
+ */
2367
+ this._documentMousedownListener = function () {
2368
+ // On mousedown record the origin only if there is not touch
2369
+ // target, since a mousedown can happen as a result of a touch event.
2370
+ if (!_this._lastTouchTarget) {
2371
+ _this._setOriginForCurrentEventQueue('mouse');
2372
+ }
2373
+ };
2374
+ /**
2375
+ * Event listener for `touchstart` events on the document.
2376
+ * Needs to be an arrow function in order to preserve the context when it gets bound.
2377
+ */
2378
+ this._documentTouchstartListener = function (event) {
2379
+ // When the touchstart event fires the focus event is not yet in the event queue. This means
2380
+ // we can't rely on the trick used above (setting timeout of 1ms). Instead we wait 650ms to
2381
+ // see if a focus happens.
2382
+ if (_this._touchTimeoutId != null) {
2383
+ clearTimeout(_this._touchTimeoutId);
2384
+ }
2385
+ _this._lastTouchTarget = event.target;
2386
+ _this._touchTimeoutId = setTimeout(function () { return _this._lastTouchTarget = null; }, TOUCH_BUFFER_MS);
2387
+ };
2388
+ /**
2389
+ * Event listener for `focus` events on the window.
2390
+ * Needs to be an arrow function in order to preserve the context when it gets bound.
2391
+ */
2392
+ this._windowFocusListener = function () {
2393
+ // Make a note of when the window regains focus, so we can
2394
+ // restore the origin info for the focused element.
2395
+ _this._windowFocused = true;
2396
+ _this._windowFocusTimeoutId = setTimeout(function () { return _this._windowFocused = false; });
2397
+ };
2181
2398
  }
2182
2399
  /**
2183
2400
  * @param {?} element
@@ -2197,14 +2414,15 @@ var FocusMonitor = /** @class */ (function () {
2197
2414
  return of(null);
2198
2415
  }
2199
2416
  /** @type {?} */
2200
- var nativeElement = this._getNativeElement(element);
2417
+ var nativeElement = coerceElement(element);
2201
2418
  // Check if we're already monitoring this element.
2202
2419
  if (this._elementInfo.has(nativeElement)) {
2203
2420
  /** @type {?} */
2204
- var cachedInfo = this._elementInfo.get(nativeElement); /** @type {?} */
2205
- ((cachedInfo)).checkChildren = checkChildren;
2206
- return /** @type {?} */ ((cachedInfo)).subject.asObservable();
2421
+ var cachedInfo = this._elementInfo.get(nativeElement);
2422
+ (/** @type {?} */ (cachedInfo)).checkChildren = checkChildren;
2423
+ return (/** @type {?} */ (cachedInfo)).subject.asObservable();
2207
2424
  }
2425
+ // Create monitored element info.
2208
2426
  /** @type {?} */
2209
2427
  var info = {
2210
2428
  unlisten: function () { },
@@ -2213,6 +2431,7 @@ var FocusMonitor = /** @class */ (function () {
2213
2431
  };
2214
2432
  this._elementInfo.set(nativeElement, info);
2215
2433
  this._incrementMonitoredElementCount();
2434
+ // Start listening. We need to listen in capture phase since focus events don't bubble.
2216
2435
  /** @type {?} */
2217
2436
  var focusListener = function (event) { return _this._onFocus(event, nativeElement); };
2218
2437
  /** @type {?} */
@@ -2238,7 +2457,7 @@ var FocusMonitor = /** @class */ (function () {
2238
2457
  */
2239
2458
  function (element) {
2240
2459
  /** @type {?} */
2241
- var nativeElement = this._getNativeElement(element);
2460
+ var nativeElement = coerceElement(element);
2242
2461
  /** @type {?} */
2243
2462
  var elementInfo = this._elementInfo.get(nativeElement);
2244
2463
  if (elementInfo) {
@@ -2263,12 +2482,12 @@ var FocusMonitor = /** @class */ (function () {
2263
2482
  */
2264
2483
  function (element, origin, options) {
2265
2484
  /** @type {?} */
2266
- var nativeElement = this._getNativeElement(element);
2485
+ var nativeElement = coerceElement(element);
2267
2486
  this._setOriginForCurrentEventQueue(origin);
2268
2487
  // `focus` isn't available on the server
2269
2488
  if (typeof nativeElement.focus === 'function') {
2270
2489
  // Cast the element to `any`, because the TS typings don't have the `options` parameter yet.
2271
- (/** @type {?} */ (nativeElement)).focus(options);
2490
+ ((/** @type {?} */ (nativeElement))).focus(options);
2272
2491
  }
2273
2492
  };
2274
2493
  /**
@@ -2282,74 +2501,14 @@ var FocusMonitor = /** @class */ (function () {
2282
2501
  this._elementInfo.forEach(function (_info, element) { return _this.stopMonitoring(element); });
2283
2502
  };
2284
2503
  /**
2285
- * Register necessary event listeners on the document and window.
2286
- * @return {?}
2287
- */
2288
- FocusMonitor.prototype._registerGlobalListeners = /**
2289
- * Register necessary event listeners on the document and window.
2290
- * @return {?}
2291
- */
2292
- function () {
2293
- var _this = this;
2294
- // Do nothing if we're not on the browser platform.
2295
- if (!this._platform.isBrowser) {
2296
- return;
2297
- }
2298
- /** @type {?} */
2299
- var documentKeydownListener = function () {
2300
- _this._lastTouchTarget = null;
2301
- _this._setOriginForCurrentEventQueue('keyboard');
2302
- };
2303
- /** @type {?} */
2304
- var documentMousedownListener = function () {
2305
- if (!_this._lastTouchTarget) {
2306
- _this._setOriginForCurrentEventQueue('mouse');
2307
- }
2308
- };
2309
- /** @type {?} */
2310
- var documentTouchstartListener = function (event) {
2311
- if (_this._touchTimeoutId != null) {
2312
- clearTimeout(_this._touchTimeoutId);
2313
- }
2314
- _this._lastTouchTarget = event.target;
2315
- _this._touchTimeoutId = setTimeout(function () { return _this._lastTouchTarget = null; }, TOUCH_BUFFER_MS);
2316
- };
2317
- /** @type {?} */
2318
- var windowFocusListener = function () {
2319
- _this._windowFocused = true;
2320
- _this._windowFocusTimeoutId = setTimeout(function () { return _this._windowFocused = false; });
2321
- };
2322
- /** @type {?} */
2323
- var captureEventListenerOptions = normalizePassiveListenerOptions({
2324
- passive: true,
2325
- capture: true
2326
- });
2327
- // Note: we listen to events in the capture phase so we can detect them even if the user stops
2328
- // propagation.
2329
- this._ngZone.runOutsideAngular(function () {
2330
- document.addEventListener('keydown', documentKeydownListener, captureEventListenerOptions);
2331
- document.addEventListener('mousedown', documentMousedownListener, captureEventListenerOptions);
2332
- document.addEventListener('touchstart', documentTouchstartListener, captureEventListenerOptions);
2333
- window.addEventListener('focus', windowFocusListener);
2334
- });
2335
- this._unregisterGlobalListeners = function () {
2336
- document.removeEventListener('keydown', documentKeydownListener, captureEventListenerOptions);
2337
- document.removeEventListener('mousedown', documentMousedownListener, captureEventListenerOptions);
2338
- document.removeEventListener('touchstart', documentTouchstartListener, captureEventListenerOptions);
2339
- window.removeEventListener('focus', windowFocusListener);
2340
- // Clear timeouts for all potentially pending timeouts to prevent the leaks.
2341
- clearTimeout(_this._windowFocusTimeoutId);
2342
- clearTimeout(_this._touchTimeoutId);
2343
- clearTimeout(_this._originTimeoutId);
2344
- };
2345
- };
2346
- /**
2504
+ * @private
2347
2505
  * @param {?} element
2348
2506
  * @param {?} className
2349
2507
  * @param {?} shouldSet
2350
2508
  * @return {?}
2351
2509
  */
2352
2510
  FocusMonitor.prototype._toggleClass = /**
2511
+ * @private
2353
2512
  * @param {?} element
2354
2513
  * @param {?} className
2355
2514
  * @param {?} shouldSet
@@ -2365,12 +2524,19 @@ var FocusMonitor = /** @class */ (function () {
2365
2524
  };
2366
2525
  /**
2367
2526
  * Sets the focus classes on the element based on the given focus origin.
2527
+ * @param element The element to update the classes on.
2528
+ * @param origin The focus origin.
2529
+ */
2530
+ /**
2531
+ * Sets the focus classes on the element based on the given focus origin.
2532
+ * @private
2368
2533
  * @param {?} element The element to update the classes on.
2369
2534
  * @param {?=} origin The focus origin.
2370
2535
  * @return {?}
2371
2536
  */
2372
2537
  FocusMonitor.prototype._setClasses = /**
2373
2538
  * Sets the focus classes on the element based on the given focus origin.
2539
+ * @private
2374
2540
  * @param {?} element The element to update the classes on.
2375
2541
  * @param {?=} origin The focus origin.
2376
2542
  * @return {?}
@@ -2388,11 +2554,17 @@ var FocusMonitor = /** @class */ (function () {
2388
2554
  };
2389
2555
  /**
2390
2556
  * Sets the origin and schedules an async function to clear it at the end of the event queue.
2557
+ * @param origin The origin to set.
2558
+ */
2559
+ /**
2560
+ * Sets the origin and schedules an async function to clear it at the end of the event queue.
2561
+ * @private
2391
2562
  * @param {?} origin The origin to set.
2392
2563
  * @return {?}
2393
2564
  */
2394
2565
  FocusMonitor.prototype._setOriginForCurrentEventQueue = /**
2395
2566
  * Sets the origin and schedules an async function to clear it at the end of the event queue.
2567
+ * @private
2396
2568
  * @param {?} origin The origin to set.
2397
2569
  * @return {?}
2398
2570
  */
@@ -2408,15 +2580,39 @@ var FocusMonitor = /** @class */ (function () {
2408
2580
  };
2409
2581
  /**
2410
2582
  * Checks whether the given focus event was caused by a touchstart event.
2583
+ * @param event The focus event to check.
2584
+ * @returns Whether the event was caused by a touch.
2585
+ */
2586
+ /**
2587
+ * Checks whether the given focus event was caused by a touchstart event.
2588
+ * @private
2411
2589
  * @param {?} event The focus event to check.
2412
2590
  * @return {?} Whether the event was caused by a touch.
2413
2591
  */
2414
2592
  FocusMonitor.prototype._wasCausedByTouch = /**
2415
2593
  * Checks whether the given focus event was caused by a touchstart event.
2594
+ * @private
2416
2595
  * @param {?} event The focus event to check.
2417
2596
  * @return {?} Whether the event was caused by a touch.
2418
2597
  */
2419
2598
  function (event) {
2599
+ // Note(mmalerba): This implementation is not quite perfect, there is a small edge case.
2600
+ // Consider the following dom structure:
2601
+ //
2602
+ // <div #parent tabindex="0" cdkFocusClasses>
2603
+ // <div #child (click)="#parent.focus()"></div>
2604
+ // </div>
2605
+ //
2606
+ // If the user touches the #child element and the #parent is programmatically focused as a
2607
+ // result, this code will still consider it to have been caused by the touch event and will
2608
+ // apply the cdk-touch-focused class rather than the cdk-program-focused class. This is a
2609
+ // relatively small edge-case that can be worked around by using
2610
+ // focusVia(parentEl, 'program') to focus the parent element.
2611
+ //
2612
+ // If we decide that we absolutely must handle this case correctly, we can do so by listening
2613
+ // for the first focus event after the touchstart, and then the first blur event after that
2614
+ // focus event. When that blur event fires we know that whatever follows is not a result of the
2615
+ // touchstart.
2420
2616
  /** @type {?} */
2421
2617
  var focusTarget = event.target;
2422
2618
  return this._lastTouchTarget instanceof Node && focusTarget instanceof Node &&
@@ -2424,22 +2620,45 @@ var FocusMonitor = /** @class */ (function () {
2424
2620
  };
2425
2621
  /**
2426
2622
  * Handles focus events on a registered element.
2623
+ * @param event The focus event.
2624
+ * @param element The monitored element.
2625
+ */
2626
+ /**
2627
+ * Handles focus events on a registered element.
2628
+ * @private
2427
2629
  * @param {?} event The focus event.
2428
2630
  * @param {?} element The monitored element.
2429
2631
  * @return {?}
2430
2632
  */
2431
2633
  FocusMonitor.prototype._onFocus = /**
2432
2634
  * Handles focus events on a registered element.
2635
+ * @private
2433
2636
  * @param {?} event The focus event.
2434
2637
  * @param {?} element The monitored element.
2435
2638
  * @return {?}
2436
2639
  */
2437
2640
  function (event, element) {
2641
+ // NOTE(mmalerba): We currently set the classes based on the focus origin of the most recent
2642
+ // focus event affecting the monitored element. If we want to use the origin of the first event
2643
+ // instead we should check for the cdk-focused class here and return if the element already has
2644
+ // it. (This only matters for elements that have includesChildren = true).
2645
+ // NOTE(mmalerba): We currently set the classes based on the focus origin of the most recent
2646
+ // focus event affecting the monitored element. If we want to use the origin of the first event
2647
+ // instead we should check for the cdk-focused class here and return if the element already has
2648
+ // it. (This only matters for elements that have includesChildren = true).
2649
+ // If we are not counting child-element-focus as focused, make sure that the event target is the
2650
+ // monitored element itself.
2438
2651
  /** @type {?} */
2439
2652
  var elementInfo = this._elementInfo.get(element);
2440
2653
  if (!elementInfo || (!elementInfo.checkChildren && element !== event.target)) {
2441
2654
  return;
2442
2655
  }
2656
+ // If we couldn't detect a cause for the focus event, it's due to one of three reasons:
2657
+ // 1) The window has just regained focus, in which case we want to restore the focused state of
2658
+ // the element from before the window blurred.
2659
+ // 2) It was caused by a touch event, in which case we mark the origin as 'touch'.
2660
+ // 3) The element was programmatically focused, in which case we should mark the origin as
2661
+ // 'program'.
2443
2662
  /** @type {?} */
2444
2663
  var origin = this._origin;
2445
2664
  if (!origin) {
@@ -2475,6 +2694,8 @@ var FocusMonitor = /** @class */ (function () {
2475
2694
  * @return {?}
2476
2695
  */
2477
2696
  function (event, element) {
2697
+ // If we are counting child-element-focus as focused, make sure that we aren't just blurring in
2698
+ // order to focus another child of the monitored element.
2478
2699
  /** @type {?} */
2479
2700
  var elementInfo = this._elementInfo.get(element);
2480
2701
  if (!elementInfo || (elementInfo.checkChildren && event.relatedTarget instanceof Node &&
@@ -2485,11 +2706,13 @@ var FocusMonitor = /** @class */ (function () {
2485
2706
  this._emitOrigin(elementInfo.subject, null);
2486
2707
  };
2487
2708
  /**
2709
+ * @private
2488
2710
  * @param {?} subject
2489
2711
  * @param {?} origin
2490
2712
  * @return {?}
2491
2713
  */
2492
2714
  FocusMonitor.prototype._emitOrigin = /**
2715
+ * @private
2493
2716
  * @param {?} subject
2494
2717
  * @param {?} origin
2495
2718
  * @return {?}
@@ -2498,41 +2721,48 @@ var FocusMonitor = /** @class */ (function () {
2498
2721
  this._ngZone.run(function () { return subject.next(origin); });
2499
2722
  };
2500
2723
  /**
2724
+ * @private
2501
2725
  * @return {?}
2502
2726
  */
2503
2727
  FocusMonitor.prototype._incrementMonitoredElementCount = /**
2728
+ * @private
2504
2729
  * @return {?}
2505
2730
  */
2506
2731
  function () {
2732
+ var _this = this;
2507
2733
  // Register global listeners when first element is monitored.
2508
- if (++this._monitoredElementCount == 1) {
2509
- this._registerGlobalListeners();
2734
+ if (++this._monitoredElementCount == 1 && this._platform.isBrowser) {
2735
+ // Note: we listen to events in the capture phase so we
2736
+ // can detect them even if the user stops propagation.
2737
+ this._ngZone.runOutsideAngular(function () {
2738
+ document.addEventListener('keydown', _this._documentKeydownListener, captureEventListenerOptions);
2739
+ document.addEventListener('mousedown', _this._documentMousedownListener, captureEventListenerOptions);
2740
+ document.addEventListener('touchstart', _this._documentTouchstartListener, captureEventListenerOptions);
2741
+ window.addEventListener('focus', _this._windowFocusListener);
2742
+ });
2510
2743
  }
2511
2744
  };
2512
2745
  /**
2746
+ * @private
2513
2747
  * @return {?}
2514
2748
  */
2515
2749
  FocusMonitor.prototype._decrementMonitoredElementCount = /**
2750
+ * @private
2516
2751
  * @return {?}
2517
2752
  */
2518
2753
  function () {
2519
2754
  // Unregister global listeners when last element is unmonitored.
2520
2755
  if (!--this._monitoredElementCount) {
2521
- this._unregisterGlobalListeners();
2522
- this._unregisterGlobalListeners = function () { };
2756
+ document.removeEventListener('keydown', this._documentKeydownListener, captureEventListenerOptions);
2757
+ document.removeEventListener('mousedown', this._documentMousedownListener, captureEventListenerOptions);
2758
+ document.removeEventListener('touchstart', this._documentTouchstartListener, captureEventListenerOptions);
2759
+ window.removeEventListener('focus', this._windowFocusListener);
2760
+ // Clear timeouts for all potentially pending timeouts to prevent the leaks.
2761
+ clearTimeout(this._windowFocusTimeoutId);
2762
+ clearTimeout(this._touchTimeoutId);
2763
+ clearTimeout(this._originTimeoutId);
2523
2764
  }
2524
2765
  };
2525
- /**
2526
- * @param {?} element
2527
- * @return {?}
2528
- */
2529
- FocusMonitor.prototype._getNativeElement = /**
2530
- * @param {?} element
2531
- * @return {?}
2532
- */
2533
- function (element) {
2534
- return element instanceof ElementRef ? element.nativeElement : element;
2535
- };
2536
2766
  FocusMonitor.decorators = [
2537
2767
  { type: Injectable, args: [{ providedIn: 'root' },] },
2538
2768
  ];
@@ -2597,9 +2827,10 @@ var CdkMonitorFocus = /** @class */ (function () {
2597
2827
  function FOCUS_MONITOR_PROVIDER_FACTORY(parentDispatcher, ngZone, platform) {
2598
2828
  return parentDispatcher || new FocusMonitor(ngZone, platform);
2599
2829
  }
2600
- /** *
2830
+ /**
2601
2831
  * \@docs-private \@deprecated \@breaking-change 8.0.0
2602
- @type {?} */
2832
+ * @type {?}
2833
+ */
2603
2834
  var FOCUS_MONITOR_PROVIDER = {
2604
2835
  // If there is already a FocusMonitor available, use that. Otherwise, provide a new one.
2605
2836
  provide: FocusMonitor,
@@ -2609,7 +2840,7 @@ var FOCUS_MONITOR_PROVIDER = {
2609
2840
 
2610
2841
  /**
2611
2842
  * @fileoverview added by tsickle
2612
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
2843
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2613
2844
  */
2614
2845
 
2615
2846
  /**
@@ -2627,7 +2858,7 @@ function isFakeMousedownFromScreenReader(event) {
2627
2858
 
2628
2859
  /**
2629
2860
  * @fileoverview added by tsickle
2630
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
2861
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2631
2862
  */
2632
2863
  var A11yModule = /** @class */ (function () {
2633
2864
  function A11yModule() {
@@ -2644,12 +2875,12 @@ var A11yModule = /** @class */ (function () {
2644
2875
 
2645
2876
  /**
2646
2877
  * @fileoverview added by tsickle
2647
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
2878
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2648
2879
  */
2649
2880
 
2650
2881
  /**
2651
2882
  * @fileoverview added by tsickle
2652
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
2883
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2653
2884
  */
2654
2885
 
2655
2886
  export { ARIA_DESCRIBER_PROVIDER_FACTORY, MESSAGES_CONTAINER_ID, CDK_DESCRIBEDBY_ID_PREFIX, CDK_DESCRIBEDBY_HOST_ATTRIBUTE, AriaDescriber, ARIA_DESCRIBER_PROVIDER, ActiveDescendantKeyManager, FocusKeyManager, ListKeyManager, FocusTrap, FocusTrapFactory, CdkTrapFocus, InteractivityChecker, LIVE_ANNOUNCER_PROVIDER_FACTORY, LiveAnnouncer, CdkAriaLive, LIVE_ANNOUNCER_PROVIDER, LIVE_ANNOUNCER_ELEMENT_TOKEN_FACTORY, LIVE_ANNOUNCER_ELEMENT_TOKEN, FOCUS_MONITOR_PROVIDER_FACTORY, TOUCH_BUFFER_MS, FocusMonitor, CdkMonitorFocus, FOCUS_MONITOR_PROVIDER, isFakeMousedownFromScreenReader, A11yModule };