@angular/material 14.0.0-rc.0 → 14.0.0

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 (310) hide show
  1. package/bottom-sheet/index.d.ts +15 -82
  2. package/checkbox/index.d.ts +62 -31
  3. package/esm2020/autocomplete/autocomplete-module.mjs +5 -5
  4. package/esm2020/autocomplete/autocomplete-origin.mjs +7 -7
  5. package/esm2020/autocomplete/autocomplete-trigger.mjs +7 -7
  6. package/esm2020/autocomplete/autocomplete.mjs +7 -7
  7. package/esm2020/badge/badge-module.mjs +5 -5
  8. package/esm2020/badge/badge.mjs +4 -4
  9. package/esm2020/bottom-sheet/bottom-sheet-container.mjs +23 -175
  10. package/esm2020/bottom-sheet/bottom-sheet-module.mjs +7 -7
  11. package/esm2020/bottom-sheet/bottom-sheet-ref.mjs +34 -34
  12. package/esm2020/bottom-sheet/bottom-sheet.mjs +30 -89
  13. package/esm2020/button/button-module.mjs +5 -5
  14. package/esm2020/button/button.mjs +7 -7
  15. package/esm2020/button-toggle/button-toggle-module.mjs +5 -5
  16. package/esm2020/button-toggle/button-toggle.mjs +7 -7
  17. package/esm2020/card/card-module.mjs +5 -5
  18. package/esm2020/card/card.mjs +43 -43
  19. package/esm2020/checkbox/checkbox-module.mjs +9 -9
  20. package/esm2020/checkbox/checkbox-required-validator.mjs +4 -4
  21. package/esm2020/checkbox/checkbox.mjs +138 -121
  22. package/esm2020/chips/chip-input.mjs +4 -4
  23. package/esm2020/chips/chip-list.mjs +4 -4
  24. package/esm2020/chips/chip.mjs +13 -13
  25. package/esm2020/chips/chips-module.mjs +5 -5
  26. package/esm2020/core/common-behaviors/common-module.mjs +5 -5
  27. package/esm2020/core/datetime/index.mjs +9 -9
  28. package/esm2020/core/datetime/native-date-adapter.mjs +4 -4
  29. package/esm2020/core/error/error-options.mjs +7 -7
  30. package/esm2020/core/line/line.mjs +8 -8
  31. package/esm2020/core/option/index.mjs +5 -5
  32. package/esm2020/core/option/optgroup.mjs +7 -7
  33. package/esm2020/core/option/option.mjs +7 -7
  34. package/esm2020/core/ripple/index.mjs +5 -5
  35. package/esm2020/core/ripple/ripple.mjs +4 -4
  36. package/esm2020/core/selection/pseudo-checkbox/pseudo-checkbox-module.mjs +5 -5
  37. package/esm2020/core/selection/pseudo-checkbox/pseudo-checkbox.mjs +4 -4
  38. package/esm2020/core/version.mjs +1 -1
  39. package/esm2020/datepicker/calendar-body.mjs +4 -4
  40. package/esm2020/datepicker/calendar.mjs +7 -7
  41. package/esm2020/datepicker/date-range-input-parts.mjs +10 -10
  42. package/esm2020/datepicker/date-range-input.mjs +4 -4
  43. package/esm2020/datepicker/date-range-picker.mjs +4 -4
  44. package/esm2020/datepicker/date-range-selection-strategy.mjs +4 -4
  45. package/esm2020/datepicker/date-selection-model.mjs +10 -10
  46. package/esm2020/datepicker/datepicker-actions.mjs +10 -10
  47. package/esm2020/datepicker/datepicker-base.mjs +23 -8
  48. package/esm2020/datepicker/datepicker-input-base.mjs +4 -4
  49. package/esm2020/datepicker/datepicker-input.mjs +4 -4
  50. package/esm2020/datepicker/datepicker-intl.mjs +4 -4
  51. package/esm2020/datepicker/datepicker-module.mjs +5 -5
  52. package/esm2020/datepicker/datepicker-toggle.mjs +7 -7
  53. package/esm2020/datepicker/datepicker.mjs +4 -4
  54. package/esm2020/datepicker/month-view.mjs +4 -4
  55. package/esm2020/datepicker/multi-year-view.mjs +4 -4
  56. package/esm2020/datepicker/year-view.mjs +4 -4
  57. package/esm2020/dialog/dialog-container.mjs +7 -7
  58. package/esm2020/dialog/dialog-content-directives.mjs +13 -13
  59. package/esm2020/dialog/dialog-module.mjs +5 -5
  60. package/esm2020/dialog/dialog.mjs +7 -7
  61. package/esm2020/divider/divider-module.mjs +5 -5
  62. package/esm2020/divider/divider.mjs +4 -4
  63. package/esm2020/expansion/accordion.mjs +4 -4
  64. package/esm2020/expansion/expansion-module.mjs +5 -5
  65. package/esm2020/expansion/expansion-panel-content.mjs +4 -4
  66. package/esm2020/expansion/expansion-panel-header.mjs +10 -10
  67. package/esm2020/expansion/expansion-panel.mjs +7 -7
  68. package/esm2020/form-field/error.mjs +4 -4
  69. package/esm2020/form-field/form-field-control.mjs +4 -4
  70. package/esm2020/form-field/form-field-module.mjs +5 -5
  71. package/esm2020/form-field/form-field.mjs +4 -4
  72. package/esm2020/form-field/hint.mjs +4 -4
  73. package/esm2020/form-field/label.mjs +4 -4
  74. package/esm2020/form-field/placeholder.mjs +4 -4
  75. package/esm2020/form-field/prefix.mjs +4 -4
  76. package/esm2020/form-field/suffix.mjs +4 -4
  77. package/esm2020/grid-list/grid-list-module.mjs +5 -5
  78. package/esm2020/grid-list/grid-list.mjs +4 -4
  79. package/esm2020/grid-list/grid-tile.mjs +16 -16
  80. package/esm2020/icon/icon-module.mjs +5 -5
  81. package/esm2020/icon/icon-registry.mjs +4 -4
  82. package/esm2020/icon/icon.mjs +4 -4
  83. package/esm2020/icon/testing/fake-icon-registry.mjs +8 -8
  84. package/esm2020/input/input-module.mjs +5 -5
  85. package/esm2020/input/input.mjs +4 -4
  86. package/esm2020/list/list-module.mjs +5 -5
  87. package/esm2020/list/list.mjs +19 -19
  88. package/esm2020/list/selection-list.mjs +7 -7
  89. package/esm2020/menu/menu-content.mjs +7 -7
  90. package/esm2020/menu/menu-item.mjs +4 -4
  91. package/esm2020/menu/menu-module.mjs +5 -5
  92. package/esm2020/menu/menu-trigger.mjs +7 -7
  93. package/esm2020/menu/menu.mjs +7 -7
  94. package/esm2020/paginator/paginator-intl.mjs +4 -4
  95. package/esm2020/paginator/paginator-module.mjs +5 -5
  96. package/esm2020/paginator/paginator.mjs +7 -7
  97. package/esm2020/progress-bar/progress-bar-module.mjs +5 -5
  98. package/esm2020/progress-bar/progress-bar.mjs +4 -4
  99. package/esm2020/progress-spinner/progress-spinner-module.mjs +5 -5
  100. package/esm2020/progress-spinner/progress-spinner.mjs +4 -4
  101. package/esm2020/radio/radio-module.mjs +5 -5
  102. package/esm2020/radio/radio.mjs +13 -13
  103. package/esm2020/select/select-module.mjs +5 -5
  104. package/esm2020/select/select.mjs +10 -10
  105. package/esm2020/sidenav/drawer.mjs +10 -10
  106. package/esm2020/sidenav/sidenav-module.mjs +5 -5
  107. package/esm2020/sidenav/sidenav.mjs +10 -10
  108. package/esm2020/slide-toggle/slide-toggle-module.mjs +9 -9
  109. package/esm2020/slide-toggle/slide-toggle-required-validator.mjs +4 -4
  110. package/esm2020/slide-toggle/slide-toggle.mjs +89 -77
  111. package/esm2020/slider/slider-module.mjs +5 -5
  112. package/esm2020/slider/slider.mjs +4 -4
  113. package/esm2020/snack-bar/simple-snack-bar.mjs +4 -4
  114. package/esm2020/snack-bar/snack-bar-container.mjs +4 -4
  115. package/esm2020/snack-bar/snack-bar-module.mjs +5 -5
  116. package/esm2020/snack-bar/snack-bar.mjs +7 -7
  117. package/esm2020/sort/sort-header-intl.mjs +4 -4
  118. package/esm2020/sort/sort-header.mjs +4 -4
  119. package/esm2020/sort/sort-module.mjs +5 -5
  120. package/esm2020/sort/sort.mjs +4 -4
  121. package/esm2020/stepper/step-content.mjs +4 -4
  122. package/esm2020/stepper/step-header.mjs +4 -4
  123. package/esm2020/stepper/step-label.mjs +4 -4
  124. package/esm2020/stepper/stepper-button.mjs +7 -7
  125. package/esm2020/stepper/stepper-icon.mjs +4 -4
  126. package/esm2020/stepper/stepper-intl.mjs +4 -4
  127. package/esm2020/stepper/stepper-module.mjs +5 -5
  128. package/esm2020/stepper/stepper.mjs +7 -7
  129. package/esm2020/table/cell.mjs +22 -22
  130. package/esm2020/table/row.mjs +22 -22
  131. package/esm2020/table/table-module.mjs +5 -5
  132. package/esm2020/table/table.mjs +7 -7
  133. package/esm2020/table/text-column.mjs +4 -4
  134. package/esm2020/tabs/ink-bar.mjs +4 -4
  135. package/esm2020/tabs/paginated-tab-header.mjs +27 -7
  136. package/esm2020/tabs/tab-body.mjs +10 -10
  137. package/esm2020/tabs/tab-content.mjs +4 -4
  138. package/esm2020/tabs/tab-group.mjs +7 -7
  139. package/esm2020/tabs/tab-header.mjs +7 -7
  140. package/esm2020/tabs/tab-label-wrapper.mjs +4 -4
  141. package/esm2020/tabs/tab-label.mjs +4 -4
  142. package/esm2020/tabs/tab-nav-bar/tab-nav-bar.mjs +16 -16
  143. package/esm2020/tabs/tab.mjs +4 -4
  144. package/esm2020/tabs/tabs-module.mjs +5 -5
  145. package/esm2020/toolbar/toolbar-module.mjs +5 -5
  146. package/esm2020/toolbar/toolbar.mjs +7 -7
  147. package/esm2020/tooltip/tooltip-module.mjs +5 -5
  148. package/esm2020/tooltip/tooltip.mjs +13 -13
  149. package/esm2020/tree/node.mjs +10 -10
  150. package/esm2020/tree/outlet.mjs +4 -4
  151. package/esm2020/tree/padding.mjs +4 -4
  152. package/esm2020/tree/toggle.mjs +4 -4
  153. package/esm2020/tree/tree-module.mjs +5 -5
  154. package/esm2020/tree/tree.mjs +4 -4
  155. package/fesm2015/autocomplete.mjs +22 -22
  156. package/fesm2015/autocomplete.mjs.map +1 -1
  157. package/fesm2015/badge.mjs +7 -7
  158. package/fesm2015/badge.mjs.map +1 -1
  159. package/fesm2015/bottom-sheet.mjs +125 -343
  160. package/fesm2015/bottom-sheet.mjs.map +1 -1
  161. package/fesm2015/button-toggle.mjs +10 -10
  162. package/fesm2015/button-toggle.mjs.map +1 -1
  163. package/fesm2015/button.mjs +10 -10
  164. package/fesm2015/button.mjs.map +1 -1
  165. package/fesm2015/card.mjs +46 -46
  166. package/fesm2015/card.mjs.map +1 -1
  167. package/fesm2015/checkbox.mjs +151 -134
  168. package/fesm2015/checkbox.mjs.map +1 -1
  169. package/fesm2015/chips.mjs +22 -22
  170. package/fesm2015/chips.mjs.map +1 -1
  171. package/fesm2015/core.mjs +59 -59
  172. package/fesm2015/core.mjs.map +1 -1
  173. package/fesm2015/datepicker.mjs +97 -82
  174. package/fesm2015/datepicker.mjs.map +1 -1
  175. package/fesm2015/dialog.mjs +28 -28
  176. package/fesm2015/dialog.mjs.map +1 -1
  177. package/fesm2015/divider.mjs +7 -7
  178. package/fesm2015/divider.mjs.map +1 -1
  179. package/fesm2015/expansion.mjs +25 -25
  180. package/fesm2015/expansion.mjs.map +1 -1
  181. package/fesm2015/form-field.mjs +28 -28
  182. package/fesm2015/form-field.mjs.map +1 -1
  183. package/fesm2015/grid-list.mjs +22 -22
  184. package/fesm2015/grid-list.mjs.map +1 -1
  185. package/fesm2015/icon/testing.mjs +7 -7
  186. package/fesm2015/icon/testing.mjs.map +1 -1
  187. package/fesm2015/icon.mjs +10 -10
  188. package/fesm2015/icon.mjs.map +1 -1
  189. package/fesm2015/input.mjs +7 -7
  190. package/fesm2015/input.mjs.map +1 -1
  191. package/fesm2015/list.mjs +28 -28
  192. package/fesm2015/list.mjs.map +1 -1
  193. package/fesm2015/menu.mjs +25 -25
  194. package/fesm2015/menu.mjs.map +1 -1
  195. package/fesm2015/paginator.mjs +13 -13
  196. package/fesm2015/paginator.mjs.map +1 -1
  197. package/fesm2015/progress-bar.mjs +7 -7
  198. package/fesm2015/progress-bar.mjs.map +1 -1
  199. package/fesm2015/progress-spinner.mjs +7 -7
  200. package/fesm2015/progress-spinner.mjs.map +1 -1
  201. package/fesm2015/radio.mjs +16 -16
  202. package/fesm2015/radio.mjs.map +1 -1
  203. package/fesm2015/select.mjs +13 -13
  204. package/fesm2015/select.mjs.map +1 -1
  205. package/fesm2015/sidenav.mjs +22 -22
  206. package/fesm2015/sidenav.mjs.map +1 -1
  207. package/fesm2015/slide-toggle.mjs +100 -88
  208. package/fesm2015/slide-toggle.mjs.map +1 -1
  209. package/fesm2015/slider.mjs +7 -7
  210. package/fesm2015/slider.mjs.map +1 -1
  211. package/fesm2015/snack-bar.mjs +16 -16
  212. package/fesm2015/snack-bar.mjs.map +1 -1
  213. package/fesm2015/sort.mjs +13 -13
  214. package/fesm2015/sort.mjs.map +1 -1
  215. package/fesm2015/stepper.mjs +31 -31
  216. package/fesm2015/stepper.mjs.map +1 -1
  217. package/fesm2015/table.mjs +55 -55
  218. package/fesm2015/table.mjs.map +1 -1
  219. package/fesm2015/tabs.mjs +81 -61
  220. package/fesm2015/tabs.mjs.map +1 -1
  221. package/fesm2015/toolbar.mjs +10 -10
  222. package/fesm2015/toolbar.mjs.map +1 -1
  223. package/fesm2015/tooltip.mjs +16 -16
  224. package/fesm2015/tooltip.mjs.map +1 -1
  225. package/fesm2015/tree.mjs +25 -25
  226. package/fesm2015/tree.mjs.map +1 -1
  227. package/fesm2020/autocomplete.mjs +22 -22
  228. package/fesm2020/autocomplete.mjs.map +1 -1
  229. package/fesm2020/badge.mjs +7 -7
  230. package/fesm2020/badge.mjs.map +1 -1
  231. package/fesm2020/bottom-sheet.mjs +132 -342
  232. package/fesm2020/bottom-sheet.mjs.map +1 -1
  233. package/fesm2020/button-toggle.mjs +10 -10
  234. package/fesm2020/button-toggle.mjs.map +1 -1
  235. package/fesm2020/button.mjs +10 -10
  236. package/fesm2020/button.mjs.map +1 -1
  237. package/fesm2020/card.mjs +46 -46
  238. package/fesm2020/card.mjs.map +1 -1
  239. package/fesm2020/checkbox.mjs +149 -132
  240. package/fesm2020/checkbox.mjs.map +1 -1
  241. package/fesm2020/chips.mjs +22 -22
  242. package/fesm2020/chips.mjs.map +1 -1
  243. package/fesm2020/core.mjs +59 -59
  244. package/fesm2020/core.mjs.map +1 -1
  245. package/fesm2020/datepicker.mjs +97 -82
  246. package/fesm2020/datepicker.mjs.map +1 -1
  247. package/fesm2020/dialog.mjs +28 -28
  248. package/fesm2020/dialog.mjs.map +1 -1
  249. package/fesm2020/divider.mjs +7 -7
  250. package/fesm2020/divider.mjs.map +1 -1
  251. package/fesm2020/expansion.mjs +25 -25
  252. package/fesm2020/expansion.mjs.map +1 -1
  253. package/fesm2020/form-field.mjs +28 -28
  254. package/fesm2020/form-field.mjs.map +1 -1
  255. package/fesm2020/grid-list.mjs +22 -22
  256. package/fesm2020/grid-list.mjs.map +1 -1
  257. package/fesm2020/icon/testing.mjs +7 -7
  258. package/fesm2020/icon/testing.mjs.map +1 -1
  259. package/fesm2020/icon.mjs +10 -10
  260. package/fesm2020/icon.mjs.map +1 -1
  261. package/fesm2020/input.mjs +7 -7
  262. package/fesm2020/input.mjs.map +1 -1
  263. package/fesm2020/list.mjs +28 -28
  264. package/fesm2020/list.mjs.map +1 -1
  265. package/fesm2020/menu.mjs +25 -25
  266. package/fesm2020/menu.mjs.map +1 -1
  267. package/fesm2020/paginator.mjs +13 -13
  268. package/fesm2020/paginator.mjs.map +1 -1
  269. package/fesm2020/progress-bar.mjs +7 -7
  270. package/fesm2020/progress-bar.mjs.map +1 -1
  271. package/fesm2020/progress-spinner.mjs +7 -7
  272. package/fesm2020/progress-spinner.mjs.map +1 -1
  273. package/fesm2020/radio.mjs +16 -16
  274. package/fesm2020/radio.mjs.map +1 -1
  275. package/fesm2020/select.mjs +13 -13
  276. package/fesm2020/select.mjs.map +1 -1
  277. package/fesm2020/sidenav.mjs +22 -22
  278. package/fesm2020/sidenav.mjs.map +1 -1
  279. package/fesm2020/slide-toggle.mjs +100 -88
  280. package/fesm2020/slide-toggle.mjs.map +1 -1
  281. package/fesm2020/slider.mjs +7 -7
  282. package/fesm2020/slider.mjs.map +1 -1
  283. package/fesm2020/snack-bar.mjs +16 -16
  284. package/fesm2020/snack-bar.mjs.map +1 -1
  285. package/fesm2020/sort.mjs +13 -13
  286. package/fesm2020/sort.mjs.map +1 -1
  287. package/fesm2020/stepper.mjs +31 -31
  288. package/fesm2020/stepper.mjs.map +1 -1
  289. package/fesm2020/table.mjs +55 -55
  290. package/fesm2020/table.mjs.map +1 -1
  291. package/fesm2020/tabs.mjs +81 -61
  292. package/fesm2020/tabs.mjs.map +1 -1
  293. package/fesm2020/toolbar.mjs +10 -10
  294. package/fesm2020/toolbar.mjs.map +1 -1
  295. package/fesm2020/tooltip.mjs +16 -16
  296. package/fesm2020/tooltip.mjs.map +1 -1
  297. package/fesm2020/tree.mjs +25 -25
  298. package/fesm2020/tree.mjs.map +1 -1
  299. package/package.json +7 -7
  300. package/schematics/ng-add/index.js +2 -2
  301. package/schematics/ng-add/index.mjs +2 -2
  302. package/schematics/ng-add/setup-project.js +59 -18
  303. package/schematics/ng-add/setup-project.mjs +59 -18
  304. package/schematics/ng-generate/address-form/schema.json +3 -0
  305. package/schematics/ng-generate/dashboard/schema.json +3 -0
  306. package/schematics/ng-generate/navigation/schema.json +3 -0
  307. package/schematics/ng-generate/table/schema.json +3 -0
  308. package/schematics/ng-generate/tree/schema.json +3 -0
  309. package/slide-toggle/index.d.ts +45 -32
  310. package/tabs/index.d.ts +2 -0
