@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
@@ -42,12 +42,13 @@ function __extends(d, b) {
42
42
 
43
43
  /**
44
44
  * @fileoverview added by tsickle
45
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
45
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
46
46
  */
47
47
 
48
- /** *
48
+ /**
49
49
  * IDs are deliminated by an empty space, as per the spec.
50
- @type {?} */
50
+ * @type {?}
51
+ */
51
52
  var ID_DELIMINATOR = ' ';
52
53
  /**
53
54
  * Adds the given ID to the specified ARIA attribute on an element.
@@ -95,31 +96,37 @@ function getAriaReferenceIds(el, attr) {
95
96
 
96
97
  /**
97
98
  * @fileoverview added by tsickle
98
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
99
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
99
100
  */
100
- /** *
101
+ /**
101
102
  * ID used for the body container where all messages are appended.
102
- @type {?} */
103
+ * @type {?}
104
+ */
103
105
  var MESSAGES_CONTAINER_ID = 'cdk-describedby-message-container';
104
- /** *
106
+ /**
105
107
  * ID prefix used for each created message element.
106
- @type {?} */
108
+ * @type {?}
109
+ */
107
110
  var CDK_DESCRIBEDBY_ID_PREFIX = 'cdk-describedby-message';
108
- /** *
111
+ /**
109
112
  * Attribute given to each host element that is described by a message element.
110
- @type {?} */
113
+ * @type {?}
114
+ */
111
115
  var CDK_DESCRIBEDBY_HOST_ATTRIBUTE = 'cdk-describedby-host';
112
- /** *
116
+ /**
113
117
  * Global incremental identifier for each registered message element.
114
- @type {?} */
118
+ * @type {?}
119
+ */
115
120
  var nextId = 0;
116
- /** *
121
+ /**
117
122
  * Global map of all registered message elements that have been placed into the document.
118
- @type {?} */
123
+ * @type {?}
124
+ */
119
125
  var messageRegistry = new Map();
120
- /** *
126
+ /**
121
127
  * Container for all registered messages.
122
- @type {?} */
128
+ * @type {?}
129
+ */
123
130
  var messagesContainer = null;
124
131
  /**
125
132
  * Utility that creates visually hidden elements with a message content. Useful for elements that
@@ -216,12 +223,18 @@ var AriaDescriber = /** @class */ (function () {
216
223
  /**
217
224
  * Creates a new element in the visually hidden message container element with the message
218
225
  * as its content and adds it to the message registry.
226
+ */
227
+ /**
228
+ * Creates a new element in the visually hidden message container element with the message
229
+ * as its content and adds it to the message registry.
230
+ * @private
219
231
  * @param {?} message
220
232
  * @return {?}
221
233
  */
222
234
  AriaDescriber.prototype._createMessageElement = /**
223
235
  * Creates a new element in the visually hidden message container element with the message
224
236
  * as its content and adds it to the message registry.
237
+ * @private
225
238
  * @param {?} message
226
239
  * @return {?}
227
240
  */
@@ -229,18 +242,21 @@ var AriaDescriber = /** @class */ (function () {
229
242
  /** @type {?} */
230
243
  var messageElement = this._document.createElement('div');
231
244
  messageElement.setAttribute('id', CDK_DESCRIBEDBY_ID_PREFIX + "-" + nextId++);
232
- messageElement.appendChild(/** @type {?} */ ((this._document.createTextNode(message))));
233
- this._createMessagesContainer(); /** @type {?} */
234
- ((messagesContainer)).appendChild(messageElement);
245
+ messageElement.appendChild((/** @type {?} */ (this._document.createTextNode(message))));
246
+ this._createMessagesContainer();
247
+ (/** @type {?} */ (messagesContainer)).appendChild(messageElement);
235
248
  messageRegistry.set(message, { messageElement: messageElement, referenceCount: 0 });
236
249
  };
250
+ /** Deletes the message element from the global messages container. */
237
251
  /**
238
252
  * Deletes the message element from the global messages container.
253
+ * @private
239
254
  * @param {?} message
240
255
  * @return {?}
241
256
  */
242
257
  AriaDescriber.prototype._deleteMessageElement = /**
243
258
  * Deletes the message element from the global messages container.
259
+ * @private
244
260
  * @param {?} message
245
261
  * @return {?}
246
262
  */
@@ -254,12 +270,15 @@ var AriaDescriber = /** @class */ (function () {
254
270
  }
255
271
  messageRegistry.delete(message);
256
272
  };
273
+ /** Creates the global container for all aria-describedby messages. */
257
274
  /**
258
275
  * Creates the global container for all aria-describedby messages.
276
+ * @private
259
277
  * @return {?}
260
278
  */
261
279
  AriaDescriber.prototype._createMessagesContainer = /**
262
280
  * Creates the global container for all aria-describedby messages.
281
+ * @private
263
282
  * @return {?}
264
283
  */
265
284
  function () {
@@ -271,7 +290,7 @@ var AriaDescriber = /** @class */ (function () {
271
290
  // old container so we don't get duplicates. Doing this, instead of emptying the previous
272
291
  // container, should be slightly faster.
273
292
  if (preExistingContainer) {
274
- /** @type {?} */ ((preExistingContainer.parentNode)).removeChild(preExistingContainer);
293
+ (/** @type {?} */ (preExistingContainer.parentNode)).removeChild(preExistingContainer);
275
294
  }
276
295
  messagesContainer = this._document.createElement('div');
277
296
  messagesContainer.id = MESSAGES_CONTAINER_ID;
@@ -280,12 +299,15 @@ var AriaDescriber = /** @class */ (function () {
280
299
  this._document.body.appendChild(messagesContainer);
281
300
  }
282
301
  };
302
+ /** Deletes the global messages container. */
283
303
  /**
284
304
  * Deletes the global messages container.
305
+ * @private
285
306
  * @return {?}
286
307
  */
287
308
  AriaDescriber.prototype._deleteMessagesContainer = /**
288
309
  * Deletes the global messages container.
310
+ * @private
289
311
  * @return {?}
290
312
  */
291
313
  function () {
@@ -294,17 +316,21 @@ var AriaDescriber = /** @class */ (function () {
294
316
  messagesContainer = null;
295
317
  }
296
318
  };
319
+ /** Removes all cdk-describedby messages that are hosted through the element. */
297
320
  /**
298
321
  * Removes all cdk-describedby messages that are hosted through the element.
322
+ * @private
299
323
  * @param {?} element
300
324
  * @return {?}
301
325
  */
302
326
  AriaDescriber.prototype._removeCdkDescribedByReferenceIds = /**
303
327
  * Removes all cdk-describedby messages that are hosted through the element.
328
+ * @private
304
329
  * @param {?} element
305
330
  * @return {?}
306
331
  */
307
332
  function (element) {
333
+ // Remove all aria-describedby reference IDs that are prefixed by CDK_DESCRIBEDBY_ID_PREFIX
308
334
  /** @type {?} */
309
335
  var originalReferenceIds = getAriaReferenceIds(element, 'aria-describedby')
310
336
  .filter(function (id) { return id.indexOf(CDK_DESCRIBEDBY_ID_PREFIX) != 0; });
@@ -313,6 +339,11 @@ var AriaDescriber = /** @class */ (function () {
313
339
  /**
314
340
  * Adds a message reference to the element using aria-describedby and increments the registered
315
341
  * message's reference count.
342
+ */
343
+ /**
344
+ * Adds a message reference to the element using aria-describedby and increments the registered
345
+ * message's reference count.
346
+ * @private
316
347
  * @param {?} element
317
348
  * @param {?} message
318
349
  * @return {?}
@@ -320,13 +351,14 @@ var AriaDescriber = /** @class */ (function () {
320
351
  AriaDescriber.prototype._addMessageReference = /**
321
352
  * Adds a message reference to the element using aria-describedby and increments the registered
322
353
  * message's reference count.
354
+ * @private
323
355
  * @param {?} element
324
356
  * @param {?} message
325
357
  * @return {?}
326
358
  */
327
359
  function (element, message) {
328
360
  /** @type {?} */
329
- var registeredMessage = /** @type {?} */ ((messageRegistry.get(message)));
361
+ var registeredMessage = (/** @type {?} */ (messageRegistry.get(message)));
330
362
  // Add the aria-describedby reference and set the
331
363
  // describedby_host attribute to mark the element.
332
364
  addAriaReferencedId(element, 'aria-describedby', registeredMessage.messageElement.id);
@@ -336,6 +368,11 @@ var AriaDescriber = /** @class */ (function () {
336
368
  /**
337
369
  * Removes a message reference from the element using aria-describedby
338
370
  * and decrements the registered message's reference count.
371
+ */
372
+ /**
373
+ * Removes a message reference from the element using aria-describedby
374
+ * and decrements the registered message's reference count.
375
+ * @private
339
376
  * @param {?} element
340
377
  * @param {?} message
341
378
  * @return {?}
@@ -343,25 +380,29 @@ var AriaDescriber = /** @class */ (function () {
343
380
  AriaDescriber.prototype._removeMessageReference = /**
344
381
  * Removes a message reference from the element using aria-describedby
345
382
  * and decrements the registered message's reference count.
383
+ * @private
346
384
  * @param {?} element
347
385
  * @param {?} message
348
386
  * @return {?}
349
387
  */
350
388
  function (element, message) {
351
389
  /** @type {?} */
352
- var registeredMessage = /** @type {?} */ ((messageRegistry.get(message)));
390
+ var registeredMessage = (/** @type {?} */ (messageRegistry.get(message)));
353
391
  registeredMessage.referenceCount--;
354
392
  removeAriaReferencedId(element, 'aria-describedby', registeredMessage.messageElement.id);
355
393
  element.removeAttribute(CDK_DESCRIBEDBY_HOST_ATTRIBUTE);
356
394
  };
395
+ /** Returns true if the element has been described by the provided message ID. */
357
396
  /**
358
397
  * Returns true if the element has been described by the provided message ID.
398
+ * @private
359
399
  * @param {?} element
360
400
  * @param {?} message
361
401
  * @return {?}
362
402
  */
363
403
  AriaDescriber.prototype._isElementDescribedByMessage = /**
364
404
  * Returns true if the element has been described by the provided message ID.
405
+ * @private
365
406
  * @param {?} element
366
407
  * @param {?} message
367
408
  * @return {?}
@@ -375,14 +416,17 @@ var AriaDescriber = /** @class */ (function () {
375
416
  var messageId = registeredMessage && registeredMessage.messageElement.id;
376
417
  return !!messageId && referenceIds.indexOf(messageId) != -1;
377
418
  };
419
+ /** Determines whether a message can be described on a particular element. */
378
420
  /**
379
421
  * Determines whether a message can be described on a particular element.
422
+ * @private
380
423
  * @param {?} element
381
424
  * @param {?} message
382
425
  * @return {?}
383
426
  */
384
427
  AriaDescriber.prototype._canBeDescribed = /**
385
428
  * Determines whether a message can be described on a particular element.
429
+ * @private
386
430
  * @param {?} element
387
431
  * @param {?} message
388
432
  * @return {?}
@@ -410,32 +454,30 @@ var AriaDescriber = /** @class */ (function () {
410
454
  function ARIA_DESCRIBER_PROVIDER_FACTORY(parentDispatcher, _document) {
411
455
  return parentDispatcher || new AriaDescriber(_document);
412
456
  }
413
- /** *
457
+ /**
414
458
  * \@docs-private \@deprecated \@breaking-change 8.0.0
415
- @type {?} */
459
+ * @type {?}
460
+ */
416
461
  var ARIA_DESCRIBER_PROVIDER = {
417
462
  // If there is already an AriaDescriber available, use that. Otherwise, provide a new one.
418
463
  provide: AriaDescriber,
419
464
  deps: [
420
465
  [new core.Optional(), new core.SkipSelf(), AriaDescriber],
421
- /** @type {?} */ (common.DOCUMENT)
466
+ (/** @type {?} */ (common.DOCUMENT))
422
467
  ],
423
468
  useFactory: ARIA_DESCRIBER_PROVIDER_FACTORY
424
469
  };
425
470
 
426
471
  /**
427
472
  * @fileoverview added by tsickle
428
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
473
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
429
474
  */
430
- // unsupported: template constraints.
431
475
  /**
432
476
  * This class manages keyboard events for selectable lists. If you pass it a query list
433
477
  * of items, it will set the active item correctly when arrow events occur.
434
478
  * @template T
435
479
  */
436
- var
437
- // unsupported: template constraints.
438
- /**
480
+ var /**
439
481
  * This class manages keyboard events for selectable lists. If you pass it a query list
440
482
  * of items, it will set the active item correctly when arrow events occur.
441
483
  * @template T
@@ -445,6 +487,7 @@ ListKeyManager = /** @class */ (function () {
445
487
  var _this = this;
446
488
  this._items = _items;
447
489
  this._activeItemIndex = -1;
490
+ this._activeItem = null;
448
491
  this._wrap = false;
449
492
  this._letterKeyStream = new rxjs.Subject();
450
493
  this._typeaheadSubscription = rxjs.Subscription.EMPTY;
@@ -455,6 +498,7 @@ ListKeyManager = /** @class */ (function () {
455
498
  * by the key manager. By default, disabled items are skipped.
456
499
  */
457
500
  this._skipPredicateFn = function (item) { return item.disabled; };
501
+ // Buffer for the letters that the user has pressed when the typeahead option is turned on.
458
502
  this._pressedLetters = [];
459
503
  /**
460
504
  * Stream that emits any time the TAB key is pressed, so components can react
@@ -490,18 +534,22 @@ ListKeyManager = /** @class */ (function () {
490
534
  /**
491
535
  * Sets the predicate function that determines which items should be skipped by the
492
536
  * list key manager.
537
+ * @template THIS
538
+ * @this {THIS}
493
539
  * @param {?} predicate Function that determines whether the given item should be skipped.
494
- * @return {?}
540
+ * @return {THIS}
495
541
  */
496
542
  ListKeyManager.prototype.skipPredicate = /**
497
543
  * Sets the predicate function that determines which items should be skipped by the
498
544
  * list key manager.
545
+ * @template THIS
546
+ * @this {THIS}
499
547
  * @param {?} predicate Function that determines whether the given item should be skipped.
500
- * @return {?}
548
+ * @return {THIS}
501
549
  */
502
550
  function (predicate) {
503
- this._skipPredicateFn = predicate;
504
- return this;
551
+ (/** @type {?} */ (this))._skipPredicateFn = predicate;
552
+ return (/** @type {?} */ (this));
505
553
  };
506
554
  /**
507
555
  * Configures wrapping mode, which determines whether the active item will wrap to
@@ -511,19 +559,23 @@ ListKeyManager = /** @class */ (function () {
511
559
  /**
512
560
  * Configures wrapping mode, which determines whether the active item will wrap to
513
561
  * the other end of list when there are no more items in the given direction.
562
+ * @template THIS
563
+ * @this {THIS}
514
564
  * @param {?=} shouldWrap Whether the list should wrap when reaching the end.
515
- * @return {?}
565
+ * @return {THIS}
516
566
  */
517
567
  ListKeyManager.prototype.withWrap = /**
518
568
  * Configures wrapping mode, which determines whether the active item will wrap to
519
569
  * the other end of list when there are no more items in the given direction.
570
+ * @template THIS
571
+ * @this {THIS}
520
572
  * @param {?=} shouldWrap Whether the list should wrap when reaching the end.
521
- * @return {?}
573
+ * @return {THIS}
522
574
  */
523
575
  function (shouldWrap) {
524
576
  if (shouldWrap === void 0) { shouldWrap = true; }
525
- this._wrap = shouldWrap;
526
- return this;
577
+ (/** @type {?} */ (this))._wrap = shouldWrap;
578
+ return (/** @type {?} */ (this));
527
579
  };
528
580
  /**
529
581
  * Configures whether the key manager should be able to move the selection vertically.
@@ -531,18 +583,22 @@ ListKeyManager = /** @class */ (function () {
531
583
  */
532
584
  /**
533
585
  * Configures whether the key manager should be able to move the selection vertically.
586
+ * @template THIS
587
+ * @this {THIS}
534
588
  * @param {?=} enabled Whether vertical selection should be enabled.
535
- * @return {?}
589
+ * @return {THIS}
536
590
  */
537
591
  ListKeyManager.prototype.withVerticalOrientation = /**
538
592
  * Configures whether the key manager should be able to move the selection vertically.
593
+ * @template THIS
594
+ * @this {THIS}
539
595
  * @param {?=} enabled Whether vertical selection should be enabled.
540
- * @return {?}
596
+ * @return {THIS}
541
597
  */
542
598
  function (enabled) {
543
599
  if (enabled === void 0) { enabled = true; }
544
- this._vertical = enabled;
545
- return this;
600
+ (/** @type {?} */ (this))._vertical = enabled;
601
+ return (/** @type {?} */ (this));
546
602
  };
547
603
  /**
548
604
  * Configures the key manager to move the selection horizontally.
@@ -552,18 +608,22 @@ ListKeyManager = /** @class */ (function () {
552
608
  /**
553
609
  * Configures the key manager to move the selection horizontally.
554
610
  * Passing in `null` will disable horizontal movement.
611
+ * @template THIS
612
+ * @this {THIS}
555
613
  * @param {?} direction Direction in which the selection can be moved.
556
- * @return {?}
614
+ * @return {THIS}
557
615
  */
558
616
  ListKeyManager.prototype.withHorizontalOrientation = /**
559
617
  * Configures the key manager to move the selection horizontally.
560
618
  * Passing in `null` will disable horizontal movement.
619
+ * @template THIS
620
+ * @this {THIS}
561
621
  * @param {?} direction Direction in which the selection can be moved.
562
- * @return {?}
622
+ * @return {THIS}
563
623
  */
564
624
  function (direction) {
565
- this._horizontal = direction;
566
- return this;
625
+ (/** @type {?} */ (this))._horizontal = direction;
626
+ return (/** @type {?} */ (this));
567
627
  };
568
628
  /**
569
629
  * Modifier keys which are allowed to be held down and whose default actions will be prevented
@@ -572,18 +632,22 @@ ListKeyManager = /** @class */ (function () {
572
632
  /**
573
633
  * Modifier keys which are allowed to be held down and whose default actions will be prevented
574
634
  * as the user is pressing the arrow keys. Defaults to not allowing any modifier keys.
635
+ * @template THIS
636
+ * @this {THIS}
575
637
  * @param {?} keys
576
- * @return {?}
638
+ * @return {THIS}
577
639
  */
578
640
  ListKeyManager.prototype.withAllowedModifierKeys = /**
579
641
  * Modifier keys which are allowed to be held down and whose default actions will be prevented
580
642
  * as the user is pressing the arrow keys. Defaults to not allowing any modifier keys.
643
+ * @template THIS
644
+ * @this {THIS}
581
645
  * @param {?} keys
582
- * @return {?}
646
+ * @return {THIS}
583
647
  */
584
648
  function (keys) {
585
- this._allowedModifierKeys = keys;
586
- return this;
649
+ (/** @type {?} */ (this))._allowedModifierKeys = keys;
650
+ return (/** @type {?} */ (this));
587
651
  };
588
652
  /**
589
653
  * Turns on typeahead mode which allows users to set the active item by typing.
@@ -591,42 +655,47 @@ ListKeyManager = /** @class */ (function () {
591
655
  */
592
656
  /**
593
657
  * Turns on typeahead mode which allows users to set the active item by typing.
658
+ * @template THIS
659
+ * @this {THIS}
594
660
  * @param {?=} debounceInterval Time to wait after the last keystroke before setting the active item.
595
- * @return {?}
661
+ * @return {THIS}
596
662
  */
597
663
  ListKeyManager.prototype.withTypeAhead = /**
598
664
  * Turns on typeahead mode which allows users to set the active item by typing.
665
+ * @template THIS
666
+ * @this {THIS}
599
667
  * @param {?=} debounceInterval Time to wait after the last keystroke before setting the active item.
600
- * @return {?}
668
+ * @return {THIS}
601
669
  */
602
670
  function (debounceInterval) {
603
671
  var _this = this;
604
672
  if (debounceInterval === void 0) { debounceInterval = 200; }
605
- if (this._items.length && this._items.some(function (item) { return typeof item.getLabel !== 'function'; })) {
673
+ if ((/** @type {?} */ (this))._items.length && (/** @type {?} */ (this))._items.some(function (item) { return typeof item.getLabel !== 'function'; })) {
606
674
  throw Error('ListKeyManager items in typeahead mode must implement the `getLabel` method.');
607
675
  }
608
- this._typeaheadSubscription.unsubscribe();
676
+ (/** @type {?} */ (this))._typeaheadSubscription.unsubscribe();
609
677
  // Debounce the presses of non-navigational keys, collect the ones that correspond to letters
610
678
  // and convert those letters back into a string. Afterwards find the first item that starts
611
679
  // with that string and select it.
612
- this._typeaheadSubscription = this._letterKeyStream.pipe(operators.tap(function (keyCode) { return _this._pressedLetters.push(keyCode); }), operators.debounceTime(debounceInterval), operators.filter(function () { return _this._pressedLetters.length > 0; }), operators.map(function () { return _this._pressedLetters.join(''); })).subscribe(function (inputString) {
680
+ (/** @type {?} */ (this))._typeaheadSubscription = (/** @type {?} */ (this))._letterKeyStream.pipe(operators.tap(function (keyCode) { return (/** @type {?} */ (_this))._pressedLetters.push(keyCode); }), operators.debounceTime(debounceInterval), operators.filter(function () { return (/** @type {?} */ (_this))._pressedLetters.length > 0; }), operators.map(function () { return (/** @type {?} */ (_this))._pressedLetters.join(''); })).subscribe(function (inputString) {
613
681
  /** @type {?} */
614
- var items = _this._getItemsArray();
682
+ var items = (/** @type {?} */ (_this))._getItemsArray();
615
683
  // Start at 1 because we want to start searching at the item immediately
616
684
  // following the current active item.
617
685
  for (var i = 1; i < items.length + 1; i++) {
618
686
  /** @type {?} */
619
- var index = (_this._activeItemIndex + i) % items.length;
687
+ var index = ((/** @type {?} */ (_this))._activeItemIndex + i) % items.length;
620
688
  /** @type {?} */
621
689
  var item = items[index];
622
- if (!_this._skipPredicateFn(item) && /** @type {?} */ ((item.getLabel))().toUpperCase().trim().indexOf(inputString) === 0) {
623
- _this.setActiveItem(index);
690
+ if (!(/** @type {?} */ (_this))._skipPredicateFn(item) &&
691
+ (/** @type {?} */ (item.getLabel))().toUpperCase().trim().indexOf(inputString) === 0) {
692
+ (/** @type {?} */ (_this)).setActiveItem(index);
624
693
  break;
625
694
  }
626
695
  }
627
- _this._pressedLetters = [];
696
+ (/** @type {?} */ (_this))._pressedLetters = [];
628
697
  });
629
- return this;
698
+ return (/** @type {?} */ (this));
630
699
  };
631
700
  /**
632
701
  * @param {?} item
@@ -705,13 +774,15 @@ ListKeyManager = /** @class */ (function () {
705
774
  return;
706
775
  }
707
776
  default:
708
- // Attempt to use the `event.key` which also maps it to the user's keyboard language,
709
- // otherwise fall back to resolving alphanumeric characters via the keyCode.
710
- if (event.key && event.key.length === 1) {
711
- this._letterKeyStream.next(event.key.toLocaleUpperCase());
712
- }
713
- else if ((keyCode >= keycodes.A && keyCode <= keycodes.Z) || (keyCode >= keycodes.ZERO && keyCode <= keycodes.NINE)) {
714
- this._letterKeyStream.next(String.fromCharCode(keyCode));
777
+ if (isModifierAllowed || keycodes.hasModifierKey(event, 'shiftKey')) {
778
+ // Attempt to use the `event.key` which also maps it to the user's keyboard language,
779
+ // otherwise fall back to resolving alphanumeric characters via the keyCode.
780
+ if (event.key && event.key.length === 1) {
781
+ this._letterKeyStream.next(event.key.toLocaleUpperCase());
782
+ }
783
+ else if ((keyCode >= keycodes.A && keyCode <= keycodes.Z) || (keyCode >= keycodes.ZERO && keyCode <= keycodes.NINE)) {
784
+ this._letterKeyStream.next(String.fromCharCode(keyCode));
785
+ }
715
786
  }
716
787
  // Note that we return here, in order to avoid preventing
717
788
  // the default action of non-navigational keys.
@@ -806,8 +877,11 @@ ListKeyManager = /** @class */ (function () {
806
877
  var itemArray = this._getItemsArray();
807
878
  /** @type {?} */
808
879
  var index = typeof item === 'number' ? item : itemArray.indexOf(item);
880
+ /** @type {?} */
881
+ var activeItem = itemArray[index];
882
+ // Explicitly check for `null` and `undefined` because other falsy values are valid.
883
+ this._activeItem = activeItem == null ? null : activeItem;
809
884
  this._activeItemIndex = index;
810
- this._activeItem = itemArray[index];
811
885
  };
812
886
  /**
813
887
  * Allows setting of the activeItemIndex without any other effects.
@@ -836,6 +910,12 @@ ListKeyManager = /** @class */ (function () {
836
910
  * This method sets the active item, given a list of items and the delta between the
837
911
  * currently active item and the new active item. It will calculate differently
838
912
  * depending on whether wrap mode is turned on.
913
+ */
914
+ /**
915
+ * This method sets the active item, given a list of items and the delta between the
916
+ * currently active item and the new active item. It will calculate differently
917
+ * depending on whether wrap mode is turned on.
918
+ * @private
839
919
  * @param {?} delta
840
920
  * @return {?}
841
921
  */
@@ -843,6 +923,7 @@ ListKeyManager = /** @class */ (function () {
843
923
  * This method sets the active item, given a list of items and the delta between the
844
924
  * currently active item and the new active item. It will calculate differently
845
925
  * depending on whether wrap mode is turned on.
926
+ * @private
846
927
  * @param {?} delta
847
928
  * @return {?}
848
929
  */
@@ -853,6 +934,12 @@ ListKeyManager = /** @class */ (function () {
853
934
  * Sets the active item properly given "wrap" mode. In other words, it will continue to move
854
935
  * down the list until it finds an item that is not disabled, and it will wrap if it
855
936
  * encounters either end of the list.
937
+ */
938
+ /**
939
+ * Sets the active item properly given "wrap" mode. In other words, it will continue to move
940
+ * down the list until it finds an item that is not disabled, and it will wrap if it
941
+ * encounters either end of the list.
942
+ * @private
856
943
  * @param {?} delta
857
944
  * @return {?}
858
945
  */
@@ -860,6 +947,7 @@ ListKeyManager = /** @class */ (function () {
860
947
  * Sets the active item properly given "wrap" mode. In other words, it will continue to move
861
948
  * down the list until it finds an item that is not disabled, and it will wrap if it
862
949
  * encounters either end of the list.
950
+ * @private
863
951
  * @param {?} delta
864
952
  * @return {?}
865
953
  */
@@ -881,6 +969,12 @@ ListKeyManager = /** @class */ (function () {
881
969
  * Sets the active item properly given the default mode. In other words, it will
882
970
  * continue to move down the list until it finds an item that is not disabled. If
883
971
  * it encounters either end of the list, it will stop and not wrap.
972
+ */
973
+ /**
974
+ * Sets the active item properly given the default mode. In other words, it will
975
+ * continue to move down the list until it finds an item that is not disabled. If
976
+ * it encounters either end of the list, it will stop and not wrap.
977
+ * @private
884
978
  * @param {?} delta
885
979
  * @return {?}
886
980
  */
@@ -888,6 +982,7 @@ ListKeyManager = /** @class */ (function () {
888
982
  * Sets the active item properly given the default mode. In other words, it will
889
983
  * continue to move down the list until it finds an item that is not disabled. If
890
984
  * it encounters either end of the list, it will stop and not wrap.
985
+ * @private
891
986
  * @param {?} delta
892
987
  * @return {?}
893
988
  */
@@ -898,6 +993,12 @@ ListKeyManager = /** @class */ (function () {
898
993
  * Sets the active item to the first enabled item starting at the index specified. If the
899
994
  * item is disabled, it will move in the fallbackDelta direction until it either
900
995
  * finds an enabled item or encounters the end of the list.
996
+ */
997
+ /**
998
+ * Sets the active item to the first enabled item starting at the index specified. If the
999
+ * item is disabled, it will move in the fallbackDelta direction until it either
1000
+ * finds an enabled item or encounters the end of the list.
1001
+ * @private
901
1002
  * @param {?} index
902
1003
  * @param {?} fallbackDelta
903
1004
  * @return {?}
@@ -906,6 +1007,7 @@ ListKeyManager = /** @class */ (function () {
906
1007
  * Sets the active item to the first enabled item starting at the index specified. If the
907
1008
  * item is disabled, it will move in the fallbackDelta direction until it either
908
1009
  * finds an enabled item or encounters the end of the list.
1010
+ * @private
909
1011
  * @param {?} index
910
1012
  * @param {?} fallbackDelta
911
1013
  * @return {?}
@@ -924,12 +1026,15 @@ ListKeyManager = /** @class */ (function () {
924
1026
  }
925
1027
  this.setActiveItem(index);
926
1028
  };
1029
+ /** Returns the items as an array. */
927
1030
  /**
928
1031
  * Returns the items as an array.
1032
+ * @private
929
1033
  * @return {?}
930
1034
  */
931
1035
  ListKeyManager.prototype._getItemsArray = /**
932
1036
  * Returns the items as an array.
1037
+ * @private
933
1038
  * @return {?}
934
1039
  */
935
1040
  function () {
@@ -940,7 +1045,7 @@ ListKeyManager = /** @class */ (function () {
940
1045
 
941
1046
  /**
942
1047
  * @fileoverview added by tsickle
943
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
1048
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
944
1049
  */
945
1050
  /**
946
1051
  * @template T
@@ -975,7 +1080,7 @@ ActiveDescendantKeyManager = /** @class */ (function (_super) {
975
1080
 
976
1081
  /**
977
1082
  * @fileoverview added by tsickle
978
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
1083
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
979
1084
  */
980
1085
  /**
981
1086
  * @template T
@@ -996,17 +1101,21 @@ FocusKeyManager = /** @class */ (function (_super) {
996
1101
  */
997
1102
  /**
998
1103
  * Sets the focus origin that will be passed in to the items for any subsequent `focus` calls.
1104
+ * @template THIS
1105
+ * @this {THIS}
999
1106
  * @param {?} origin Focus origin to be used when focusing items.
1000
- * @return {?}
1107
+ * @return {THIS}
1001
1108
  */
1002
1109
  FocusKeyManager.prototype.setFocusOrigin = /**
1003
1110
  * Sets the focus origin that will be passed in to the items for any subsequent `focus` calls.
1111
+ * @template THIS
1112
+ * @this {THIS}
1004
1113
  * @param {?} origin Focus origin to be used when focusing items.
1005
- * @return {?}
1114
+ * @return {THIS}
1006
1115
  */
1007
1116
  function (origin) {
1008
- this._origin = origin;
1009
- return this;
1117
+ (/** @type {?} */ (this))._origin = origin;
1118
+ return (/** @type {?} */ (this));
1010
1119
  };
1011
1120
  /**
1012
1121
  * @param {?} item
@@ -1027,8 +1136,11 @@ FocusKeyManager = /** @class */ (function (_super) {
1027
1136
 
1028
1137
  /**
1029
1138
  * @fileoverview added by tsickle
1030
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
1139
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1031
1140
  */
1141
+ // The InteractivityChecker leans heavily on the ally.js accessibility utilities.
1142
+ // Methods like `isTabbable` are only covering specific edge-cases for the browsers which are
1143
+ // supported.
1032
1144
  /**
1033
1145
  * Utility for checking the interactivity of an element, such as whether is is focusable or
1034
1146
  * tabbable.
@@ -1111,7 +1223,7 @@ var InteractivityChecker = /** @class */ (function () {
1111
1223
  * @return {?} Whether the element is tabbable.
1112
1224
  */
1113
1225
  function (element) {
1114
- // Nothing is tabbable on the the server 😎
1226
+ // Nothing is tabbable on the server 😎
1115
1227
  if (!this._platform.isBrowser) {
1116
1228
  return false;
1117
1229
  }
@@ -1217,7 +1329,7 @@ var InteractivityChecker = /** @class */ (function () {
1217
1329
  */
1218
1330
  function getFrameElement(window) {
1219
1331
  try {
1220
- return /** @type {?} */ (window.frameElement);
1332
+ return (/** @type {?} */ (window.frameElement));
1221
1333
  }
1222
1334
  catch (_a) {
1223
1335
  return null;
@@ -1306,6 +1418,7 @@ function getTabIndexValue(element) {
1306
1418
  if (!hasValidTabIndex(element)) {
1307
1419
  return null;
1308
1420
  }
1421
+ // See browser issue in Gecko https://bugzilla.mozilla.org/show_bug.cgi?id=1128054
1309
1422
  /** @type {?} */
1310
1423
  var tabIndex = parseInt(element.getAttribute('tabindex') || '', 10);
1311
1424
  return isNaN(tabIndex) ? -1 : tabIndex;
@@ -1319,7 +1432,7 @@ function isPotentiallyTabbableIOS(element) {
1319
1432
  /** @type {?} */
1320
1433
  var nodeName = element.nodeName.toLowerCase();
1321
1434
  /** @type {?} */
1322
- var inputType = nodeName === 'input' && (/** @type {?} */ (element)).type;
1435
+ var inputType = nodeName === 'input' && ((/** @type {?} */ (element))).type;
1323
1436
  return inputType === 'text'
1324
1437
  || inputType === 'password'
1325
1438
  || nodeName === 'select'
@@ -1353,7 +1466,7 @@ function getWindow(node) {
1353
1466
 
1354
1467
  /**
1355
1468
  * @fileoverview added by tsickle
1356
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
1469
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1357
1470
  */
1358
1471
  /**
1359
1472
  * Class that allows for trapping focus within a DOM element.
@@ -1372,11 +1485,15 @@ var /**
1372
1485
  FocusTrap = /** @class */ (function () {
1373
1486
  function FocusTrap(_element, _checker, _ngZone, _document, deferAnchors) {
1374
1487
  if (deferAnchors === void 0) { deferAnchors = false; }
1488
+ var _this = this;
1375
1489
  this._element = _element;
1376
1490
  this._checker = _checker;
1377
1491
  this._ngZone = _ngZone;
1378
1492
  this._document = _document;
1379
1493
  this._hasAttached = false;
1494
+ // Event listeners for the anchors. Need to be regular functions so that we can unbind them later.
1495
+ this._startAnchorListener = function () { return _this.focusLastTabbableElement(); };
1496
+ this._endAnchorListener = function () { return _this.focusFirstTabbableElement(); };
1380
1497
  this._enabled = true;
1381
1498
  if (!deferAnchors) {
1382
1499
  this.attachAnchors();
@@ -1413,11 +1530,21 @@ FocusTrap = /** @class */ (function () {
1413
1530
  * @return {?}
1414
1531
  */
1415
1532
  function () {
1416
- if (this._startAnchor && this._startAnchor.parentNode) {
1417
- this._startAnchor.parentNode.removeChild(this._startAnchor);
1533
+ /** @type {?} */
1534
+ var startAnchor = this._startAnchor;
1535
+ /** @type {?} */
1536
+ var endAnchor = this._endAnchor;
1537
+ if (startAnchor) {
1538
+ startAnchor.removeEventListener('focus', this._startAnchorListener);
1539
+ if (startAnchor.parentNode) {
1540
+ startAnchor.parentNode.removeChild(startAnchor);
1541
+ }
1418
1542
  }
1419
- if (this._endAnchor && this._endAnchor.parentNode) {
1420
- this._endAnchor.parentNode.removeChild(this._endAnchor);
1543
+ if (endAnchor) {
1544
+ endAnchor.removeEventListener('focus', this._endAnchorListener);
1545
+ if (endAnchor.parentNode) {
1546
+ endAnchor.parentNode.removeChild(endAnchor);
1547
+ }
1421
1548
  }
1422
1549
  this._startAnchor = this._endAnchor = null;
1423
1550
  };
@@ -1447,17 +1574,17 @@ FocusTrap = /** @class */ (function () {
1447
1574
  }
1448
1575
  this._ngZone.runOutsideAngular(function () {
1449
1576
  if (!_this._startAnchor) {
1450
- _this._startAnchor = _this._createAnchor(); /** @type {?} */
1451
- ((_this._startAnchor)).addEventListener('focus', function () { return _this.focusLastTabbableElement(); });
1577
+ _this._startAnchor = _this._createAnchor();
1578
+ (/** @type {?} */ (_this._startAnchor)).addEventListener('focus', _this._startAnchorListener);
1452
1579
  }
1453
1580
  if (!_this._endAnchor) {
1454
- _this._endAnchor = _this._createAnchor(); /** @type {?} */
1455
- ((_this._endAnchor)).addEventListener('focus', function () { return _this.focusFirstTabbableElement(); });
1581
+ _this._endAnchor = _this._createAnchor();
1582
+ (/** @type {?} */ (_this._endAnchor)).addEventListener('focus', _this._endAnchorListener);
1456
1583
  }
1457
1584
  });
1458
1585
  if (this._element.parentNode) {
1459
- this._element.parentNode.insertBefore(/** @type {?} */ ((this._startAnchor)), this._element);
1460
- this._element.parentNode.insertBefore(/** @type {?} */ ((this._endAnchor)), this._element.nextSibling);
1586
+ this._element.parentNode.insertBefore((/** @type {?} */ (this._startAnchor)), this._element);
1587
+ this._element.parentNode.insertBefore((/** @type {?} */ (this._endAnchor)), this._element.nextSibling);
1461
1588
  this._hasAttached = true;
1462
1589
  }
1463
1590
  return this._hasAttached;
@@ -1536,19 +1663,27 @@ FocusTrap = /** @class */ (function () {
1536
1663
  };
1537
1664
  /**
1538
1665
  * Get the specified boundary element of the trapped region.
1666
+ * @param bound The boundary to get (start or end of trapped region).
1667
+ * @returns The boundary element.
1668
+ */
1669
+ /**
1670
+ * Get the specified boundary element of the trapped region.
1671
+ * @private
1539
1672
  * @param {?} bound The boundary to get (start or end of trapped region).
1540
1673
  * @return {?} The boundary element.
1541
1674
  */
1542
1675
  FocusTrap.prototype._getRegionBoundary = /**
1543
1676
  * Get the specified boundary element of the trapped region.
1677
+ * @private
1544
1678
  * @param {?} bound The boundary to get (start or end of trapped region).
1545
1679
  * @return {?} The boundary element.
1546
1680
  */
1547
1681
  function (bound) {
1682
+ // Contains the deprecated version of selector, for temporary backwards comparability.
1548
1683
  /** @type {?} */
1549
- var markers = /** @type {?} */ (this._element.querySelectorAll("[cdk-focus-region-" + bound + "], " +
1684
+ var markers = (/** @type {?} */ (this._element.querySelectorAll("[cdk-focus-region-" + bound + "], " +
1550
1685
  ("[cdkFocusRegion" + bound + "], ") +
1551
- ("[cdk-focus-" + bound + "]")));
1686
+ ("[cdk-focus-" + bound + "]"))));
1552
1687
  for (var i = 0; i < markers.length; i++) {
1553
1688
  // @breaking-change 8.0.0
1554
1689
  if (markers[i].hasAttribute("cdk-focus-" + bound)) {
@@ -1581,9 +1716,10 @@ FocusTrap = /** @class */ (function () {
1581
1716
  * @return {?} Whether focus was moved successfuly.
1582
1717
  */
1583
1718
  function () {
1719
+ // Contains the deprecated version of selector, for temporary backwards comparability.
1584
1720
  /** @type {?} */
1585
- var redirectToElement = /** @type {?} */ (this._element.querySelector("[cdk-focus-initial], " +
1586
- "[cdkFocusInitial]"));
1721
+ var redirectToElement = (/** @type {?} */ (this._element.querySelector("[cdk-focus-initial], " +
1722
+ "[cdkFocusInitial]")));
1587
1723
  if (redirectToElement) {
1588
1724
  // @breaking-change 8.0.0
1589
1725
  if (redirectToElement.hasAttribute("cdk-focus-initial")) {
@@ -1655,13 +1791,16 @@ FocusTrap = /** @class */ (function () {
1655
1791
  function () {
1656
1792
  return this._hasAttached;
1657
1793
  };
1794
+ /** Get the first tabbable element from a DOM subtree (inclusive). */
1658
1795
  /**
1659
1796
  * Get the first tabbable element from a DOM subtree (inclusive).
1797
+ * @private
1660
1798
  * @param {?} root
1661
1799
  * @return {?}
1662
1800
  */
1663
1801
  FocusTrap.prototype._getFirstTabbableElement = /**
1664
1802
  * Get the first tabbable element from a DOM subtree (inclusive).
1803
+ * @private
1665
1804
  * @param {?} root
1666
1805
  * @return {?}
1667
1806
  */
@@ -1669,12 +1808,14 @@ FocusTrap = /** @class */ (function () {
1669
1808
  if (this._checker.isFocusable(root) && this._checker.isTabbable(root)) {
1670
1809
  return root;
1671
1810
  }
1811
+ // Iterate in DOM order. Note that IE doesn't have `children` for SVG so we fall
1812
+ // back to `childNodes` which includes text nodes, comments etc.
1672
1813
  /** @type {?} */
1673
1814
  var children = root.children || root.childNodes;
1674
1815
  for (var i = 0; i < children.length; i++) {
1675
1816
  /** @type {?} */
1676
1817
  var tabbableChild = children[i].nodeType === this._document.ELEMENT_NODE ?
1677
- this._getFirstTabbableElement(/** @type {?} */ (children[i])) :
1818
+ this._getFirstTabbableElement((/** @type {?} */ (children[i]))) :
1678
1819
  null;
1679
1820
  if (tabbableChild) {
1680
1821
  return tabbableChild;
@@ -1682,13 +1823,16 @@ FocusTrap = /** @class */ (function () {
1682
1823
  }
1683
1824
  return null;
1684
1825
  };
1826
+ /** Get the last tabbable element from a DOM subtree (inclusive). */
1685
1827
  /**
1686
1828
  * Get the last tabbable element from a DOM subtree (inclusive).
1829
+ * @private
1687
1830
  * @param {?} root
1688
1831
  * @return {?}
1689
1832
  */
1690
1833
  FocusTrap.prototype._getLastTabbableElement = /**
1691
1834
  * Get the last tabbable element from a DOM subtree (inclusive).
1835
+ * @private
1692
1836
  * @param {?} root
1693
1837
  * @return {?}
1694
1838
  */
@@ -1696,12 +1840,13 @@ FocusTrap = /** @class */ (function () {
1696
1840
  if (this._checker.isFocusable(root) && this._checker.isTabbable(root)) {
1697
1841
  return root;
1698
1842
  }
1843
+ // Iterate in reverse DOM order.
1699
1844
  /** @type {?} */
1700
1845
  var children = root.children || root.childNodes;
1701
1846
  for (var i = children.length - 1; i >= 0; i--) {
1702
1847
  /** @type {?} */
1703
1848
  var tabbableChild = children[i].nodeType === this._document.ELEMENT_NODE ?
1704
- this._getLastTabbableElement(/** @type {?} */ (children[i])) :
1849
+ this._getLastTabbableElement((/** @type {?} */ (children[i]))) :
1705
1850
  null;
1706
1851
  if (tabbableChild) {
1707
1852
  return tabbableChild;
@@ -1709,12 +1854,15 @@ FocusTrap = /** @class */ (function () {
1709
1854
  }
1710
1855
  return null;
1711
1856
  };
1857
+ /** Creates an anchor element. */
1712
1858
  /**
1713
1859
  * Creates an anchor element.
1860
+ * @private
1714
1861
  * @return {?}
1715
1862
  */
1716
1863
  FocusTrap.prototype._createAnchor = /**
1717
1864
  * Creates an anchor element.
1865
+ * @private
1718
1866
  * @return {?}
1719
1867
  */
1720
1868
  function () {
@@ -1723,16 +1871,24 @@ FocusTrap = /** @class */ (function () {
1723
1871
  this._toggleAnchorTabIndex(this._enabled, anchor);
1724
1872
  anchor.classList.add('cdk-visually-hidden');
1725
1873
  anchor.classList.add('cdk-focus-trap-anchor');
1874
+ anchor.setAttribute('aria-hidden', 'true');
1726
1875
  return anchor;
1727
1876
  };
1728
1877
  /**
1729
1878
  * Toggles the `tabindex` of an anchor, based on the enabled state of the focus trap.
1879
+ * @param isEnabled Whether the focus trap is enabled.
1880
+ * @param anchor Anchor on which to toggle the tabindex.
1881
+ */
1882
+ /**
1883
+ * Toggles the `tabindex` of an anchor, based on the enabled state of the focus trap.
1884
+ * @private
1730
1885
  * @param {?} isEnabled Whether the focus trap is enabled.
1731
1886
  * @param {?} anchor Anchor on which to toggle the tabindex.
1732
1887
  * @return {?}
1733
1888
  */
1734
1889
  FocusTrap.prototype._toggleAnchorTabIndex = /**
1735
1890
  * Toggles the `tabindex` of an anchor, based on the enabled state of the focus trap.
1891
+ * @private
1736
1892
  * @param {?} isEnabled Whether the focus trap is enabled.
1737
1893
  * @param {?} anchor Anchor on which to toggle the tabindex.
1738
1894
  * @return {?}
@@ -1742,13 +1898,16 @@ FocusTrap = /** @class */ (function () {
1742
1898
  // element has a tabindex, the user might still hit it when navigating with the arrow keys.
1743
1899
  isEnabled ? anchor.setAttribute('tabindex', '0') : anchor.removeAttribute('tabindex');
1744
1900
  };
1901
+ /** Executes a function when the zone is stable. */
1745
1902
  /**
1746
1903
  * Executes a function when the zone is stable.
1904
+ * @private
1747
1905
  * @param {?} fn
1748
1906
  * @return {?}
1749
1907
  */
1750
1908
  FocusTrap.prototype._executeOnStable = /**
1751
1909
  * Executes a function when the zone is stable.
1910
+ * @private
1752
1911
  * @param {?} fn
1753
1912
  * @return {?}
1754
1913
  */
@@ -1880,7 +2039,7 @@ var CdkTrapFocus = /** @class */ (function () {
1880
2039
  function () {
1881
2040
  this.focusTrap.attachAnchors();
1882
2041
  if (this.autoCapture) {
1883
- this._previouslyFocusedElement = /** @type {?} */ (this._document.activeElement);
2042
+ this._previouslyFocusedElement = (/** @type {?} */ (this._document.activeElement));
1884
2043
  this.focusTrap.focusInitialElementWhenReady();
1885
2044
  }
1886
2045
  };
@@ -1916,8 +2075,10 @@ var CdkTrapFocus = /** @class */ (function () {
1916
2075
 
1917
2076
  /**
1918
2077
  * @fileoverview added by tsickle
1919
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
2078
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1920
2079
  */
2080
+ // The token for the live announcer element is defined in a separate file from LiveAnnouncer
2081
+ // as a workaround for https://github.com/angular/angular/issues/22559
1921
2082
  /** @type {?} */
1922
2083
  var LIVE_ANNOUNCER_ELEMENT_TOKEN = new core.InjectionToken('liveAnnouncerElement', {
1923
2084
  providedIn: 'root',
@@ -1933,7 +2094,7 @@ function LIVE_ANNOUNCER_ELEMENT_TOKEN_FACTORY() {
1933
2094
 
1934
2095
  /**
1935
2096
  * @fileoverview added by tsickle
1936
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
2097
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1937
2098
  */
1938
2099
  var LiveAnnouncer = /** @class */ (function () {
1939
2100
  function LiveAnnouncer(elementToken, _ngZone, _document) {
@@ -1973,7 +2134,7 @@ var LiveAnnouncer = /** @class */ (function () {
1973
2134
  this.clear();
1974
2135
  clearTimeout(this._previousTimeout);
1975
2136
  // TODO: ensure changing the politeness works on all environments we support.
1976
- this._liveElement.setAttribute('aria-live', /** @type {?} */ ((politeness)) || 'polite');
2137
+ this._liveElement.setAttribute('aria-live', (/** @type {?} */ (politeness)) || 'polite');
1977
2138
  // This 100ms timeout is necessary for some browser + screen-reader combinations:
1978
2139
  // - Both JAWS and NVDA over IE11 will not announce anything without a non-zero timeout.
1979
2140
  // - With Chrome and IE11 with NVDA or JAWS, a repeated (identical) message won't be read a
@@ -2024,13 +2185,15 @@ var LiveAnnouncer = /** @class */ (function () {
2024
2185
  clearTimeout(this._previousTimeout);
2025
2186
  if (this._liveElement && this._liveElement.parentNode) {
2026
2187
  this._liveElement.parentNode.removeChild(this._liveElement);
2027
- this._liveElement = /** @type {?} */ ((null));
2188
+ this._liveElement = (/** @type {?} */ (null));
2028
2189
  }
2029
2190
  };
2030
2191
  /**
2192
+ * @private
2031
2193
  * @return {?}
2032
2194
  */
2033
2195
  LiveAnnouncer.prototype._createLiveElement = /**
2196
+ * @private
2034
2197
  * @return {?}
2035
2198
  */
2036
2199
  function () {
@@ -2042,7 +2205,7 @@ var LiveAnnouncer = /** @class */ (function () {
2042
2205
  var liveEl = this._document.createElement('div');
2043
2206
  // Remove any old containers. This can happen when coming in from a server-side-rendered page.
2044
2207
  for (var i = 0; i < previousElements.length; i++) {
2045
- /** @type {?} */ ((previousElements[i].parentNode)).removeChild(previousElements[i]);
2208
+ (/** @type {?} */ (previousElements[i].parentNode)).removeChild(previousElements[i]);
2046
2209
  }
2047
2210
  liveEl.classList.add(elementClass);
2048
2211
  liveEl.classList.add('cdk-visually-hidden');
@@ -2100,6 +2263,7 @@ var CdkAriaLive = /** @class */ (function () {
2100
2263
  return _this._contentObserver
2101
2264
  .observe(_this._elementRef)
2102
2265
  .subscribe(function () {
2266
+ // Note that we use textContent here, rather than innerText, in order to avoid a reflow.
2103
2267
  /** @type {?} */
2104
2268
  var elementText = _this._elementRef.nativeElement.textContent;
2105
2269
  // The `MutationObserver` fires also for attribute
@@ -2155,9 +2319,10 @@ var CdkAriaLive = /** @class */ (function () {
2155
2319
  function LIVE_ANNOUNCER_PROVIDER_FACTORY(parentAnnouncer, liveElement, _document, ngZone) {
2156
2320
  return parentAnnouncer || new LiveAnnouncer(liveElement, ngZone, _document);
2157
2321
  }
2158
- /** *
2322
+ /**
2159
2323
  * \@docs-private \@deprecated \@breaking-change 8.0.0
2160
- @type {?} */
2324
+ * @type {?}
2325
+ */
2161
2326
  var LIVE_ANNOUNCER_PROVIDER = {
2162
2327
  // If there is already a LiveAnnouncer available, use that. Otherwise, provide a new one.
2163
2328
  provide: LiveAnnouncer,
@@ -2172,15 +2337,27 @@ var LIVE_ANNOUNCER_PROVIDER = {
2172
2337
 
2173
2338
  /**
2174
2339
  * @fileoverview added by tsickle
2175
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
2340
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2176
2341
  */
2342
+ // This is the value used by AngularJS Material. Through trial and error (on iPhone 6S) they found
2343
+ // that a value of around 650ms seems appropriate.
2177
2344
  /** @type {?} */
2178
2345
  var TOUCH_BUFFER_MS = 650;
2346
+ /**
2347
+ * Event listener options that enable capturing and also
2348
+ * mark the the listener as passive if the browser supports it.
2349
+ * @type {?}
2350
+ */
2351
+ var captureEventListenerOptions = platform.normalizePassiveListenerOptions({
2352
+ passive: true,
2353
+ capture: true
2354
+ });
2179
2355
  /**
2180
2356
  * Monitors mouse and keyboard events to determine the cause of focus events.
2181
2357
  */
2182
2358
  var FocusMonitor = /** @class */ (function () {
2183
2359
  function FocusMonitor(_ngZone, _platform) {
2360
+ var _this = this;
2184
2361
  this._ngZone = _ngZone;
2185
2362
  this._platform = _platform;
2186
2363
  /**
@@ -2195,14 +2372,54 @@ var FocusMonitor = /** @class */ (function () {
2195
2372
  * Map of elements being monitored to their info.
2196
2373
  */
2197
2374
  this._elementInfo = new Map();
2198
- /**
2199
- * A map of global objects to lists of current listeners.
2200
- */
2201
- this._unregisterGlobalListeners = function () { };
2202
2375
  /**
2203
2376
  * The number of elements currently being monitored.
2204
2377
  */
2205
2378
  this._monitoredElementCount = 0;
2379
+ /**
2380
+ * Event listener for `keydown` events on the document.
2381
+ * Needs to be an arrow function in order to preserve the context when it gets bound.
2382
+ */
2383
+ this._documentKeydownListener = function () {
2384
+ // On keydown record the origin and clear any touch event that may be in progress.
2385
+ _this._lastTouchTarget = null;
2386
+ _this._setOriginForCurrentEventQueue('keyboard');
2387
+ };
2388
+ /**
2389
+ * Event listener for `mousedown` events on the document.
2390
+ * Needs to be an arrow function in order to preserve the context when it gets bound.
2391
+ */
2392
+ this._documentMousedownListener = function () {
2393
+ // On mousedown record the origin only if there is not touch
2394
+ // target, since a mousedown can happen as a result of a touch event.
2395
+ if (!_this._lastTouchTarget) {
2396
+ _this._setOriginForCurrentEventQueue('mouse');
2397
+ }
2398
+ };
2399
+ /**
2400
+ * Event listener for `touchstart` events on the document.
2401
+ * Needs to be an arrow function in order to preserve the context when it gets bound.
2402
+ */
2403
+ this._documentTouchstartListener = function (event) {
2404
+ // When the touchstart event fires the focus event is not yet in the event queue. This means
2405
+ // we can't rely on the trick used above (setting timeout of 1ms). Instead we wait 650ms to
2406
+ // see if a focus happens.
2407
+ if (_this._touchTimeoutId != null) {
2408
+ clearTimeout(_this._touchTimeoutId);
2409
+ }
2410
+ _this._lastTouchTarget = event.target;
2411
+ _this._touchTimeoutId = setTimeout(function () { return _this._lastTouchTarget = null; }, TOUCH_BUFFER_MS);
2412
+ };
2413
+ /**
2414
+ * Event listener for `focus` events on the window.
2415
+ * Needs to be an arrow function in order to preserve the context when it gets bound.
2416
+ */
2417
+ this._windowFocusListener = function () {
2418
+ // Make a note of when the window regains focus, so we can
2419
+ // restore the origin info for the focused element.
2420
+ _this._windowFocused = true;
2421
+ _this._windowFocusTimeoutId = setTimeout(function () { return _this._windowFocused = false; });
2422
+ };
2206
2423
  }
2207
2424
  /**
2208
2425
  * @param {?} element
@@ -2222,14 +2439,15 @@ var FocusMonitor = /** @class */ (function () {
2222
2439
  return rxjs.of(null);
2223
2440
  }
2224
2441
  /** @type {?} */
2225
- var nativeElement = this._getNativeElement(element);
2442
+ var nativeElement = coercion.coerceElement(element);
2226
2443
  // Check if we're already monitoring this element.
2227
2444
  if (this._elementInfo.has(nativeElement)) {
2228
2445
  /** @type {?} */
2229
- var cachedInfo = this._elementInfo.get(nativeElement); /** @type {?} */
2230
- ((cachedInfo)).checkChildren = checkChildren;
2231
- return /** @type {?} */ ((cachedInfo)).subject.asObservable();
2446
+ var cachedInfo = this._elementInfo.get(nativeElement);
2447
+ (/** @type {?} */ (cachedInfo)).checkChildren = checkChildren;
2448
+ return (/** @type {?} */ (cachedInfo)).subject.asObservable();
2232
2449
  }
2450
+ // Create monitored element info.
2233
2451
  /** @type {?} */
2234
2452
  var info = {
2235
2453
  unlisten: function () { },
@@ -2238,6 +2456,7 @@ var FocusMonitor = /** @class */ (function () {
2238
2456
  };
2239
2457
  this._elementInfo.set(nativeElement, info);
2240
2458
  this._incrementMonitoredElementCount();
2459
+ // Start listening. We need to listen in capture phase since focus events don't bubble.
2241
2460
  /** @type {?} */
2242
2461
  var focusListener = function (event) { return _this._onFocus(event, nativeElement); };
2243
2462
  /** @type {?} */
@@ -2263,7 +2482,7 @@ var FocusMonitor = /** @class */ (function () {
2263
2482
  */
2264
2483
  function (element) {
2265
2484
  /** @type {?} */
2266
- var nativeElement = this._getNativeElement(element);
2485
+ var nativeElement = coercion.coerceElement(element);
2267
2486
  /** @type {?} */
2268
2487
  var elementInfo = this._elementInfo.get(nativeElement);
2269
2488
  if (elementInfo) {
@@ -2288,12 +2507,12 @@ var FocusMonitor = /** @class */ (function () {
2288
2507
  */
2289
2508
  function (element, origin, options) {
2290
2509
  /** @type {?} */
2291
- var nativeElement = this._getNativeElement(element);
2510
+ var nativeElement = coercion.coerceElement(element);
2292
2511
  this._setOriginForCurrentEventQueue(origin);
2293
2512
  // `focus` isn't available on the server
2294
2513
  if (typeof nativeElement.focus === 'function') {
2295
2514
  // Cast the element to `any`, because the TS typings don't have the `options` parameter yet.
2296
- (/** @type {?} */ (nativeElement)).focus(options);
2515
+ ((/** @type {?} */ (nativeElement))).focus(options);
2297
2516
  }
2298
2517
  };
2299
2518
  /**
@@ -2307,74 +2526,14 @@ var FocusMonitor = /** @class */ (function () {
2307
2526
  this._elementInfo.forEach(function (_info, element) { return _this.stopMonitoring(element); });
2308
2527
  };
2309
2528
  /**
2310
- * Register necessary event listeners on the document and window.
2311
- * @return {?}
2312
- */
2313
- FocusMonitor.prototype._registerGlobalListeners = /**
2314
- * Register necessary event listeners on the document and window.
2315
- * @return {?}
2316
- */
2317
- function () {
2318
- var _this = this;
2319
- // Do nothing if we're not on the browser platform.
2320
- if (!this._platform.isBrowser) {
2321
- return;
2322
- }
2323
- /** @type {?} */
2324
- var documentKeydownListener = function () {
2325
- _this._lastTouchTarget = null;
2326
- _this._setOriginForCurrentEventQueue('keyboard');
2327
- };
2328
- /** @type {?} */
2329
- var documentMousedownListener = function () {
2330
- if (!_this._lastTouchTarget) {
2331
- _this._setOriginForCurrentEventQueue('mouse');
2332
- }
2333
- };
2334
- /** @type {?} */
2335
- var documentTouchstartListener = function (event) {
2336
- if (_this._touchTimeoutId != null) {
2337
- clearTimeout(_this._touchTimeoutId);
2338
- }
2339
- _this._lastTouchTarget = event.target;
2340
- _this._touchTimeoutId = setTimeout(function () { return _this._lastTouchTarget = null; }, TOUCH_BUFFER_MS);
2341
- };
2342
- /** @type {?} */
2343
- var windowFocusListener = function () {
2344
- _this._windowFocused = true;
2345
- _this._windowFocusTimeoutId = setTimeout(function () { return _this._windowFocused = false; });
2346
- };
2347
- /** @type {?} */
2348
- var captureEventListenerOptions = platform.normalizePassiveListenerOptions({
2349
- passive: true,
2350
- capture: true
2351
- });
2352
- // Note: we listen to events in the capture phase so we can detect them even if the user stops
2353
- // propagation.
2354
- this._ngZone.runOutsideAngular(function () {
2355
- document.addEventListener('keydown', documentKeydownListener, captureEventListenerOptions);
2356
- document.addEventListener('mousedown', documentMousedownListener, captureEventListenerOptions);
2357
- document.addEventListener('touchstart', documentTouchstartListener, captureEventListenerOptions);
2358
- window.addEventListener('focus', windowFocusListener);
2359
- });
2360
- this._unregisterGlobalListeners = function () {
2361
- document.removeEventListener('keydown', documentKeydownListener, captureEventListenerOptions);
2362
- document.removeEventListener('mousedown', documentMousedownListener, captureEventListenerOptions);
2363
- document.removeEventListener('touchstart', documentTouchstartListener, captureEventListenerOptions);
2364
- window.removeEventListener('focus', windowFocusListener);
2365
- // Clear timeouts for all potentially pending timeouts to prevent the leaks.
2366
- clearTimeout(_this._windowFocusTimeoutId);
2367
- clearTimeout(_this._touchTimeoutId);
2368
- clearTimeout(_this._originTimeoutId);
2369
- };
2370
- };
2371
- /**
2529
+ * @private
2372
2530
  * @param {?} element
2373
2531
  * @param {?} className
2374
2532
  * @param {?} shouldSet
2375
2533
  * @return {?}
2376
2534
  */
2377
2535
  FocusMonitor.prototype._toggleClass = /**
2536
+ * @private
2378
2537
  * @param {?} element
2379
2538
  * @param {?} className
2380
2539
  * @param {?} shouldSet
@@ -2390,12 +2549,19 @@ var FocusMonitor = /** @class */ (function () {
2390
2549
  };
2391
2550
  /**
2392
2551
  * Sets the focus classes on the element based on the given focus origin.
2552
+ * @param element The element to update the classes on.
2553
+ * @param origin The focus origin.
2554
+ */
2555
+ /**
2556
+ * Sets the focus classes on the element based on the given focus origin.
2557
+ * @private
2393
2558
  * @param {?} element The element to update the classes on.
2394
2559
  * @param {?=} origin The focus origin.
2395
2560
  * @return {?}
2396
2561
  */
2397
2562
  FocusMonitor.prototype._setClasses = /**
2398
2563
  * Sets the focus classes on the element based on the given focus origin.
2564
+ * @private
2399
2565
  * @param {?} element The element to update the classes on.
2400
2566
  * @param {?=} origin The focus origin.
2401
2567
  * @return {?}
@@ -2413,11 +2579,17 @@ var FocusMonitor = /** @class */ (function () {
2413
2579
  };
2414
2580
  /**
2415
2581
  * Sets the origin and schedules an async function to clear it at the end of the event queue.
2582
+ * @param origin The origin to set.
2583
+ */
2584
+ /**
2585
+ * Sets the origin and schedules an async function to clear it at the end of the event queue.
2586
+ * @private
2416
2587
  * @param {?} origin The origin to set.
2417
2588
  * @return {?}
2418
2589
  */
2419
2590
  FocusMonitor.prototype._setOriginForCurrentEventQueue = /**
2420
2591
  * Sets the origin and schedules an async function to clear it at the end of the event queue.
2592
+ * @private
2421
2593
  * @param {?} origin The origin to set.
2422
2594
  * @return {?}
2423
2595
  */
@@ -2433,15 +2605,39 @@ var FocusMonitor = /** @class */ (function () {
2433
2605
  };
2434
2606
  /**
2435
2607
  * Checks whether the given focus event was caused by a touchstart event.
2608
+ * @param event The focus event to check.
2609
+ * @returns Whether the event was caused by a touch.
2610
+ */
2611
+ /**
2612
+ * Checks whether the given focus event was caused by a touchstart event.
2613
+ * @private
2436
2614
  * @param {?} event The focus event to check.
2437
2615
  * @return {?} Whether the event was caused by a touch.
2438
2616
  */
2439
2617
  FocusMonitor.prototype._wasCausedByTouch = /**
2440
2618
  * Checks whether the given focus event was caused by a touchstart event.
2619
+ * @private
2441
2620
  * @param {?} event The focus event to check.
2442
2621
  * @return {?} Whether the event was caused by a touch.
2443
2622
  */
2444
2623
  function (event) {
2624
+ // Note(mmalerba): This implementation is not quite perfect, there is a small edge case.
2625
+ // Consider the following dom structure:
2626
+ //
2627
+ // <div #parent tabindex="0" cdkFocusClasses>
2628
+ // <div #child (click)="#parent.focus()"></div>
2629
+ // </div>
2630
+ //
2631
+ // If the user touches the #child element and the #parent is programmatically focused as a
2632
+ // result, this code will still consider it to have been caused by the touch event and will
2633
+ // apply the cdk-touch-focused class rather than the cdk-program-focused class. This is a
2634
+ // relatively small edge-case that can be worked around by using
2635
+ // focusVia(parentEl, 'program') to focus the parent element.
2636
+ //
2637
+ // If we decide that we absolutely must handle this case correctly, we can do so by listening
2638
+ // for the first focus event after the touchstart, and then the first blur event after that
2639
+ // focus event. When that blur event fires we know that whatever follows is not a result of the
2640
+ // touchstart.
2445
2641
  /** @type {?} */
2446
2642
  var focusTarget = event.target;
2447
2643
  return this._lastTouchTarget instanceof Node && focusTarget instanceof Node &&
@@ -2449,22 +2645,45 @@ var FocusMonitor = /** @class */ (function () {
2449
2645
  };
2450
2646
  /**
2451
2647
  * Handles focus events on a registered element.
2648
+ * @param event The focus event.
2649
+ * @param element The monitored element.
2650
+ */
2651
+ /**
2652
+ * Handles focus events on a registered element.
2653
+ * @private
2452
2654
  * @param {?} event The focus event.
2453
2655
  * @param {?} element The monitored element.
2454
2656
  * @return {?}
2455
2657
  */
2456
2658
  FocusMonitor.prototype._onFocus = /**
2457
2659
  * Handles focus events on a registered element.
2660
+ * @private
2458
2661
  * @param {?} event The focus event.
2459
2662
  * @param {?} element The monitored element.
2460
2663
  * @return {?}
2461
2664
  */
2462
2665
  function (event, element) {
2666
+ // NOTE(mmalerba): We currently set the classes based on the focus origin of the most recent
2667
+ // focus event affecting the monitored element. If we want to use the origin of the first event
2668
+ // instead we should check for the cdk-focused class here and return if the element already has
2669
+ // it. (This only matters for elements that have includesChildren = true).
2670
+ // NOTE(mmalerba): We currently set the classes based on the focus origin of the most recent
2671
+ // focus event affecting the monitored element. If we want to use the origin of the first event
2672
+ // instead we should check for the cdk-focused class here and return if the element already has
2673
+ // it. (This only matters for elements that have includesChildren = true).
2674
+ // If we are not counting child-element-focus as focused, make sure that the event target is the
2675
+ // monitored element itself.
2463
2676
  /** @type {?} */
2464
2677
  var elementInfo = this._elementInfo.get(element);
2465
2678
  if (!elementInfo || (!elementInfo.checkChildren && element !== event.target)) {
2466
2679
  return;
2467
2680
  }
2681
+ // If we couldn't detect a cause for the focus event, it's due to one of three reasons:
2682
+ // 1) The window has just regained focus, in which case we want to restore the focused state of
2683
+ // the element from before the window blurred.
2684
+ // 2) It was caused by a touch event, in which case we mark the origin as 'touch'.
2685
+ // 3) The element was programmatically focused, in which case we should mark the origin as
2686
+ // 'program'.
2468
2687
  /** @type {?} */
2469
2688
  var origin = this._origin;
2470
2689
  if (!origin) {
@@ -2500,6 +2719,8 @@ var FocusMonitor = /** @class */ (function () {
2500
2719
  * @return {?}
2501
2720
  */
2502
2721
  function (event, element) {
2722
+ // If we are counting child-element-focus as focused, make sure that we aren't just blurring in
2723
+ // order to focus another child of the monitored element.
2503
2724
  /** @type {?} */
2504
2725
  var elementInfo = this._elementInfo.get(element);
2505
2726
  if (!elementInfo || (elementInfo.checkChildren && event.relatedTarget instanceof Node &&
@@ -2510,11 +2731,13 @@ var FocusMonitor = /** @class */ (function () {
2510
2731
  this._emitOrigin(elementInfo.subject, null);
2511
2732
  };
2512
2733
  /**
2734
+ * @private
2513
2735
  * @param {?} subject
2514
2736
  * @param {?} origin
2515
2737
  * @return {?}
2516
2738
  */
2517
2739
  FocusMonitor.prototype._emitOrigin = /**
2740
+ * @private
2518
2741
  * @param {?} subject
2519
2742
  * @param {?} origin
2520
2743
  * @return {?}
@@ -2523,41 +2746,48 @@ var FocusMonitor = /** @class */ (function () {
2523
2746
  this._ngZone.run(function () { return subject.next(origin); });
2524
2747
  };
2525
2748
  /**
2749
+ * @private
2526
2750
  * @return {?}
2527
2751
  */
2528
2752
  FocusMonitor.prototype._incrementMonitoredElementCount = /**
2753
+ * @private
2529
2754
  * @return {?}
2530
2755
  */
2531
2756
  function () {
2757
+ var _this = this;
2532
2758
  // Register global listeners when first element is monitored.
2533
- if (++this._monitoredElementCount == 1) {
2534
- this._registerGlobalListeners();
2759
+ if (++this._monitoredElementCount == 1 && this._platform.isBrowser) {
2760
+ // Note: we listen to events in the capture phase so we
2761
+ // can detect them even if the user stops propagation.
2762
+ this._ngZone.runOutsideAngular(function () {
2763
+ document.addEventListener('keydown', _this._documentKeydownListener, captureEventListenerOptions);
2764
+ document.addEventListener('mousedown', _this._documentMousedownListener, captureEventListenerOptions);
2765
+ document.addEventListener('touchstart', _this._documentTouchstartListener, captureEventListenerOptions);
2766
+ window.addEventListener('focus', _this._windowFocusListener);
2767
+ });
2535
2768
  }
2536
2769
  };
2537
2770
  /**
2771
+ * @private
2538
2772
  * @return {?}
2539
2773
  */
2540
2774
  FocusMonitor.prototype._decrementMonitoredElementCount = /**
2775
+ * @private
2541
2776
  * @return {?}
2542
2777
  */
2543
2778
  function () {
2544
2779
  // Unregister global listeners when last element is unmonitored.
2545
2780
  if (!--this._monitoredElementCount) {
2546
- this._unregisterGlobalListeners();
2547
- this._unregisterGlobalListeners = function () { };
2781
+ document.removeEventListener('keydown', this._documentKeydownListener, captureEventListenerOptions);
2782
+ document.removeEventListener('mousedown', this._documentMousedownListener, captureEventListenerOptions);
2783
+ document.removeEventListener('touchstart', this._documentTouchstartListener, captureEventListenerOptions);
2784
+ window.removeEventListener('focus', this._windowFocusListener);
2785
+ // Clear timeouts for all potentially pending timeouts to prevent the leaks.
2786
+ clearTimeout(this._windowFocusTimeoutId);
2787
+ clearTimeout(this._touchTimeoutId);
2788
+ clearTimeout(this._originTimeoutId);
2548
2789
  }
2549
2790
  };
2550
- /**
2551
- * @param {?} element
2552
- * @return {?}
2553
- */
2554
- FocusMonitor.prototype._getNativeElement = /**
2555
- * @param {?} element
2556
- * @return {?}
2557
- */
2558
- function (element) {
2559
- return element instanceof core.ElementRef ? element.nativeElement : element;
2560
- };
2561
2791
  FocusMonitor.decorators = [
2562
2792
  { type: core.Injectable, args: [{ providedIn: 'root' },] },
2563
2793
  ];
@@ -2622,9 +2852,10 @@ var CdkMonitorFocus = /** @class */ (function () {
2622
2852
  function FOCUS_MONITOR_PROVIDER_FACTORY(parentDispatcher, ngZone, platform$$1) {
2623
2853
  return parentDispatcher || new FocusMonitor(ngZone, platform$$1);
2624
2854
  }
2625
- /** *
2855
+ /**
2626
2856
  * \@docs-private \@deprecated \@breaking-change 8.0.0
2627
- @type {?} */
2857
+ * @type {?}
2858
+ */
2628
2859
  var FOCUS_MONITOR_PROVIDER = {
2629
2860
  // If there is already a FocusMonitor available, use that. Otherwise, provide a new one.
2630
2861
  provide: FocusMonitor,
@@ -2634,7 +2865,7 @@ var FOCUS_MONITOR_PROVIDER = {
2634
2865
 
2635
2866
  /**
2636
2867
  * @fileoverview added by tsickle
2637
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
2868
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2638
2869
  */
2639
2870
 
2640
2871
  /**
@@ -2652,7 +2883,7 @@ function isFakeMousedownFromScreenReader(event) {
2652
2883
 
2653
2884
  /**
2654
2885
  * @fileoverview added by tsickle
2655
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
2886
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2656
2887
  */
2657
2888
  var A11yModule = /** @class */ (function () {
2658
2889
  function A11yModule() {