@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.
- package/bottom-sheet/index.d.ts +15 -82
- package/checkbox/index.d.ts +62 -31
- package/esm2020/autocomplete/autocomplete-module.mjs +5 -5
- package/esm2020/autocomplete/autocomplete-origin.mjs +7 -7
- package/esm2020/autocomplete/autocomplete-trigger.mjs +7 -7
- package/esm2020/autocomplete/autocomplete.mjs +7 -7
- package/esm2020/badge/badge-module.mjs +5 -5
- package/esm2020/badge/badge.mjs +4 -4
- package/esm2020/bottom-sheet/bottom-sheet-container.mjs +23 -175
- package/esm2020/bottom-sheet/bottom-sheet-module.mjs +7 -7
- package/esm2020/bottom-sheet/bottom-sheet-ref.mjs +34 -34
- package/esm2020/bottom-sheet/bottom-sheet.mjs +30 -89
- package/esm2020/button/button-module.mjs +5 -5
- package/esm2020/button/button.mjs +7 -7
- package/esm2020/button-toggle/button-toggle-module.mjs +5 -5
- package/esm2020/button-toggle/button-toggle.mjs +7 -7
- package/esm2020/card/card-module.mjs +5 -5
- package/esm2020/card/card.mjs +43 -43
- package/esm2020/checkbox/checkbox-module.mjs +9 -9
- package/esm2020/checkbox/checkbox-required-validator.mjs +4 -4
- package/esm2020/checkbox/checkbox.mjs +138 -121
- package/esm2020/chips/chip-input.mjs +4 -4
- package/esm2020/chips/chip-list.mjs +4 -4
- package/esm2020/chips/chip.mjs +13 -13
- package/esm2020/chips/chips-module.mjs +5 -5
- package/esm2020/core/common-behaviors/common-module.mjs +5 -5
- package/esm2020/core/datetime/index.mjs +9 -9
- package/esm2020/core/datetime/native-date-adapter.mjs +4 -4
- package/esm2020/core/error/error-options.mjs +7 -7
- package/esm2020/core/line/line.mjs +8 -8
- package/esm2020/core/option/index.mjs +5 -5
- package/esm2020/core/option/optgroup.mjs +7 -7
- package/esm2020/core/option/option.mjs +7 -7
- package/esm2020/core/ripple/index.mjs +5 -5
- package/esm2020/core/ripple/ripple.mjs +4 -4
- package/esm2020/core/selection/pseudo-checkbox/pseudo-checkbox-module.mjs +5 -5
- package/esm2020/core/selection/pseudo-checkbox/pseudo-checkbox.mjs +4 -4
- package/esm2020/core/version.mjs +1 -1
- package/esm2020/datepicker/calendar-body.mjs +4 -4
- package/esm2020/datepicker/calendar.mjs +7 -7
- package/esm2020/datepicker/date-range-input-parts.mjs +10 -10
- package/esm2020/datepicker/date-range-input.mjs +4 -4
- package/esm2020/datepicker/date-range-picker.mjs +4 -4
- package/esm2020/datepicker/date-range-selection-strategy.mjs +4 -4
- package/esm2020/datepicker/date-selection-model.mjs +10 -10
- package/esm2020/datepicker/datepicker-actions.mjs +10 -10
- package/esm2020/datepicker/datepicker-base.mjs +23 -8
- package/esm2020/datepicker/datepicker-input-base.mjs +4 -4
- package/esm2020/datepicker/datepicker-input.mjs +4 -4
- package/esm2020/datepicker/datepicker-intl.mjs +4 -4
- package/esm2020/datepicker/datepicker-module.mjs +5 -5
- package/esm2020/datepicker/datepicker-toggle.mjs +7 -7
- package/esm2020/datepicker/datepicker.mjs +4 -4
- package/esm2020/datepicker/month-view.mjs +4 -4
- package/esm2020/datepicker/multi-year-view.mjs +4 -4
- package/esm2020/datepicker/year-view.mjs +4 -4
- package/esm2020/dialog/dialog-container.mjs +7 -7
- package/esm2020/dialog/dialog-content-directives.mjs +13 -13
- package/esm2020/dialog/dialog-module.mjs +5 -5
- package/esm2020/dialog/dialog.mjs +7 -7
- package/esm2020/divider/divider-module.mjs +5 -5
- package/esm2020/divider/divider.mjs +4 -4
- package/esm2020/expansion/accordion.mjs +4 -4
- package/esm2020/expansion/expansion-module.mjs +5 -5
- package/esm2020/expansion/expansion-panel-content.mjs +4 -4
- package/esm2020/expansion/expansion-panel-header.mjs +10 -10
- package/esm2020/expansion/expansion-panel.mjs +7 -7
- package/esm2020/form-field/error.mjs +4 -4
- package/esm2020/form-field/form-field-control.mjs +4 -4
- package/esm2020/form-field/form-field-module.mjs +5 -5
- package/esm2020/form-field/form-field.mjs +4 -4
- package/esm2020/form-field/hint.mjs +4 -4
- package/esm2020/form-field/label.mjs +4 -4
- package/esm2020/form-field/placeholder.mjs +4 -4
- package/esm2020/form-field/prefix.mjs +4 -4
- package/esm2020/form-field/suffix.mjs +4 -4
- package/esm2020/grid-list/grid-list-module.mjs +5 -5
- package/esm2020/grid-list/grid-list.mjs +4 -4
- package/esm2020/grid-list/grid-tile.mjs +16 -16
- package/esm2020/icon/icon-module.mjs +5 -5
- package/esm2020/icon/icon-registry.mjs +4 -4
- package/esm2020/icon/icon.mjs +4 -4
- package/esm2020/icon/testing/fake-icon-registry.mjs +8 -8
- package/esm2020/input/input-module.mjs +5 -5
- package/esm2020/input/input.mjs +4 -4
- package/esm2020/list/list-module.mjs +5 -5
- package/esm2020/list/list.mjs +19 -19
- package/esm2020/list/selection-list.mjs +7 -7
- package/esm2020/menu/menu-content.mjs +7 -7
- package/esm2020/menu/menu-item.mjs +4 -4
- package/esm2020/menu/menu-module.mjs +5 -5
- package/esm2020/menu/menu-trigger.mjs +7 -7
- package/esm2020/menu/menu.mjs +7 -7
- package/esm2020/paginator/paginator-intl.mjs +4 -4
- package/esm2020/paginator/paginator-module.mjs +5 -5
- package/esm2020/paginator/paginator.mjs +7 -7
- package/esm2020/progress-bar/progress-bar-module.mjs +5 -5
- package/esm2020/progress-bar/progress-bar.mjs +4 -4
- package/esm2020/progress-spinner/progress-spinner-module.mjs +5 -5
- package/esm2020/progress-spinner/progress-spinner.mjs +4 -4
- package/esm2020/radio/radio-module.mjs +5 -5
- package/esm2020/radio/radio.mjs +13 -13
- package/esm2020/select/select-module.mjs +5 -5
- package/esm2020/select/select.mjs +10 -10
- package/esm2020/sidenav/drawer.mjs +10 -10
- package/esm2020/sidenav/sidenav-module.mjs +5 -5
- package/esm2020/sidenav/sidenav.mjs +10 -10
- package/esm2020/slide-toggle/slide-toggle-module.mjs +9 -9
- package/esm2020/slide-toggle/slide-toggle-required-validator.mjs +4 -4
- package/esm2020/slide-toggle/slide-toggle.mjs +89 -77
- package/esm2020/slider/slider-module.mjs +5 -5
- package/esm2020/slider/slider.mjs +4 -4
- package/esm2020/snack-bar/simple-snack-bar.mjs +4 -4
- package/esm2020/snack-bar/snack-bar-container.mjs +4 -4
- package/esm2020/snack-bar/snack-bar-module.mjs +5 -5
- package/esm2020/snack-bar/snack-bar.mjs +7 -7
- package/esm2020/sort/sort-header-intl.mjs +4 -4
- package/esm2020/sort/sort-header.mjs +4 -4
- package/esm2020/sort/sort-module.mjs +5 -5
- package/esm2020/sort/sort.mjs +4 -4
- package/esm2020/stepper/step-content.mjs +4 -4
- package/esm2020/stepper/step-header.mjs +4 -4
- package/esm2020/stepper/step-label.mjs +4 -4
- package/esm2020/stepper/stepper-button.mjs +7 -7
- package/esm2020/stepper/stepper-icon.mjs +4 -4
- package/esm2020/stepper/stepper-intl.mjs +4 -4
- package/esm2020/stepper/stepper-module.mjs +5 -5
- package/esm2020/stepper/stepper.mjs +7 -7
- package/esm2020/table/cell.mjs +22 -22
- package/esm2020/table/row.mjs +22 -22
- package/esm2020/table/table-module.mjs +5 -5
- package/esm2020/table/table.mjs +7 -7
- package/esm2020/table/text-column.mjs +4 -4
- package/esm2020/tabs/ink-bar.mjs +4 -4
- package/esm2020/tabs/paginated-tab-header.mjs +27 -7
- package/esm2020/tabs/tab-body.mjs +10 -10
- package/esm2020/tabs/tab-content.mjs +4 -4
- package/esm2020/tabs/tab-group.mjs +7 -7
- package/esm2020/tabs/tab-header.mjs +7 -7
- package/esm2020/tabs/tab-label-wrapper.mjs +4 -4
- package/esm2020/tabs/tab-label.mjs +4 -4
- package/esm2020/tabs/tab-nav-bar/tab-nav-bar.mjs +16 -16
- package/esm2020/tabs/tab.mjs +4 -4
- package/esm2020/tabs/tabs-module.mjs +5 -5
- package/esm2020/toolbar/toolbar-module.mjs +5 -5
- package/esm2020/toolbar/toolbar.mjs +7 -7
- package/esm2020/tooltip/tooltip-module.mjs +5 -5
- package/esm2020/tooltip/tooltip.mjs +13 -13
- package/esm2020/tree/node.mjs +10 -10
- package/esm2020/tree/outlet.mjs +4 -4
- package/esm2020/tree/padding.mjs +4 -4
- package/esm2020/tree/toggle.mjs +4 -4
- package/esm2020/tree/tree-module.mjs +5 -5
- package/esm2020/tree/tree.mjs +4 -4
- package/fesm2015/autocomplete.mjs +22 -22
- package/fesm2015/autocomplete.mjs.map +1 -1
- package/fesm2015/badge.mjs +7 -7
- package/fesm2015/badge.mjs.map +1 -1
- package/fesm2015/bottom-sheet.mjs +125 -343
- package/fesm2015/bottom-sheet.mjs.map +1 -1
- package/fesm2015/button-toggle.mjs +10 -10
- package/fesm2015/button-toggle.mjs.map +1 -1
- package/fesm2015/button.mjs +10 -10
- package/fesm2015/button.mjs.map +1 -1
- package/fesm2015/card.mjs +46 -46
- package/fesm2015/card.mjs.map +1 -1
- package/fesm2015/checkbox.mjs +151 -134
- package/fesm2015/checkbox.mjs.map +1 -1
- package/fesm2015/chips.mjs +22 -22
- package/fesm2015/chips.mjs.map +1 -1
- package/fesm2015/core.mjs +59 -59
- package/fesm2015/core.mjs.map +1 -1
- package/fesm2015/datepicker.mjs +97 -82
- package/fesm2015/datepicker.mjs.map +1 -1
- package/fesm2015/dialog.mjs +28 -28
- package/fesm2015/dialog.mjs.map +1 -1
- package/fesm2015/divider.mjs +7 -7
- package/fesm2015/divider.mjs.map +1 -1
- package/fesm2015/expansion.mjs +25 -25
- package/fesm2015/expansion.mjs.map +1 -1
- package/fesm2015/form-field.mjs +28 -28
- package/fesm2015/form-field.mjs.map +1 -1
- package/fesm2015/grid-list.mjs +22 -22
- package/fesm2015/grid-list.mjs.map +1 -1
- package/fesm2015/icon/testing.mjs +7 -7
- package/fesm2015/icon/testing.mjs.map +1 -1
- package/fesm2015/icon.mjs +10 -10
- package/fesm2015/icon.mjs.map +1 -1
- package/fesm2015/input.mjs +7 -7
- package/fesm2015/input.mjs.map +1 -1
- package/fesm2015/list.mjs +28 -28
- package/fesm2015/list.mjs.map +1 -1
- package/fesm2015/menu.mjs +25 -25
- package/fesm2015/menu.mjs.map +1 -1
- package/fesm2015/paginator.mjs +13 -13
- package/fesm2015/paginator.mjs.map +1 -1
- package/fesm2015/progress-bar.mjs +7 -7
- package/fesm2015/progress-bar.mjs.map +1 -1
- package/fesm2015/progress-spinner.mjs +7 -7
- package/fesm2015/progress-spinner.mjs.map +1 -1
- package/fesm2015/radio.mjs +16 -16
- package/fesm2015/radio.mjs.map +1 -1
- package/fesm2015/select.mjs +13 -13
- package/fesm2015/select.mjs.map +1 -1
- package/fesm2015/sidenav.mjs +22 -22
- package/fesm2015/sidenav.mjs.map +1 -1
- package/fesm2015/slide-toggle.mjs +100 -88
- package/fesm2015/slide-toggle.mjs.map +1 -1
- package/fesm2015/slider.mjs +7 -7
- package/fesm2015/slider.mjs.map +1 -1
- package/fesm2015/snack-bar.mjs +16 -16
- package/fesm2015/snack-bar.mjs.map +1 -1
- package/fesm2015/sort.mjs +13 -13
- package/fesm2015/sort.mjs.map +1 -1
- package/fesm2015/stepper.mjs +31 -31
- package/fesm2015/stepper.mjs.map +1 -1
- package/fesm2015/table.mjs +55 -55
- package/fesm2015/table.mjs.map +1 -1
- package/fesm2015/tabs.mjs +81 -61
- package/fesm2015/tabs.mjs.map +1 -1
- package/fesm2015/toolbar.mjs +10 -10
- package/fesm2015/toolbar.mjs.map +1 -1
- package/fesm2015/tooltip.mjs +16 -16
- package/fesm2015/tooltip.mjs.map +1 -1
- package/fesm2015/tree.mjs +25 -25
- package/fesm2015/tree.mjs.map +1 -1
- package/fesm2020/autocomplete.mjs +22 -22
- package/fesm2020/autocomplete.mjs.map +1 -1
- package/fesm2020/badge.mjs +7 -7
- package/fesm2020/badge.mjs.map +1 -1
- package/fesm2020/bottom-sheet.mjs +132 -342
- package/fesm2020/bottom-sheet.mjs.map +1 -1
- package/fesm2020/button-toggle.mjs +10 -10
- package/fesm2020/button-toggle.mjs.map +1 -1
- package/fesm2020/button.mjs +10 -10
- package/fesm2020/button.mjs.map +1 -1
- package/fesm2020/card.mjs +46 -46
- package/fesm2020/card.mjs.map +1 -1
- package/fesm2020/checkbox.mjs +149 -132
- package/fesm2020/checkbox.mjs.map +1 -1
- package/fesm2020/chips.mjs +22 -22
- package/fesm2020/chips.mjs.map +1 -1
- package/fesm2020/core.mjs +59 -59
- package/fesm2020/core.mjs.map +1 -1
- package/fesm2020/datepicker.mjs +97 -82
- package/fesm2020/datepicker.mjs.map +1 -1
- package/fesm2020/dialog.mjs +28 -28
- package/fesm2020/dialog.mjs.map +1 -1
- package/fesm2020/divider.mjs +7 -7
- package/fesm2020/divider.mjs.map +1 -1
- package/fesm2020/expansion.mjs +25 -25
- package/fesm2020/expansion.mjs.map +1 -1
- package/fesm2020/form-field.mjs +28 -28
- package/fesm2020/form-field.mjs.map +1 -1
- package/fesm2020/grid-list.mjs +22 -22
- package/fesm2020/grid-list.mjs.map +1 -1
- package/fesm2020/icon/testing.mjs +7 -7
- package/fesm2020/icon/testing.mjs.map +1 -1
- package/fesm2020/icon.mjs +10 -10
- package/fesm2020/icon.mjs.map +1 -1
- package/fesm2020/input.mjs +7 -7
- package/fesm2020/input.mjs.map +1 -1
- package/fesm2020/list.mjs +28 -28
- package/fesm2020/list.mjs.map +1 -1
- package/fesm2020/menu.mjs +25 -25
- package/fesm2020/menu.mjs.map +1 -1
- package/fesm2020/paginator.mjs +13 -13
- package/fesm2020/paginator.mjs.map +1 -1
- package/fesm2020/progress-bar.mjs +7 -7
- package/fesm2020/progress-bar.mjs.map +1 -1
- package/fesm2020/progress-spinner.mjs +7 -7
- package/fesm2020/progress-spinner.mjs.map +1 -1
- package/fesm2020/radio.mjs +16 -16
- package/fesm2020/radio.mjs.map +1 -1
- package/fesm2020/select.mjs +13 -13
- package/fesm2020/select.mjs.map +1 -1
- package/fesm2020/sidenav.mjs +22 -22
- package/fesm2020/sidenav.mjs.map +1 -1
- package/fesm2020/slide-toggle.mjs +100 -88
- package/fesm2020/slide-toggle.mjs.map +1 -1
- package/fesm2020/slider.mjs +7 -7
- package/fesm2020/slider.mjs.map +1 -1
- package/fesm2020/snack-bar.mjs +16 -16
- package/fesm2020/snack-bar.mjs.map +1 -1
- package/fesm2020/sort.mjs +13 -13
- package/fesm2020/sort.mjs.map +1 -1
- package/fesm2020/stepper.mjs +31 -31
- package/fesm2020/stepper.mjs.map +1 -1
- package/fesm2020/table.mjs +55 -55
- package/fesm2020/table.mjs.map +1 -1
- package/fesm2020/tabs.mjs +81 -61
- package/fesm2020/tabs.mjs.map +1 -1
- package/fesm2020/toolbar.mjs +10 -10
- package/fesm2020/toolbar.mjs.map +1 -1
- package/fesm2020/tooltip.mjs +16 -16
- package/fesm2020/tooltip.mjs.map +1 -1
- package/fesm2020/tree.mjs +25 -25
- package/fesm2020/tree.mjs.map +1 -1
- package/package.json +7 -7
- package/schematics/ng-add/index.js +2 -2
- package/schematics/ng-add/index.mjs +2 -2
- package/schematics/ng-add/setup-project.js +59 -18
- package/schematics/ng-add/setup-project.mjs +59 -18
- package/schematics/ng-generate/address-form/schema.json +3 -0
- package/schematics/ng-generate/dashboard/schema.json +3 -0
- package/schematics/ng-generate/navigation/schema.json +3 -0
- package/schematics/ng-generate/table/schema.json +3 -0
- package/schematics/ng-generate/tree/schema.json +3 -0
- package/slide-toggle/index.d.ts +45 -32
- package/tabs/index.d.ts +2 -0
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import {
|
|
3
|
-
import * as
|
|
4
|
-
import {
|
|
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 {
|
|
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
8
|
import * as i1 from '@angular/cdk/a11y';
|
|
9
|
-
import
|
|
10
|
-
import * as i2 from '@angular/cdk/layout';
|
|
9
|
+
import * as i4 from '@angular/cdk/layout';
|
|
11
10
|
import { Breakpoints } from '@angular/cdk/layout';
|
|
12
|
-
import
|
|
11
|
+
import * as i3 from '@angular/cdk/overlay';
|
|
13
12
|
import { DOCUMENT } from '@angular/common';
|
|
14
13
|
import { trigger, state, style, transition, group, animate, query, animateChild } from '@angular/animations';
|
|
15
|
-
import { Directionality } from '@angular/cdk/bidi';
|
|
16
|
-
import { Subject, merge, of } from 'rxjs';
|
|
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
|
|
95
|
-
constructor(
|
|
96
|
-
|
|
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 === '
|
|
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,144 +87,31 @@ 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-
|
|
291
|
-
MatBottomSheetContainer.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.0.0-
|
|
292
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-
|
|
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': '
|
|
298
|
-
'aria-modal': '
|
|
299
|
-
'[attr.aria-label]': '
|
|
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
|
-
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type:
|
|
109
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i1.FocusTrapFactory }, { type: undefined, decorators: [{
|
|
305
110
|
type: Optional
|
|
306
111
|
}, {
|
|
307
112
|
type: Inject,
|
|
308
113
|
args: [DOCUMENT]
|
|
309
|
-
}] }, { type:
|
|
310
|
-
type: ViewChild,
|
|
311
|
-
args: [CdkPortalOutlet, { static: true }]
|
|
312
|
-
}] } });
|
|
114
|
+
}] }, { type: i2.DialogConfig }, { type: i1.InteractivityChecker }, { type: i0.NgZone }, { type: i3.OverlayRef }, { type: i4.BreakpointObserver }, { type: i0.ChangeDetectorRef }, { type: i1.FocusMonitor }]; } });
|
|
313
115
|
|
|
314
116
|
/**
|
|
315
117
|
* @license
|
|
@@ -320,18 +122,63 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.16",
|
|
|
320
122
|
*/
|
|
321
123
|
class MatBottomSheetModule {
|
|
322
124
|
}
|
|
323
|
-
MatBottomSheetModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-
|
|
324
|
-
MatBottomSheetModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.0.0-
|
|
325
|
-
MatBottomSheetModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.0.0-
|
|
326
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-
|
|
125
|
+
MatBottomSheetModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-rc.1", ngImport: i0, type: MatBottomSheetModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
126
|
+
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] });
|
|
127
|
+
MatBottomSheetModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.0.0-rc.1", ngImport: i0, type: MatBottomSheetModule, imports: [DialogModule, MatCommonModule, PortalModule, MatCommonModule] });
|
|
128
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-rc.1", ngImport: i0, type: MatBottomSheetModule, decorators: [{
|
|
327
129
|
type: NgModule,
|
|
328
130
|
args: [{
|
|
329
|
-
imports: [
|
|
131
|
+
imports: [DialogModule, MatCommonModule, PortalModule],
|
|
330
132
|
exports: [MatBottomSheetContainer, MatCommonModule],
|
|
331
133
|
declarations: [MatBottomSheetContainer],
|
|
332
134
|
}]
|
|
333
135
|
}] });
|
|
334
136
|
|
|
137
|
+
/**
|
|
138
|
+
* @license
|
|
139
|
+
* Copyright Google LLC All Rights Reserved.
|
|
140
|
+
*
|
|
141
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
142
|
+
* found in the LICENSE file at https://angular.io/license
|
|
143
|
+
*/
|
|
144
|
+
/** Injection token that can be used to access the data that was passed in to a bottom sheet. */
|
|
145
|
+
const MAT_BOTTOM_SHEET_DATA = new InjectionToken('MatBottomSheetData');
|
|
146
|
+
/**
|
|
147
|
+
* Configuration used when opening a bottom sheet.
|
|
148
|
+
*/
|
|
149
|
+
class MatBottomSheetConfig {
|
|
150
|
+
constructor() {
|
|
151
|
+
/** Data being injected into the child component. */
|
|
152
|
+
this.data = null;
|
|
153
|
+
/** Whether the bottom sheet has a backdrop. */
|
|
154
|
+
this.hasBackdrop = true;
|
|
155
|
+
/** Whether the user can use escape or clicking outside to close the bottom sheet. */
|
|
156
|
+
this.disableClose = false;
|
|
157
|
+
/** Aria label to assign to the bottom sheet element. */
|
|
158
|
+
this.ariaLabel = null;
|
|
159
|
+
/**
|
|
160
|
+
* Whether the bottom sheet should close when the user goes backwards/forwards in history.
|
|
161
|
+
* Note that this usually doesn't include clicking on links (unless the user is using
|
|
162
|
+
* the `HashLocationStrategy`).
|
|
163
|
+
*/
|
|
164
|
+
this.closeOnNavigation = true;
|
|
165
|
+
// Note that this is set to 'dialog' by default, because while the a11y recommendations
|
|
166
|
+
// are to focus the first focusable element, doing so prevents screen readers from reading out the
|
|
167
|
+
// rest of the bottom sheet content.
|
|
168
|
+
/**
|
|
169
|
+
* Where the bottom sheet should focus on open.
|
|
170
|
+
* @breaking-change 14.0.0 Remove boolean option from autoFocus. Use string or
|
|
171
|
+
* AutoFocusTarget instead.
|
|
172
|
+
*/
|
|
173
|
+
this.autoFocus = 'dialog';
|
|
174
|
+
/**
|
|
175
|
+
* Whether the bottom sheet should restore focus to the
|
|
176
|
+
* previously-focused element, after it's closed.
|
|
177
|
+
*/
|
|
178
|
+
this.restoreFocus = true;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
335
182
|
/**
|
|
336
183
|
* @license
|
|
337
184
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -343,14 +190,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.16",
|
|
|
343
190
|
* Reference to a bottom sheet dispatched from the bottom sheet service.
|
|
344
191
|
*/
|
|
345
192
|
class MatBottomSheetRef {
|
|
346
|
-
constructor(
|
|
347
|
-
this.
|
|
348
|
-
/** Subject for notifying the user that the bottom sheet has been dismissed. */
|
|
349
|
-
this._afterDismissed = new Subject();
|
|
193
|
+
constructor(_ref, config, containerInstance) {
|
|
194
|
+
this._ref = _ref;
|
|
350
195
|
/** Subject for notifying the user that the bottom sheet has opened and appeared. */
|
|
351
196
|
this._afterOpened = new Subject();
|
|
352
197
|
this.containerInstance = containerInstance;
|
|
353
|
-
this.disableClose =
|
|
198
|
+
this.disableClose = config.disableClose;
|
|
354
199
|
// Emit when opening animation completes
|
|
355
200
|
containerInstance._animationStateChanged
|
|
356
201
|
.pipe(filter(event => event.phaseName === 'done' && event.toState === 'visible'), take(1))
|
|
@@ -363,16 +208,12 @@ class MatBottomSheetRef {
|
|
|
363
208
|
.pipe(filter(event => event.phaseName === 'done' && event.toState === 'hidden'), take(1))
|
|
364
209
|
.subscribe(() => {
|
|
365
210
|
clearTimeout(this._closeFallbackTimeout);
|
|
366
|
-
|
|
211
|
+
this._ref.close(this._result);
|
|
367
212
|
});
|
|
368
|
-
|
|
369
|
-
.
|
|
370
|
-
.pipe(take(1))
|
|
371
|
-
.subscribe(() => {
|
|
372
|
-
this._afterDismissed.next(this._result);
|
|
373
|
-
this._afterDismissed.complete();
|
|
213
|
+
_ref.overlayRef.detachments().subscribe(() => {
|
|
214
|
+
this._ref.close(this._result);
|
|
374
215
|
});
|
|
375
|
-
merge(
|
|
216
|
+
merge(this.backdropClick(), this.keydownEvents().pipe(filter(event => event.keyCode === ESCAPE))).subscribe(event => {
|
|
376
217
|
if (!this.disableClose &&
|
|
377
218
|
(event.type !== 'keydown' || !hasModifierKey(event))) {
|
|
378
219
|
event.preventDefault();
|
|
@@ -380,33 +221,39 @@ class MatBottomSheetRef {
|
|
|
380
221
|
}
|
|
381
222
|
});
|
|
382
223
|
}
|
|
224
|
+
/** Instance of the component making up the content of the bottom sheet. */
|
|
225
|
+
get instance() {
|
|
226
|
+
return this._ref.componentInstance;
|
|
227
|
+
}
|
|
383
228
|
/**
|
|
384
229
|
* Dismisses the bottom sheet.
|
|
385
230
|
* @param result Data to be passed back to the bottom sheet opener.
|
|
386
231
|
*/
|
|
387
232
|
dismiss(result) {
|
|
388
|
-
if (!this.
|
|
389
|
-
|
|
390
|
-
this.containerInstance._animationStateChanged
|
|
391
|
-
.pipe(filter(event => event.phaseName === 'start'), take(1))
|
|
392
|
-
.subscribe(event => {
|
|
393
|
-
// The logic that disposes of the overlay depends on the exit animation completing, however
|
|
394
|
-
// it isn't guaranteed if the parent view is destroyed while it's running. Add a fallback
|
|
395
|
-
// timeout which will clean everything up if the animation hasn't fired within the specified
|
|
396
|
-
// amount of time plus 100ms. We don't need to run this outside the NgZone, because for the
|
|
397
|
-
// vast majority of cases the timeout will have been cleared before it has fired.
|
|
398
|
-
this._closeFallbackTimeout = setTimeout(() => {
|
|
399
|
-
this._overlayRef.dispose();
|
|
400
|
-
}, event.totalTime + 100);
|
|
401
|
-
this._overlayRef.detachBackdrop();
|
|
402
|
-
});
|
|
403
|
-
this._result = result;
|
|
404
|
-
this.containerInstance.exit();
|
|
233
|
+
if (!this.containerInstance) {
|
|
234
|
+
return;
|
|
405
235
|
}
|
|
236
|
+
// Transition the backdrop in parallel to the bottom sheet.
|
|
237
|
+
this.containerInstance._animationStateChanged
|
|
238
|
+
.pipe(filter(event => event.phaseName === 'start'), take(1))
|
|
239
|
+
.subscribe(event => {
|
|
240
|
+
// The logic that disposes of the overlay depends on the exit animation completing, however
|
|
241
|
+
// it isn't guaranteed if the parent view is destroyed while it's running. Add a fallback
|
|
242
|
+
// timeout which will clean everything up if the animation hasn't fired within the specified
|
|
243
|
+
// amount of time plus 100ms. We don't need to run this outside the NgZone, because for the
|
|
244
|
+
// vast majority of cases the timeout will have been cleared before it has fired.
|
|
245
|
+
this._closeFallbackTimeout = setTimeout(() => {
|
|
246
|
+
this._ref.close(this._result);
|
|
247
|
+
}, event.totalTime + 100);
|
|
248
|
+
this._ref.overlayRef.detachBackdrop();
|
|
249
|
+
});
|
|
250
|
+
this._result = result;
|
|
251
|
+
this.containerInstance.exit();
|
|
252
|
+
this.containerInstance = null;
|
|
406
253
|
}
|
|
407
254
|
/** Gets an observable that is notified when the bottom sheet is finished closing. */
|
|
408
255
|
afterDismissed() {
|
|
409
|
-
return this.
|
|
256
|
+
return this._ref.closed;
|
|
410
257
|
}
|
|
411
258
|
/** Gets an observable that is notified when the bottom sheet has opened and appeared. */
|
|
412
259
|
afterOpened() {
|
|
@@ -416,13 +263,13 @@ class MatBottomSheetRef {
|
|
|
416
263
|
* Gets an observable that emits when the overlay's backdrop has been clicked.
|
|
417
264
|
*/
|
|
418
265
|
backdropClick() {
|
|
419
|
-
return this.
|
|
266
|
+
return this._ref.backdropClick;
|
|
420
267
|
}
|
|
421
268
|
/**
|
|
422
269
|
* Gets an observable that emits when keydown events are targeted on the overlay.
|
|
423
270
|
*/
|
|
424
271
|
keydownEvents() {
|
|
425
|
-
return this.
|
|
272
|
+
return this._ref.keydownEvents;
|
|
426
273
|
}
|
|
427
274
|
}
|
|
428
275
|
|
|
@@ -439,12 +286,12 @@ const MAT_BOTTOM_SHEET_DEFAULT_OPTIONS = new InjectionToken('mat-bottom-sheet-de
|
|
|
439
286
|
* Service to trigger Material Design bottom sheets.
|
|
440
287
|
*/
|
|
441
288
|
class MatBottomSheet {
|
|
442
|
-
constructor(_overlay,
|
|
289
|
+
constructor(_overlay, injector, _parentBottomSheet, _defaultOptions) {
|
|
443
290
|
this._overlay = _overlay;
|
|
444
|
-
this._injector = _injector;
|
|
445
291
|
this._parentBottomSheet = _parentBottomSheet;
|
|
446
292
|
this._defaultOptions = _defaultOptions;
|
|
447
293
|
this._bottomSheetRefAtThisLevel = null;
|
|
294
|
+
this._dialog = injector.get(Dialog);
|
|
448
295
|
}
|
|
449
296
|
/** Reference to the currently opened bottom sheet. */
|
|
450
297
|
get _openedBottomSheetRef() {
|
|
@@ -460,32 +307,36 @@ class MatBottomSheet {
|
|
|
460
307
|
}
|
|
461
308
|
}
|
|
462
309
|
open(componentOrTemplateRef, config) {
|
|
463
|
-
const _config =
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
310
|
+
const _config = { ...(this._defaultOptions || new MatBottomSheetConfig()), ...config };
|
|
311
|
+
let ref;
|
|
312
|
+
this._dialog.open(componentOrTemplateRef, {
|
|
313
|
+
..._config,
|
|
314
|
+
// Disable closing since we need to sync it up to the animation ourselves.
|
|
315
|
+
disableClose: true,
|
|
316
|
+
maxWidth: '100%',
|
|
317
|
+
container: MatBottomSheetContainer,
|
|
318
|
+
scrollStrategy: _config.scrollStrategy || this._overlay.scrollStrategies.block(),
|
|
319
|
+
positionStrategy: this._overlay.position().global().centerHorizontally().bottom('0'),
|
|
320
|
+
templateContext: () => ({ bottomSheetRef: ref }),
|
|
321
|
+
providers: (cdkRef, _cdkConfig, container) => {
|
|
322
|
+
ref = new MatBottomSheetRef(cdkRef, _config, container);
|
|
323
|
+
return [
|
|
324
|
+
{ provide: MatBottomSheetRef, useValue: ref },
|
|
325
|
+
{ provide: MAT_BOTTOM_SHEET_DATA, useValue: _config.data },
|
|
326
|
+
];
|
|
327
|
+
},
|
|
328
|
+
});
|
|
478
329
|
// When the bottom sheet is dismissed, clear the reference to it.
|
|
479
330
|
ref.afterDismissed().subscribe(() => {
|
|
480
331
|
// Clear the bottom sheet ref if it hasn't already been replaced by a newer one.
|
|
481
|
-
if (this._openedBottomSheetRef
|
|
332
|
+
if (this._openedBottomSheetRef === ref) {
|
|
482
333
|
this._openedBottomSheetRef = null;
|
|
483
334
|
}
|
|
484
335
|
});
|
|
485
336
|
if (this._openedBottomSheetRef) {
|
|
486
337
|
// If a bottom sheet is already in view, dismiss it and enter the
|
|
487
338
|
// new bottom sheet after exit animation is complete.
|
|
488
|
-
this._openedBottomSheetRef.afterDismissed().subscribe(() => ref.containerInstance
|
|
339
|
+
this._openedBottomSheetRef.afterDismissed().subscribe(() => ref.containerInstance?.enter());
|
|
489
340
|
this._openedBottomSheetRef.dismiss();
|
|
490
341
|
}
|
|
491
342
|
else {
|
|
@@ -509,65 +360,13 @@ class MatBottomSheet {
|
|
|
509
360
|
this._bottomSheetRefAtThisLevel.dismiss();
|
|
510
361
|
}
|
|
511
362
|
}
|
|
512
|
-
/**
|
|
513
|
-
* Attaches the bottom sheet container component to the overlay.
|
|
514
|
-
*/
|
|
515
|
-
_attachContainer(overlayRef, config) {
|
|
516
|
-
const userInjector = config && config.viewContainerRef && config.viewContainerRef.injector;
|
|
517
|
-
const injector = Injector.create({
|
|
518
|
-
parent: userInjector || this._injector,
|
|
519
|
-
providers: [{ provide: MatBottomSheetConfig, useValue: config }],
|
|
520
|
-
});
|
|
521
|
-
const containerPortal = new ComponentPortal(MatBottomSheetContainer, config.viewContainerRef, injector);
|
|
522
|
-
const containerRef = overlayRef.attach(containerPortal);
|
|
523
|
-
return containerRef.instance;
|
|
524
|
-
}
|
|
525
|
-
/**
|
|
526
|
-
* Creates a new overlay and places it in the correct location.
|
|
527
|
-
* @param config The user-specified bottom sheet config.
|
|
528
|
-
*/
|
|
529
|
-
_createOverlay(config) {
|
|
530
|
-
const overlayConfig = new OverlayConfig({
|
|
531
|
-
direction: config.direction,
|
|
532
|
-
hasBackdrop: config.hasBackdrop,
|
|
533
|
-
disposeOnNavigation: config.closeOnNavigation,
|
|
534
|
-
maxWidth: '100%',
|
|
535
|
-
scrollStrategy: config.scrollStrategy || this._overlay.scrollStrategies.block(),
|
|
536
|
-
positionStrategy: this._overlay.position().global().centerHorizontally().bottom('0'),
|
|
537
|
-
});
|
|
538
|
-
if (config.backdropClass) {
|
|
539
|
-
overlayConfig.backdropClass = config.backdropClass;
|
|
540
|
-
}
|
|
541
|
-
return this._overlay.create(overlayConfig);
|
|
542
|
-
}
|
|
543
|
-
/**
|
|
544
|
-
* Creates an injector to be used inside of a bottom sheet component.
|
|
545
|
-
* @param config Config that was used to create the bottom sheet.
|
|
546
|
-
* @param bottomSheetRef Reference to the bottom sheet.
|
|
547
|
-
*/
|
|
548
|
-
_createInjector(config, bottomSheetRef) {
|
|
549
|
-
const userInjector = config && config.viewContainerRef && config.viewContainerRef.injector;
|
|
550
|
-
const providers = [
|
|
551
|
-
{ provide: MatBottomSheetRef, useValue: bottomSheetRef },
|
|
552
|
-
{ provide: MAT_BOTTOM_SHEET_DATA, useValue: config.data },
|
|
553
|
-
];
|
|
554
|
-
if (config.direction &&
|
|
555
|
-
(!userInjector ||
|
|
556
|
-
!userInjector.get(Directionality, null, InjectFlags.Optional))) {
|
|
557
|
-
providers.push({
|
|
558
|
-
provide: Directionality,
|
|
559
|
-
useValue: { value: config.direction, change: of() },
|
|
560
|
-
});
|
|
561
|
-
}
|
|
562
|
-
return Injector.create({ parent: userInjector || this._injector, providers });
|
|
563
|
-
}
|
|
564
363
|
}
|
|
565
|
-
MatBottomSheet.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-
|
|
566
|
-
MatBottomSheet.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.0-
|
|
567
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-
|
|
364
|
+
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 });
|
|
365
|
+
MatBottomSheet.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.0-rc.1", ngImport: i0, type: MatBottomSheet, providedIn: MatBottomSheetModule });
|
|
366
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-rc.1", ngImport: i0, type: MatBottomSheet, decorators: [{
|
|
568
367
|
type: Injectable,
|
|
569
368
|
args: [{ providedIn: MatBottomSheetModule }]
|
|
570
|
-
}], ctorParameters: function () { return [{ type:
|
|
369
|
+
}], ctorParameters: function () { return [{ type: i3.Overlay }, { type: i0.Injector }, { type: MatBottomSheet, decorators: [{
|
|
571
370
|
type: Optional
|
|
572
371
|
}, {
|
|
573
372
|
type: SkipSelf
|
|
@@ -577,15 +376,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.16",
|
|
|
577
376
|
type: Inject,
|
|
578
377
|
args: [MAT_BOTTOM_SHEET_DEFAULT_OPTIONS]
|
|
579
378
|
}] }]; } });
|
|
580
|
-
/**
|
|
581
|
-
* Applies default options to the bottom sheet config.
|
|
582
|
-
* @param defaults Object containing the default values to which to fall back.
|
|
583
|
-
* @param config The configuration to which the defaults will be applied.
|
|
584
|
-
* @returns The new configuration object with defaults applied.
|
|
585
|
-
*/
|
|
586
|
-
function _applyConfigDefaults(defaults, config) {
|
|
587
|
-
return { ...defaults, ...config };
|
|
588
|
-
}
|
|
589
379
|
|
|
590
380
|
/**
|
|
591
381
|
* @license
|