@@ -1,20 +1,18 @@
1
- import * as i1$1 from '@angular/cdk/overlay';
2
- import { OverlayModule, OverlayConfig } from '@angular/cdk/overlay';
3
- import * as i4 from '@angular/cdk/portal';
4
- import { BasePortalOutlet, CdkPortalOutlet, PortalModule, TemplatePortal, ComponentPortal } from '@angular/cdk/portal';
1
+ import * as i2 from '@angular/cdk/dialog';
2
+ import { CdkDialogContainer, DialogModule, Dialog } from '@angular/cdk/dialog';
3
+ import * as i5 from '@angular/cdk/portal';
4
+ import { PortalModule } from '@angular/cdk/portal';
5
5
  import * as i0 from '@angular/core';
6
- import { InjectionToken, EventEmitter, Component, ChangeDetectionStrategy, ViewEncapsulation, Optional, Inject, ViewChild, NgModule, TemplateRef, Injector, InjectFlags, Injectable, SkipSelf } from '@angular/core';
6
+ import { EventEmitter, Component, ChangeDetectionStrategy, ViewEncapsulation, Optional, Inject, NgModule, InjectionToken, Injectable, SkipSelf } from '@angular/core';
7
7
  import { AnimationDurations, AnimationCurves, MatCommonModule } from '@angular/material/core';
8
- import { coerceArray } from '@angular/cdk/coercion';
9
- import * as i2 from '@angular/cdk/layout';
8
+ import * as i4 from '@angular/cdk/layout';
10
9
  import { Breakpoints } from '@angular/cdk/layout';
11
- import { _getFocusedElementPierceShadowDom } from '@angular/cdk/platform';
12
10
  import { DOCUMENT } from '@angular/common';
13
11
  import { trigger, state, style, transition, group, animate, query, animateChild } from '@angular/animations';
14
12
  import * as i1 from '@angular/cdk/a11y';
15
- import { Directionality } from '@angular/cdk/bidi';
16
- import { Subject, merge, of } from 'rxjs';
13
+ import * as i3 from '@angular/cdk/overlay';
17
14
  import { ESCAPE, hasModifierKey } from '@angular/cdk/keycodes';
15
+ import { Subject, merge } from 'rxjs';
18
16
  import { filter, take } from 'rxjs/operators';
19
17
 
20
18
  /**
@@ -41,85 +39,18 @@ const matBottomSheetAnimations = {
41
39
  ]),
42
40
  };
43
41
 
44
- /**
45
- * @license
46
- * Copyright Google LLC All Rights Reserved.
47
- *
48
- * Use of this source code is governed by an MIT-style license that can be
49
- * found in the LICENSE file at https://angular.io/license
50
- */
51
- /** Injection token that can be used to access the data that was passed in to a bottom sheet. */
52
- const MAT_BOTTOM_SHEET_DATA = new InjectionToken('MatBottomSheetData');
53
- /**
54
- * Configuration used when opening a bottom sheet.
55
- */
56
- class MatBottomSheetConfig {
57
- constructor() {
58
- /** Data being injected into the child component. */
59
- this.data = null;
60
- /** Whether the bottom sheet has a backdrop. */
61
- this.hasBackdrop = true;
62
- /** Whether the user can use escape or clicking outside to close the bottom sheet. */
63
- this.disableClose = false;
64
- /** Aria label to assign to the bottom sheet element. */
65
- this.ariaLabel = null;
66
- /**
67
- * Whether the bottom sheet should close when the user goes backwards/forwards in history.
68
- * Note that this usually doesn't include clicking on links (unless the user is using
69
- * the `HashLocationStrategy`).
70
- */
71
- this.closeOnNavigation = true;
72
- // Note that this is set to 'dialog' by default, because while the a11y recommendations
73
- // are to focus the first focusable element, doing so prevents screen readers from reading out the
74
- // rest of the bottom sheet content.
75
- /**
76
- * Where the bottom sheet should focus on open.
77
- * @breaking-change 14.0.0 Remove boolean option from autoFocus. Use string or
78
- * AutoFocusTarget instead.
79
- */
80
- this.autoFocus = 'dialog';
81
- /**
82
- * Whether the bottom sheet should restore focus to the
83
- * previously-focused element, after it's closed.
84
- */
85
- this.restoreFocus = true;
86
- }
87
- }
88
-
89
- // TODO(crisbeto): consolidate some logic between this, MatDialog and MatSnackBar
90
42
  /**
91
43
  * Internal component that wraps user-provided bottom sheet content.
92
44
  * @docs-private
93
45
  */
94
- class MatBottomSheetContainer extends BasePortalOutlet {
95
- constructor(_elementRef, _changeDetectorRef, _focusTrapFactory, _interactivityChecker, _ngZone, breakpointObserver, document,
96
- /** The bottom sheet configuration. */
97
- bottomSheetConfig) {
98
- super();
99
- this._elementRef = _elementRef;
46
+ class MatBottomSheetContainer extends CdkDialogContainer {
47
+ constructor(elementRef, focusTrapFactory, document, config, checker, ngZone, overlayRef, breakpointObserver, _changeDetectorRef, focusMonitor) {
48
+ super(elementRef, focusTrapFactory, document, config, checker, ngZone, overlayRef, focusMonitor);
100
49
  this._changeDetectorRef = _changeDetectorRef;
101
- this._focusTrapFactory = _focusTrapFactory;
102
- this._interactivityChecker = _interactivityChecker;
103
- this._ngZone = _ngZone;
104
- this.bottomSheetConfig = bottomSheetConfig;
105
50
  /** The state of the bottom sheet animations. */
106
51
  this._animationState = 'void';
107
52
  /** Emits whenever the state of the animation changes. */
108
53
  this._animationStateChanged = new EventEmitter();
109
- /** Element that was focused before the bottom sheet was opened. */
110
- this._elementFocusedBeforeOpened = null;
111
- /**
112
- * Attaches a DOM portal to the bottom sheet container.
113
- * @deprecated To be turned into a method.
114
- * @breaking-change 10.0.0
115
- */
116
- this.attachDomPortal = (portal) => {
117
- this._validatePortalAttached();
118
- this._setPanelClass();
119
- this._savePreviouslyFocusedElement();
120
- return this._portalOutlet.attachDomPortal(portal);
121
- };
122
- this._document = document;
123
54
  this._breakpointSubscription = breakpointObserver
124
55
  .observe([Breakpoints.Medium, Breakpoints.Large, Breakpoints.XLarge])
125
56
  .subscribe(() => {
@@ -128,20 +59,6 @@ class MatBottomSheetContainer extends BasePortalOutlet {
128
59
  this._toggleClass('mat-bottom-sheet-container-xlarge', breakpointObserver.isMatched(Breakpoints.XLarge));
129
60
  });
130
61
  }
131
- /** Attach a component portal as content to this bottom sheet container. */
132
- attachComponentPortal(portal) {
133
- this._validatePortalAttached();
134
- this._setPanelClass();
135
- this._savePreviouslyFocusedElement();
136
- return this._portalOutlet.attachComponentPortal(portal);
137
- }
138
- /** Attach a template portal as content to this bottom sheet container. */
139
- attachTemplatePortal(portal) {
140
- this._validatePortalAttached();
141
- this._setPanelClass();
142
- this._savePreviouslyFocusedElement();
143
- return this._portalOutlet.attachTemplatePortal(portal);
144
- }
145
62
  /** Begin animation of bottom sheet entrance into view. */
146
63
  enter() {
147
64
  if (!this._destroyed) {
@@ -157,14 +74,12 @@ class MatBottomSheetContainer extends BasePortalOutlet {
157
74
  }
158
75
  }
159
76
  ngOnDestroy() {
77
+ super.ngOnDestroy();
160
78
  this._breakpointSubscription.unsubscribe();
161
79
  this._destroyed = true;
162
80
  }
163
81
  _onAnimationDone(event) {
164
- if (event.toState === 'hidden') {
165
- this._restoreFocus();
166
- }
167
- else if (event.toState === 'visible') {
82
+ if (event.toState === 'visible') {
168
83
  this._trapFocus();
169
84
  }
170
85
  this._animationStateChanged.emit(event);
@@ -172,146 +87,33 @@ class MatBottomSheetContainer extends BasePortalOutlet {
172
87
  _onAnimationStart(event) {
173
88
  this._animationStateChanged.emit(event);
174
89
  }
90
+ _captureInitialFocus() { }
175
91
  _toggleClass(cssClass, add) {
176
92
  this._elementRef.nativeElement.classList.toggle(cssClass, add);
177
93
  }
178
- _validatePortalAttached() {
179
- if (this._portalOutlet.hasAttached() && (typeof ngDevMode === 'undefined' || ngDevMode)) {
180
- throw Error('Attempting to attach bottom sheet content after content is already attached');
181
- }
182
- }
183
- _setPanelClass() {
184
- const element = this._elementRef.nativeElement;
185
- element.classList.add(...coerceArray(this.bottomSheetConfig.panelClass || []));
186
- }
187
- /**
188
- * Focuses the provided element. If the element is not focusable, it will add a tabIndex
189
- * attribute to forcefully focus it. The attribute is removed after focus is moved.
190
- * @param element The element to focus.
191
- */
192
- _forceFocus(element, options) {
193
- if (!this._interactivityChecker.isFocusable(element)) {
194
- element.tabIndex = -1;
195
- // The tabindex attribute should be removed to avoid navigating to that element again
196
- this._ngZone.runOutsideAngular(() => {
197
- const callback = () => {
198
- element.removeEventListener('blur', callback);
199
- element.removeEventListener('mousedown', callback);
200
- element.removeAttribute('tabindex');
201
- };
202
- element.addEventListener('blur', callback);
203
- element.addEventListener('mousedown', callback);
204
- });
205
- }
206
- element.focus(options);
207
- }
208
- /**
209
- * Focuses the first element that matches the given selector within the focus trap.
210
- * @param selector The CSS selector for the element to set focus to.
211
- */
212
- _focusByCssSelector(selector, options) {
213
- let elementToFocus = this._elementRef.nativeElement.querySelector(selector);
214
- if (elementToFocus) {
215
- this._forceFocus(elementToFocus, options);
216
- }
217
- }
218
- /**
219
- * Moves the focus inside the focus trap. When autoFocus is not set to 'bottom-sheet',
220
- * if focus cannot be moved then focus will go to the bottom sheet container.
221
- */
222
- _trapFocus() {
223
- const element = this._elementRef.nativeElement;
224
- if (!this._focusTrap) {
225
- this._focusTrap = this._focusTrapFactory.create(element);
226
- }
227
- // If were to attempt to focus immediately, then the content of the bottom sheet would not
228
- // yet be ready in instances where change detection has to run first. To deal with this,
229
- // we simply wait for the microtask queue to be empty when setting focus when autoFocus
230
- // isn't set to bottom sheet. If the element inside the bottom sheet can't be focused,
231
- // then the container is focused so the user can't tab into other elements behind it.
232
- switch (this.bottomSheetConfig.autoFocus) {
233
- case false:
234
- case 'dialog':
235
- const activeElement = _getFocusedElementPierceShadowDom();
236
- // Ensure that focus is on the bottom sheet container. It's possible that a different
237
- // component tried to move focus while the open animation was running. See:
238
- // https://github.com/angular/components/issues/16215. Note that we only want to do this
239
- // if the focus isn't inside the bottom sheet already, because it's possible that the
240
- // consumer specified `autoFocus` in order to move focus themselves.
241
- if (activeElement !== element && !element.contains(activeElement)) {
242
- element.focus();
243
- }
244
- break;
245
- case true:
246
- case 'first-tabbable':
247
- this._focusTrap.focusInitialElementWhenReady();
248
- break;
249
- case 'first-heading':
250
- this._focusByCssSelector('h1, h2, h3, h4, h5, h6, [role="heading"]');
251
- break;
252
- default:
253
- this._focusByCssSelector(this.bottomSheetConfig.autoFocus);
254
- break;
255
- }
256
- }
257
- /** Restores focus to the element that was focused before the bottom sheet was opened. */
258
- _restoreFocus() {
259
- const toFocus = this._elementFocusedBeforeOpened;
260
- // We need the extra check, because IE can set the `activeElement` to null in some cases.
261
- if (this.bottomSheetConfig.restoreFocus && toFocus && typeof toFocus.focus === 'function') {
262
- const activeElement = _getFocusedElementPierceShadowDom();
263
- const element = this._elementRef.nativeElement;
264
- // Make sure that focus is still inside the bottom sheet or is on the body (usually because a
265
- // non-focusable element like the backdrop was clicked) before moving it. It's possible that
266
- // the consumer moved it themselves before the animation was done, in which case we shouldn't
267
- // do anything.
268
- if (!activeElement ||
269
- activeElement === this._document.body ||
270
- activeElement === element ||
271
- element.contains(activeElement)) {
272
- toFocus.focus();
273
- }
274
- }
275
- if (this._focusTrap) {
276
- this._focusTrap.destroy();
277
- }
278
- }
279
- /** Saves a reference to the element that was focused before the bottom sheet was opened. */
280
- _savePreviouslyFocusedElement() {
281
- this._elementFocusedBeforeOpened = _getFocusedElementPierceShadowDom();
282
- // The `focus` method isn't available during server-side rendering.
283
- if (this._elementRef.nativeElement.focus) {
284
- this._ngZone.runOutsideAngular(() => {
285
- Promise.resolve().then(() => this._elementRef.nativeElement.focus());
286
- });
287
- }
288
- }
289
94
  }
290
- MatBottomSheetContainer.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.16", ngImport: i0, type: MatBottomSheetContainer, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: i1.FocusTrapFactory }, { token: i1.InteractivityChecker }, { token: i0.NgZone }, { token: i2.BreakpointObserver }, { token: DOCUMENT, optional: true }, { token: MatBottomSheetConfig }], target: i0.ɵɵFactoryTarget.Component });
291
- MatBottomSheetContainer.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.0.0-next.16", type: MatBottomSheetContainer, selector: "mat-bottom-sheet-container", host: { attributes: { "tabindex": "-1", "role": "dialog", "aria-modal": "true" }, listeners: { "@state.start": "_onAnimationStart($event)", "@state.done": "_onAnimationDone($event)" }, properties: { "attr.aria-label": "bottomSheetConfig?.ariaLabel", "@state": "_animationState" }, classAttribute: "mat-bottom-sheet-container" }, viewQueries: [{ propertyName: "_portalOutlet", first: true, predicate: CdkPortalOutlet, descendants: true, static: true }], usesInheritance: true, ngImport: i0, template: "<ng-template cdkPortalOutlet></ng-template>\r\n", styles: [".mat-bottom-sheet-container{padding:8px 16px;min-width:100vw;box-sizing:border-box;display:block;outline:0;max-height:80vh;overflow:auto}.cdk-high-contrast-active .mat-bottom-sheet-container{outline:1px solid}.mat-bottom-sheet-container-xlarge,.mat-bottom-sheet-container-large,.mat-bottom-sheet-container-medium{border-top-left-radius:4px;border-top-right-radius:4px}.mat-bottom-sheet-container-medium{min-width:384px;max-width:calc(100vw - 128px)}.mat-bottom-sheet-container-large{min-width:512px;max-width:calc(100vw - 256px)}.mat-bottom-sheet-container-xlarge{min-width:576px;max-width:calc(100vw - 384px)}"], dependencies: [{ kind: "directive", type: i4.CdkPortalOutlet, selector: "[cdkPortalOutlet]", inputs: ["cdkPortalOutlet"], outputs: ["attached"], exportAs: ["cdkPortalOutlet"] }], animations: [matBottomSheetAnimations.bottomSheetState], changeDetection: i0.ChangeDetectionStrategy.Default, encapsulation: i0.ViewEncapsulation.None });
292
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.16", ngImport: i0, type: MatBottomSheetContainer, decorators: [{
95
+ MatBottomSheetContainer.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-rc.1", ngImport: i0, type: MatBottomSheetContainer, deps: [{ token: i0.ElementRef }, { token: i1.FocusTrapFactory }, { token: DOCUMENT, optional: true }, { token: i2.DialogConfig }, { token: i1.InteractivityChecker }, { token: i0.NgZone }, { token: i3.OverlayRef }, { token: i4.BreakpointObserver }, { token: i0.ChangeDetectorRef }, { token: i1.FocusMonitor }], target: i0.ɵɵFactoryTarget.Component });
96
+ MatBottomSheetContainer.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.0.0-rc.1", type: MatBottomSheetContainer, selector: "mat-bottom-sheet-container", host: { attributes: { "tabindex": "-1" }, listeners: { "@state.start": "_onAnimationStart($event)", "@state.done": "_onAnimationDone($event)" }, properties: { "attr.role": "_config.role", "attr.aria-modal": "_config.isModal", "attr.aria-label": "_config.ariaLabel", "@state": "_animationState" }, classAttribute: "mat-bottom-sheet-container" }, usesInheritance: true, ngImport: i0, template: "<ng-template cdkPortalOutlet></ng-template>\r\n", styles: [".mat-bottom-sheet-container{padding:8px 16px;min-width:100vw;box-sizing:border-box;display:block;outline:0;max-height:80vh;overflow:auto}.cdk-high-contrast-active .mat-bottom-sheet-container{outline:1px solid}.mat-bottom-sheet-container-xlarge,.mat-bottom-sheet-container-large,.mat-bottom-sheet-container-medium{border-top-left-radius:4px;border-top-right-radius:4px}.mat-bottom-sheet-container-medium{min-width:384px;max-width:calc(100vw - 128px)}.mat-bottom-sheet-container-large{min-width:512px;max-width:calc(100vw - 256px)}.mat-bottom-sheet-container-xlarge{min-width:576px;max-width:calc(100vw - 384px)}"], dependencies: [{ kind: "directive", type: i5.CdkPortalOutlet, selector: "[cdkPortalOutlet]", inputs: ["cdkPortalOutlet"], outputs: ["attached"], exportAs: ["cdkPortalOutlet"] }], animations: [matBottomSheetAnimations.bottomSheetState], changeDetection: i0.ChangeDetectionStrategy.Default, encapsulation: i0.ViewEncapsulation.None });
97
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-rc.1", ngImport: i0, type: MatBottomSheetContainer, decorators: [{
293
98
  type: Component,
294
99
  args: [{ selector: 'mat-bottom-sheet-container', changeDetection: ChangeDetectionStrategy.Default, encapsulation: ViewEncapsulation.None, animations: [matBottomSheetAnimations.bottomSheetState], host: {
295
100
  'class': 'mat-bottom-sheet-container',
296
101
  'tabindex': '-1',
297
- 'role': 'dialog',
298
- 'aria-modal': 'true',
299
- '[attr.aria-label]': 'bottomSheetConfig?.ariaLabel',
102
+ '[attr.role]': '_config.role',
103
+ '[attr.aria-modal]': '_config.isModal',
104
+ '[attr.aria-label]': '_config.ariaLabel',
300
105
  '[@state]': '_animationState',
301
106
  '(@state.start)': '_onAnimationStart($event)',
302
107
  '(@state.done)': '_onAnimationDone($event)',
303
108
  }, template: "<ng-template cdkPortalOutlet></ng-template>\r\n", styles: [".mat-bottom-sheet-container{padding:8px 16px;min-width:100vw;box-sizing:border-box;display:block;outline:0;max-height:80vh;overflow:auto}.cdk-high-contrast-active .mat-bottom-sheet-container{outline:1px solid}.mat-bottom-sheet-container-xlarge,.mat-bottom-sheet-container-large,.mat-bottom-sheet-container-medium{border-top-left-radius:4px;border-top-right-radius:4px}.mat-bottom-sheet-container-medium{min-width:384px;max-width:calc(100vw - 128px)}.mat-bottom-sheet-container-large{min-width:512px;max-width:calc(100vw - 256px)}.mat-bottom-sheet-container-xlarge{min-width:576px;max-width:calc(100vw - 384px)}"] }]
304
109
  }], ctorParameters: function () {
305
- return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i1.FocusTrapFactory }, { type: i1.InteractivityChecker }, { type: i0.NgZone }, { type: i2.BreakpointObserver }, { type: undefined, decorators: [{
110
+ return [{ type: i0.ElementRef }, { type: i1.FocusTrapFactory }, { type: undefined, decorators: [{
306
111
  type: Optional
307
112
  }, {
308
113
  type: Inject,
309
114
  args: [DOCUMENT]
310
- }] }, { type: MatBottomSheetConfig }];
311
- }, propDecorators: { _portalOutlet: [{
312
- type: ViewChild,
313
- args: [CdkPortalOutlet, { static: true }]
314
- }] } });
115
+ }] }, { type: i2.DialogConfig }, { type: i1.InteractivityChecker }, { type: i0.NgZone }, { type: i3.OverlayRef }, { type: i4.BreakpointObserver }, { type: i0.ChangeDetectorRef }, { type: i1.FocusMonitor }];
116
+ } });
315
117
 
316
118
  /**
317
119
  * @license
@@ -322,18 +124,63 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.16",
322
124
  */
323
125
  class MatBottomSheetModule {
324
126
  }
325
- MatBottomSheetModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.16", ngImport: i0, type: MatBottomSheetModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
326
- MatBottomSheetModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.0.0-next.16", ngImport: i0, type: MatBottomSheetModule, declarations: [MatBottomSheetContainer], imports: [OverlayModule, MatCommonModule, PortalModule], exports: [MatBottomSheetContainer, MatCommonModule] });
327
- MatBottomSheetModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.0.0-next.16", ngImport: i0, type: MatBottomSheetModule, imports: [OverlayModule, MatCommonModule, PortalModule, MatCommonModule] });
328
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.16", ngImport: i0, type: MatBottomSheetModule, decorators: [{
127
+ MatBottomSheetModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-rc.1", ngImport: i0, type: MatBottomSheetModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
128
+ MatBottomSheetModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.0.0-rc.1", ngImport: i0, type: MatBottomSheetModule, declarations: [MatBottomSheetContainer], imports: [DialogModule, MatCommonModule, PortalModule], exports: [MatBottomSheetContainer, MatCommonModule] });
129
+ MatBottomSheetModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.0.0-rc.1", ngImport: i0, type: MatBottomSheetModule, imports: [DialogModule, MatCommonModule, PortalModule, MatCommonModule] });
130
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-rc.1", ngImport: i0, type: MatBottomSheetModule, decorators: [{
329
131
  type: NgModule,
330
132
  args: [{
331
- imports: [OverlayModule, MatCommonModule, PortalModule],
133
+ imports: [DialogModule, MatCommonModule, PortalModule],
332
134
  exports: [MatBottomSheetContainer, MatCommonModule],
333
135
  declarations: [MatBottomSheetContainer],
334
136
  }]
335
137
  }] });
336
138
 
139
+ /**
140
+ * @license
141
+ * Copyright Google LLC All Rights Reserved.
142
+ *
143
+ * Use of this source code is governed by an MIT-style license that can be
144
+ * found in the LICENSE file at https://angular.io/license
145
+ */
146
+ /** Injection token that can be used to access the data that was passed in to a bottom sheet. */
147
+ const MAT_BOTTOM_SHEET_DATA = new InjectionToken('MatBottomSheetData');
148
+ /**
149
+ * Configuration used when opening a bottom sheet.
150
+ */
151
+ class MatBottomSheetConfig {
152
+ constructor() {
153
+ /** Data being injected into the child component. */
154
+ this.data = null;
155
+ /** Whether the bottom sheet has a backdrop. */
156
+ this.hasBackdrop = true;
157
+ /** Whether the user can use escape or clicking outside to close the bottom sheet. */
158
+ this.disableClose = false;
159
+ /** Aria label to assign to the bottom sheet element. */
160
+ this.ariaLabel = null;
161
+ /**
162
+ * Whether the bottom sheet should close when the user goes backwards/forwards in history.
163
+ * Note that this usually doesn't include clicking on links (unless the user is using
164
+ * the `HashLocationStrategy`).
165
+ */
166
+ this.closeOnNavigation = true;
167
+ // Note that this is set to 'dialog' by default, because while the a11y recommendations
168
+ // are to focus the first focusable element, doing so prevents screen readers from reading out the
169
+ // rest of the bottom sheet content.
170
+ /**
171
+ * Where the bottom sheet should focus on open.
172
+ * @breaking-change 14.0.0 Remove boolean option from autoFocus. Use string or
173
+ * AutoFocusTarget instead.
174
+ */
175
+ this.autoFocus = 'dialog';
176
+ /**
177
+ * Whether the bottom sheet should restore focus to the
178
+ * previously-focused element, after it's closed.
179
+ */
180
+ this.restoreFocus = true;
181
+ }
182
+ }
183
+
337
184
  /**
338
185
  * @license
339
186
  * Copyright Google LLC All Rights Reserved.
@@ -345,14 +192,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.16",
345
192
  * Reference to a bottom sheet dispatched from the bottom sheet service.
346
193
  */
347
194
  class MatBottomSheetRef {
348
- constructor(containerInstance, _overlayRef) {
349
- this._overlayRef = _overlayRef;
350
- /** Subject for notifying the user that the bottom sheet has been dismissed. */
351
- this._afterDismissed = new Subject();
195
+ constructor(_ref, config, containerInstance) {
196
+ this._ref = _ref;
352
197
  /** Subject for notifying the user that the bottom sheet has opened and appeared. */
353
198
  this._afterOpened = new Subject();
354
199
  this.containerInstance = containerInstance;
355
- this.disableClose = containerInstance.bottomSheetConfig.disableClose;
200
+ this.disableClose = config.disableClose;
356
201
  // Emit when opening animation completes
357
202
  containerInstance._animationStateChanged
358
203
  .pipe(filter(event => event.phaseName === 'done' && event.toState === 'visible'), take(1))
@@ -365,16 +210,12 @@ class MatBottomSheetRef {
365
210
  .pipe(filter(event => event.phaseName === 'done' && event.toState === 'hidden'), take(1))
366
211
  .subscribe(() => {
367
212
  clearTimeout(this._closeFallbackTimeout);
368
- _overlayRef.dispose();
213
+ this._ref.close(this._result);
369
214
  });
370
- _overlayRef
371
- .detachments()
372
- .pipe(take(1))
373
- .subscribe(() => {
374
- this._afterDismissed.next(this._result);
375
- this._afterDismissed.complete();
215
+ _ref.overlayRef.detachments().subscribe(() => {
216
+ this._ref.close(this._result);
376
217
  });
377
- merge(_overlayRef.backdropClick(), _overlayRef.keydownEvents().pipe(filter(event => event.keyCode === ESCAPE))).subscribe(event => {
218
+ merge(this.backdropClick(), this.keydownEvents().pipe(filter(event => event.keyCode === ESCAPE))).subscribe(event => {
378
219
  if (!this.disableClose &&
379
220
  (event.type !== 'keydown' || !hasModifierKey(event))) {
380
221
  event.preventDefault();
@@ -382,33 +223,39 @@ class MatBottomSheetRef {
382
223
  }
383
224
  });
384
225
  }
226
+ /** Instance of the component making up the content of the bottom sheet. */
227
+ get instance() {
228
+ return this._ref.componentInstance;
229
+ }
385
230
  /**
386
231
  * Dismisses the bottom sheet.
387
232
  * @param result Data to be passed back to the bottom sheet opener.
388
233
  */
389
234
  dismiss(result) {
390
- if (!this._afterDismissed.closed) {
391
- // Transition the backdrop in parallel to the bottom sheet.
392
- this.containerInstance._animationStateChanged
393
- .pipe(filter(event => event.phaseName === 'start'), take(1))
394
- .subscribe(event => {
395
- // The logic that disposes of the overlay depends on the exit animation completing, however
396
- // it isn't guaranteed if the parent view is destroyed while it's running. Add a fallback
397
- // timeout which will clean everything up if the animation hasn't fired within the specified
398
- // amount of time plus 100ms. We don't need to run this outside the NgZone, because for the
399
- // vast majority of cases the timeout will have been cleared before it has fired.
400
- this._closeFallbackTimeout = setTimeout(() => {
401
- this._overlayRef.dispose();
402
- }, event.totalTime + 100);
403
- this._overlayRef.detachBackdrop();
404
- });
405
- this._result = result;
406
- this.containerInstance.exit();
235
+ if (!this.containerInstance) {
236
+ return;
407
237
  }
238
+ // Transition the backdrop in parallel to the bottom sheet.
239
+ this.containerInstance._animationStateChanged
240
+ .pipe(filter(event => event.phaseName === 'start'), take(1))
241
+ .subscribe(event => {
242
+ // The logic that disposes of the overlay depends on the exit animation completing, however
243
+ // it isn't guaranteed if the parent view is destroyed while it's running. Add a fallback
244
+ // timeout which will clean everything up if the animation hasn't fired within the specified
245
+ // amount of time plus 100ms. We don't need to run this outside the NgZone, because for the
246
+ // vast majority of cases the timeout will have been cleared before it has fired.
247
+ this._closeFallbackTimeout = setTimeout(() => {
248
+ this._ref.close(this._result);
249
+ }, event.totalTime + 100);
250
+ this._ref.overlayRef.detachBackdrop();
251
+ });
252
+ this._result = result;
253
+ this.containerInstance.exit();
254
+ this.containerInstance = null;
408
255
  }
409
256
  /** Gets an observable that is notified when the bottom sheet is finished closing. */
410
257
  afterDismissed() {
411
- return this._afterDismissed;
258
+ return this._ref.closed;
412
259
  }
413
260
  /** Gets an observable that is notified when the bottom sheet has opened and appeared. */
414
261
  afterOpened() {
@@ -418,13 +265,13 @@ class MatBottomSheetRef {
418
265
  * Gets an observable that emits when the overlay's backdrop has been clicked.
419
266
  */
420
267
  backdropClick() {
421
- return this._overlayRef.backdropClick();
268
+ return this._ref.backdropClick;
422
269
  }
423
270
  /**
424
271
  * Gets an observable that emits when keydown events are targeted on the overlay.
425
272
  */
426
273
  keydownEvents() {
427
- return this._overlayRef.keydownEvents();
274
+ return this._ref.keydownEvents;
428
275
  }
429
276
  }
430
277
 
@@ -441,12 +288,12 @@ const MAT_BOTTOM_SHEET_DEFAULT_OPTIONS = new InjectionToken('mat-bottom-sheet-de
441
288
  * Service to trigger Material Design bottom sheets.
442
289
  */
443
290
  class MatBottomSheet {
444
- constructor(_overlay, _injector, _parentBottomSheet, _defaultOptions) {
291
+ constructor(_overlay, injector, _parentBottomSheet, _defaultOptions) {
445
292
  this._overlay = _overlay;
446
- this._injector = _injector;
447
293
  this._parentBottomSheet = _parentBottomSheet;
448
294
  this._defaultOptions = _defaultOptions;
449
295
  this._bottomSheetRefAtThisLevel = null;
296
+ this._dialog = injector.get(Dialog);
450
297
  }
451
298
  /** Reference to the currently opened bottom sheet. */
452
299
  get _openedBottomSheetRef() {
@@ -462,32 +309,28 @@ class MatBottomSheet {
462
309
  }
463
310
  }
464
311
  open(componentOrTemplateRef, config) {
465
- const _config = _applyConfigDefaults(this._defaultOptions || new MatBottomSheetConfig(), config);
466
- const overlayRef = this._createOverlay(_config);
467
- const container = this._attachContainer(overlayRef, _config);
468
- const ref = new MatBottomSheetRef(container, overlayRef);
469
- if (componentOrTemplateRef instanceof TemplateRef) {
470
- container.attachTemplatePortal(new TemplatePortal(componentOrTemplateRef, null, {
471
- $implicit: _config.data,
472
- bottomSheetRef: ref,
473
- }));
474
- }
475
- else {
476
- const portal = new ComponentPortal(componentOrTemplateRef, undefined, this._createInjector(_config, ref));
477
- const contentRef = container.attachComponentPortal(portal);
478
- ref.instance = contentRef.instance;
479
- }
312
+ const _config = Object.assign(Object.assign({}, (this._defaultOptions || new MatBottomSheetConfig())), config);
313
+ let ref;
314
+ this._dialog.open(componentOrTemplateRef, Object.assign(Object.assign({}, _config), {
315
+ // Disable closing since we need to sync it up to the animation ourselves.
316
+ disableClose: true, maxWidth: '100%', container: MatBottomSheetContainer, scrollStrategy: _config.scrollStrategy || this._overlay.scrollStrategies.block(), positionStrategy: this._overlay.position().global().centerHorizontally().bottom('0'), templateContext: () => ({ bottomSheetRef: ref }), providers: (cdkRef, _cdkConfig, container) => {
317
+ ref = new MatBottomSheetRef(cdkRef, _config, container);
318
+ return [
319
+ { provide: MatBottomSheetRef, useValue: ref },
320
+ { provide: MAT_BOTTOM_SHEET_DATA, useValue: _config.data },
321
+ ];
322
+ } }));
480
323
  // When the bottom sheet is dismissed, clear the reference to it.
481
324
  ref.afterDismissed().subscribe(() => {
482
325
  // Clear the bottom sheet ref if it hasn't already been replaced by a newer one.
483
- if (this._openedBottomSheetRef == ref) {
326
+ if (this._openedBottomSheetRef === ref) {
484
327
  this._openedBottomSheetRef = null;
485
328
  }
486
329
  });
487
330
  if (this._openedBottomSheetRef) {
488
331
  // If a bottom sheet is already in view, dismiss it and enter the
489
332
  // new bottom sheet after exit animation is complete.
490
- this._openedBottomSheetRef.afterDismissed().subscribe(() => ref.containerInstance.enter());
333
+ this._openedBottomSheetRef.afterDismissed().subscribe(() => { var _a; return (_a = ref.containerInstance) === null || _a === void 0 ? void 0 : _a.enter(); });
491
334
  this._openedBottomSheetRef.dismiss();
492
335
  }
493
336
  else {
@@ -511,66 +354,14 @@ class MatBottomSheet {
511
354
  this._bottomSheetRefAtThisLevel.dismiss();
512
355
  }
513
356
  }
514
- /**
515
- * Attaches the bottom sheet container component to the overlay.
516
- */
517
- _attachContainer(overlayRef, config) {
518
- const userInjector = config && config.viewContainerRef && config.viewContainerRef.injector;
519
- const injector = Injector.create({
520
- parent: userInjector || this._injector,
521
- providers: [{ provide: MatBottomSheetConfig, useValue: config }],
522
- });
523
- const containerPortal = new ComponentPortal(MatBottomSheetContainer, config.viewContainerRef, injector);
524
- const containerRef = overlayRef.attach(containerPortal);
525
- return containerRef.instance;
526
- }
527
- /**
528
- * Creates a new overlay and places it in the correct location.
529
- * @param config The user-specified bottom sheet config.
530
- */
531
- _createOverlay(config) {
532
- const overlayConfig = new OverlayConfig({
533
- direction: config.direction,
534
- hasBackdrop: config.hasBackdrop,
535
- disposeOnNavigation: config.closeOnNavigation,
536
- maxWidth: '100%',
537
- scrollStrategy: config.scrollStrategy || this._overlay.scrollStrategies.block(),
538
- positionStrategy: this._overlay.position().global().centerHorizontally().bottom('0'),
539
- });
540
- if (config.backdropClass) {
541
- overlayConfig.backdropClass = config.backdropClass;
542
- }
543
- return this._overlay.create(overlayConfig);
544
- }
545
- /**
546
- * Creates an injector to be used inside of a bottom sheet component.
547
- * @param config Config that was used to create the bottom sheet.
548
- * @param bottomSheetRef Reference to the bottom sheet.
549
- */
550
- _createInjector(config, bottomSheetRef) {
551
- const userInjector = config && config.viewContainerRef && config.viewContainerRef.injector;
552
- const providers = [
553
- { provide: MatBottomSheetRef, useValue: bottomSheetRef },
554
- { provide: MAT_BOTTOM_SHEET_DATA, useValue: config.data },
555
- ];
556
- if (config.direction &&
557
- (!userInjector ||
558
- !userInjector.get(Directionality, null, InjectFlags.Optional))) {
559
- providers.push({
560
- provide: Directionality,
561
- useValue: { value: config.direction, change: of() },
562
- });
563
- }
564
- return Injector.create({ parent: userInjector || this._injector, providers });
565
- }
566
357
  }
567
- MatBottomSheet.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.16", ngImport: i0, type: MatBottomSheet, deps: [{ token: i1$1.Overlay }, { token: i0.Injector }, { token: MatBottomSheet, optional: true, skipSelf: true }, { token: MAT_BOTTOM_SHEET_DEFAULT_OPTIONS, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
568
- MatBottomSheet.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.0-next.16", ngImport: i0, type: MatBottomSheet, providedIn: MatBottomSheetModule });
569
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.16", ngImport: i0, type: MatBottomSheet, decorators: [{
358
+ MatBottomSheet.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-rc.1", ngImport: i0, type: MatBottomSheet, deps: [{ token: i3.Overlay }, { token: i0.Injector }, { token: MatBottomSheet, optional: true, skipSelf: true }, { token: MAT_BOTTOM_SHEET_DEFAULT_OPTIONS, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
359
+ MatBottomSheet.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.0-rc.1", ngImport: i0, type: MatBottomSheet, providedIn: MatBottomSheetModule });
360
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-rc.1", ngImport: i0, type: MatBottomSheet, decorators: [{
570
361
  type: Injectable,
571
362
  args: [{ providedIn: MatBottomSheetModule }]
572
363
  }], ctorParameters: function () {
573
- return [{ type: i1$1.Overlay }, { type: i0.Injector }, { type: MatBottomSheet, decorators: [{
364
+ return [{ type: i3.Overlay }, { type: i0.Injector }, { type: MatBottomSheet, decorators: [{
574
365
  type: Optional
575
366
  }, {
576
367
  type: SkipSelf
@@ -581,15 +372,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.16",
581
372
  args: [MAT_BOTTOM_SHEET_DEFAULT_OPTIONS]
582
373
  }] }];
583
374
  } });
584
- /**
585
- * Applies default options to the bottom sheet config.
586
- * @param defaults Object containing the default values to which to fall back.
587
- * @param config The configuration to which the defaults will be applied.
588
- * @returns The new configuration object with defaults applied.
589
- */
590
- function _applyConfigDefaults(defaults, config) {
591
- return Object.assign(Object.assign({}, defaults), config);
592
- }
593
375
 
594
376
  /**
595
377
  * @license