@angular/cdk-experimental 14.0.0-next.11 → 14.0.0-next.12

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 (145) hide show
  1. package/column-resize/column-resize-directives/column-resize-flex.d.ts +1 -1
  2. package/column-resize/column-resize-directives/column-resize.d.ts +1 -1
  3. package/column-resize/column-resize-directives/default-enabled-column-resize-flex.d.ts +1 -1
  4. package/column-resize/column-resize-directives/default-enabled-column-resize.d.ts +1 -1
  5. package/column-resize/column-resize.d.ts +1 -1
  6. package/column-resize/overlay-handle.d.ts +1 -1
  7. package/column-resize/resizable.d.ts +1 -1
  8. package/combobox/combobox-popup.d.ts +1 -1
  9. package/combobox/combobox.d.ts +1 -1
  10. package/esm2020/column-resize/column-resize-directives/column-resize-flex.mjs +3 -3
  11. package/esm2020/column-resize/column-resize-directives/column-resize.mjs +3 -3
  12. package/esm2020/column-resize/column-resize-directives/default-enabled-column-resize-flex.mjs +3 -3
  13. package/esm2020/column-resize/column-resize-directives/default-enabled-column-resize.mjs +3 -3
  14. package/esm2020/column-resize/column-resize-module.mjs +8 -8
  15. package/esm2020/column-resize/column-resize-notifier.mjs +6 -6
  16. package/esm2020/column-resize/column-resize.mjs +3 -3
  17. package/esm2020/column-resize/column-size-store.mjs +3 -3
  18. package/esm2020/column-resize/event-dispatcher.mjs +3 -3
  19. package/esm2020/column-resize/overlay-handle.mjs +3 -3
  20. package/esm2020/column-resize/resizable.mjs +3 -3
  21. package/esm2020/column-resize/resize-strategy.mjs +9 -9
  22. package/esm2020/combobox/combobox-module.mjs +4 -4
  23. package/esm2020/combobox/combobox-popup.mjs +3 -3
  24. package/esm2020/combobox/combobox.mjs +3 -3
  25. package/esm2020/listbox/listbox-module.mjs +4 -4
  26. package/esm2020/listbox/listbox.mjs +6 -6
  27. package/esm2020/popover-edit/edit-event-dispatcher.mjs +3 -3
  28. package/esm2020/popover-edit/edit-ref.mjs +3 -3
  29. package/esm2020/popover-edit/edit-services.mjs +3 -3
  30. package/esm2020/popover-edit/focus-dispatcher.mjs +3 -3
  31. package/esm2020/popover-edit/focus-escape-notifier.mjs +3 -3
  32. package/esm2020/popover-edit/lens-directives.mjs +9 -9
  33. package/esm2020/popover-edit/popover-edit-module.mjs +4 -4
  34. package/esm2020/popover-edit/popover-edit-position-strategy-factory.mjs +6 -6
  35. package/esm2020/popover-edit/table-directives.mjs +15 -15
  36. package/esm2020/scrolling/auto-size-virtual-scroll.mjs +3 -3
  37. package/esm2020/scrolling/scrolling-module.mjs +4 -4
  38. package/esm2020/selection/row-selection.mjs +3 -3
  39. package/esm2020/selection/select-all.mjs +3 -3
  40. package/esm2020/selection/selection-column.mjs +9 -9
  41. package/esm2020/selection/selection-module.mjs +4 -4
  42. package/esm2020/selection/selection-toggle.mjs +3 -3
  43. package/esm2020/selection/selection.mjs +3 -3
  44. package/esm2020/table-scroll-container/table-scroll-container-module.mjs +4 -4
  45. package/esm2020/table-scroll-container/table-scroll-container.mjs +3 -3
  46. package/esm2020/version.mjs +1 -1
  47. package/fesm2015/cdk-experimental.mjs +1 -1
  48. package/fesm2015/cdk-experimental.mjs.map +1 -1
  49. package/fesm2015/column-resize.mjs +50 -50
  50. package/fesm2015/combobox.mjs +10 -10
  51. package/fesm2015/listbox.mjs +10 -10
  52. package/fesm2015/popover-edit.mjs +49 -49
  53. package/fesm2015/scrolling.mjs +7 -7
  54. package/fesm2015/selection.mjs +23 -23
  55. package/fesm2015/selection.mjs.map +1 -1
  56. package/fesm2015/table-scroll-container.mjs +7 -7
  57. package/fesm2020/cdk-experimental.mjs +1 -1
  58. package/fesm2020/cdk-experimental.mjs.map +1 -1
  59. package/fesm2020/column-resize.mjs +50 -50
  60. package/fesm2020/combobox.mjs +10 -10
  61. package/fesm2020/listbox.mjs +10 -10
  62. package/fesm2020/popover-edit.mjs +49 -49
  63. package/fesm2020/scrolling.mjs +7 -7
  64. package/fesm2020/selection.mjs +23 -23
  65. package/fesm2020/selection.mjs.map +1 -1
  66. package/fesm2020/table-scroll-container.mjs +7 -7
  67. package/listbox/listbox.d.ts +2 -2
  68. package/package.json +2 -18
  69. package/popover-edit/lens-directives.d.ts +3 -3
  70. package/popover-edit/table-directives.d.ts +5 -5
  71. package/scrolling/auto-size-virtual-scroll.d.ts +1 -1
  72. package/selection/row-selection.d.ts +1 -1
  73. package/selection/select-all.d.ts +1 -1
  74. package/selection/selection-column.d.ts +1 -1
  75. package/selection/selection-toggle.d.ts +1 -1
  76. package/selection/selection.d.ts +1 -1
  77. package/table-scroll-container/table-scroll-container.d.ts +1 -1
  78. package/dialog/dialog-config.d.ts +0 -111
  79. package/dialog/dialog-container.d.ts +0 -95
  80. package/dialog/dialog-injectors.d.ts +0 -24
  81. package/dialog/dialog-module.d.ts +0 -10
  82. package/dialog/dialog-ref.d.ts +0 -64
  83. package/dialog/dialog.d.ts +0 -103
  84. package/dialog/dialog_public_index.d.ts +0 -4
  85. package/dialog/index.d.ts +0 -8
  86. package/dialog/package.json +0 -9
  87. package/dialog/public-api.d.ts +0 -13
  88. package/esm2020/dialog/dialog-config.mjs +0 -54
  89. package/esm2020/dialog/dialog-container.mjs +0 -255
  90. package/esm2020/dialog/dialog-injectors.mjs +0 -26
  91. package/esm2020/dialog/dialog-module.mjs +0 -42
  92. package/esm2020/dialog/dialog-ref.mjs +0 -77
  93. package/esm2020/dialog/dialog.mjs +0 -285
  94. package/esm2020/dialog/dialog_public_index.mjs +0 -5
  95. package/esm2020/dialog/index.mjs +0 -9
  96. package/esm2020/dialog/public-api.mjs +0 -14
  97. package/esm2020/menu/context-menu-trigger.mjs +0 -227
  98. package/esm2020/menu/index.mjs +0 -9
  99. package/esm2020/menu/menu-aim.mjs +0 -204
  100. package/esm2020/menu/menu-bar.mjs +0 -159
  101. package/esm2020/menu/menu-base.mjs +0 -203
  102. package/esm2020/menu/menu-errors.mjs +0 -22
  103. package/esm2020/menu/menu-group.mjs +0 -30
  104. package/esm2020/menu/menu-interface.mjs +0 -11
  105. package/esm2020/menu/menu-item-checkbox.mjs +0 -48
  106. package/esm2020/menu/menu-item-radio.mjs +0 -114
  107. package/esm2020/menu/menu-item-selectable.mjs +0 -42
  108. package/esm2020/menu/menu-item.mjs +0 -289
  109. package/esm2020/menu/menu-module.mjs +0 -62
  110. package/esm2020/menu/menu-stack.mjs +0 -156
  111. package/esm2020/menu/menu-trigger-base.mjs +0 -114
  112. package/esm2020/menu/menu-trigger.mjs +0 -302
  113. package/esm2020/menu/menu.mjs +0 -168
  114. package/esm2020/menu/menu_public_index.mjs +0 -5
  115. package/esm2020/menu/pointer-focus-tracker.mjs +0 -51
  116. package/esm2020/menu/public-api.mjs +0 -24
  117. package/fesm2015/dialog.mjs +0 -736
  118. package/fesm2015/dialog.mjs.map +0 -1
  119. package/fesm2015/menu.mjs +0 -2131
  120. package/fesm2015/menu.mjs.map +0 -1
  121. package/fesm2020/dialog.mjs +0 -740
  122. package/fesm2020/dialog.mjs.map +0 -1
  123. package/fesm2020/menu.mjs +0 -2104
  124. package/fesm2020/menu.mjs.map +0 -1
  125. package/menu/context-menu-trigger.d.ts +0 -98
  126. package/menu/index.d.ts +0 -8
  127. package/menu/menu-aim.d.ts +0 -107
  128. package/menu/menu-bar.d.ts +0 -52
  129. package/menu/menu-base.d.ts +0 -104
  130. package/menu/menu-errors.d.ts +0 -17
  131. package/menu/menu-group.d.ts +0 -8
  132. package/menu/menu-interface.d.ts +0 -25
  133. package/menu/menu-item-checkbox.d.ts +0 -18
  134. package/menu/menu-item-radio.d.ts +0 -59
  135. package/menu/menu-item-selectable.d.ts +0 -21
  136. package/menu/menu-item.d.ts +0 -140
  137. package/menu/menu-module.d.ts +0 -17
  138. package/menu/menu-stack.d.ts +0 -122
  139. package/menu/menu-trigger-base.d.ts +0 -77
  140. package/menu/menu-trigger.d.ts +0 -104
  141. package/menu/menu.d.ts +0 -60
  142. package/menu/menu_public_index.d.ts +0 -4
  143. package/menu/package.json +0 -9
  144. package/menu/pointer-focus-tracker.d.ts +0 -47
  145. package/menu/public-api.d.ts +0 -23
@@ -1,740 +0,0 @@
1
- import * as i1 from '@angular/cdk/a11y';
2
- import { A11yModule } from '@angular/cdk/a11y';
3
- import * as i1$1 from '@angular/cdk/overlay';
4
- import { Overlay, OverlayConfig, OverlayRef, OverlayModule } from '@angular/cdk/overlay';
5
- import { _getFocusedElementPierceShadowDom } from '@angular/cdk/platform';
6
- import * as i3 from '@angular/cdk/portal';
7
- import { BasePortalOutlet, CdkPortalOutlet, ComponentPortal, TemplatePortal, PortalModule } from '@angular/cdk/portal';
8
- import { DOCUMENT } from '@angular/common';
9
- import * as i0 from '@angular/core';
10
- import { Component, ViewEncapsulation, ChangeDetectionStrategy, Optional, Inject, ViewChild, InjectionToken, Injector, TemplateRef, InjectFlags, Injectable, SkipSelf, NgModule } from '@angular/core';
11
- import { ESCAPE, hasModifierKey } from '@angular/cdk/keycodes';
12
- import { Subject, defer, of } from 'rxjs';
13
- import { Directionality } from '@angular/cdk/bidi';
14
- import { startWith } from 'rxjs/operators';
15
-
16
- /**
17
- * @license
18
- * Copyright Google LLC All Rights Reserved.
19
- *
20
- * Use of this source code is governed by an MIT-style license that can be
21
- * found in the LICENSE file at https://angular.io/license
22
- */
23
- /** Configuration for opening a modal dialog. */
24
- class DialogConfig {
25
- constructor() {
26
- /** The ARIA role of the dialog element. */
27
- this.role = 'dialog';
28
- /** Optional CSS class or classes applied to the overlay panel. */
29
- this.panelClass = '';
30
- /** Whether the dialog has a backdrop. */
31
- this.hasBackdrop = true;
32
- /** Optional CSS class or classes applied to the overlay backdrop. */
33
- this.backdropClass = '';
34
- /** Whether the dialog closes with the escape key or pointer events outside the panel element. */
35
- this.disableClose = false;
36
- /** Width of the dialog. */
37
- this.width = '';
38
- /** Height of the dialog. */
39
- this.height = '';
40
- /** Data being injected into the child component. */
41
- this.data = null;
42
- /** ID of the element that describes the dialog. */
43
- this.ariaDescribedBy = null;
44
- /** ID of the element that labels the dialog. */
45
- this.ariaLabelledBy = null;
46
- /** Dialog label applied via `aria-label` */
47
- this.ariaLabel = null;
48
- /** Whether this a modal dialog. Used to set the `aria-modal` attribute. */
49
- this.ariaModal = true;
50
- /**
51
- * Where the dialog should focus on open.
52
- * @breaking-change 14.0.0 Remove boolean option from autoFocus. Use string or
53
- * AutoFocusTarget instead.
54
- */
55
- this.autoFocus = 'first-tabbable';
56
- /**
57
- * Whether the dialog should restore focus to the
58
- * previously-focused element upon closing.
59
- */
60
- this.restoreFocus = true;
61
- /**
62
- * Whether the dialog should close when the user navigates backwards or forwards through browser
63
- * history. This does not apply to navigation via anchor element unless using URL-hash based
64
- * routing (`HashLocationStrategy` in the Angular router).
65
- */
66
- this.closeOnNavigation = true;
67
- }
68
- }
69
-
70
- /**
71
- * @license
72
- * Copyright Google LLC All Rights Reserved.
73
- *
74
- * Use of this source code is governed by an MIT-style license that can be
75
- * found in the LICENSE file at https://angular.io/license
76
- */
77
- function throwDialogContentAlreadyAttachedError() {
78
- throw Error('Attempting to attach dialog content after content is already attached');
79
- }
80
- /**
81
- * Internal component that wraps user-provided dialog content.
82
- * @docs-private
83
- */
84
- class CdkDialogContainer extends BasePortalOutlet {
85
- constructor(_elementRef, _focusTrapFactory, _document, _config, _interactivityChecker, _ngZone, _overlayRef, _focusMonitor) {
86
- super();
87
- this._elementRef = _elementRef;
88
- this._focusTrapFactory = _focusTrapFactory;
89
- this._config = _config;
90
- this._interactivityChecker = _interactivityChecker;
91
- this._ngZone = _ngZone;
92
- this._overlayRef = _overlayRef;
93
- this._focusMonitor = _focusMonitor;
94
- /** Element that was focused before the dialog was opened. Save this to restore upon close. */
95
- this._elementFocusedBeforeDialogWasOpened = null;
96
- /**
97
- * Type of interaction that led to the dialog being closed. This is used to determine
98
- * whether the focus style will be applied when returning focus to its original location
99
- * after the dialog is closed.
100
- */
101
- this._closeInteractionType = null;
102
- /**
103
- * Attaches a DOM portal to the dialog container.
104
- * @param portal Portal to be attached.
105
- * @deprecated To be turned into a method.
106
- * @breaking-change 10.0.0
107
- */
108
- this.attachDomPortal = (portal) => {
109
- if (this._portalOutlet.hasAttached() && (typeof ngDevMode === 'undefined' || ngDevMode)) {
110
- throwDialogContentAlreadyAttachedError();
111
- }
112
- return this._portalOutlet.attachDomPortal(portal);
113
- };
114
- this._ariaLabelledBy = this._config.ariaLabelledBy || null;
115
- this._document = _document;
116
- }
117
- ngAfterViewInit() {
118
- this._initializeFocusTrap();
119
- this._handleBackdropClicks();
120
- this._captureInitialFocus();
121
- }
122
- /**
123
- * Can be used by child classes to customize the initial focus
124
- * capturing behavior (e.g. if it's tied to an animation).
125
- */
126
- _captureInitialFocus() {
127
- this._trapFocus();
128
- }
129
- ngOnDestroy() {
130
- this._restoreFocus();
131
- }
132
- /**
133
- * Attach a ComponentPortal as content to this dialog container.
134
- * @param portal Portal to be attached as the dialog content.
135
- */
136
- attachComponentPortal(portal) {
137
- if (this._portalOutlet.hasAttached() && (typeof ngDevMode === 'undefined' || ngDevMode)) {
138
- throwDialogContentAlreadyAttachedError();
139
- }
140
- return this._portalOutlet.attachComponentPortal(portal);
141
- }
142
- /**
143
- * Attach a TemplatePortal as content to this dialog container.
144
- * @param portal Portal to be attached as the dialog content.
145
- */
146
- attachTemplatePortal(portal) {
147
- if (this._portalOutlet.hasAttached() && (typeof ngDevMode === 'undefined' || ngDevMode)) {
148
- throwDialogContentAlreadyAttachedError();
149
- }
150
- return this._portalOutlet.attachTemplatePortal(portal);
151
- }
152
- /**
153
- * Focuses the provided element. If the element is not focusable, it will add a tabIndex
154
- * attribute to forcefully focus it. The attribute is removed after focus is moved.
155
- * @param element The element to focus.
156
- */
157
- _forceFocus(element, options) {
158
- if (!this._interactivityChecker.isFocusable(element)) {
159
- element.tabIndex = -1;
160
- // The tabindex attribute should be removed to avoid navigating to that element again
161
- this._ngZone.runOutsideAngular(() => {
162
- const callback = () => {
163
- element.removeEventListener('blur', callback);
164
- element.removeEventListener('mousedown', callback);
165
- element.removeAttribute('tabindex');
166
- };
167
- element.addEventListener('blur', callback);
168
- element.addEventListener('mousedown', callback);
169
- });
170
- }
171
- element.focus(options);
172
- }
173
- /**
174
- * Focuses the first element that matches the given selector within the focus trap.
175
- * @param selector The CSS selector for the element to set focus to.
176
- */
177
- _focusByCssSelector(selector, options) {
178
- let elementToFocus = this._elementRef.nativeElement.querySelector(selector);
179
- if (elementToFocus) {
180
- this._forceFocus(elementToFocus, options);
181
- }
182
- }
183
- /**
184
- * Moves the focus inside the focus trap. When autoFocus is not set to 'dialog', if focus
185
- * cannot be moved then focus will go to the dialog container.
186
- */
187
- _trapFocus() {
188
- const element = this._elementRef.nativeElement;
189
- // If were to attempt to focus immediately, then the content of the dialog would not yet be
190
- // ready in instances where change detection has to run first. To deal with this, we simply
191
- // wait for the microtask queue to be empty when setting focus when autoFocus isn't set to
192
- // dialog. If the element inside the dialog can't be focused, then the container is focused
193
- // so the user can't tab into other elements behind it.
194
- switch (this._config.autoFocus) {
195
- case false:
196
- case 'dialog':
197
- // Ensure that focus is on the dialog container. It's possible that a different
198
- // component tried to move focus while the open animation was running. See:
199
- // https://github.com/angular/components/issues/16215. Note that we only want to do this
200
- // if the focus isn't inside the dialog already, because it's possible that the consumer
201
- // turned off `autoFocus` in order to move focus themselves.
202
- if (!this._containsFocus()) {
203
- element.focus();
204
- }
205
- break;
206
- case true:
207
- case 'first-tabbable':
208
- this._focusTrap.focusInitialElementWhenReady().then(focusedSuccessfully => {
209
- // If we weren't able to find a focusable element in the dialog, then focus the dialog
210
- // container instead.
211
- if (!focusedSuccessfully) {
212
- this._focusDialogContainer();
213
- }
214
- });
215
- break;
216
- case 'first-heading':
217
- this._focusByCssSelector('h1, h2, h3, h4, h5, h6, [role="heading"]');
218
- break;
219
- default:
220
- this._focusByCssSelector(this._config.autoFocus);
221
- break;
222
- }
223
- }
224
- /** Restores focus to the element that was focused before the dialog opened. */
225
- _restoreFocus() {
226
- const previousElement = this._elementFocusedBeforeDialogWasOpened;
227
- // We need the extra check, because IE can set the `activeElement` to null in some cases.
228
- if (this._config.restoreFocus &&
229
- previousElement &&
230
- typeof previousElement.focus === 'function') {
231
- const activeElement = _getFocusedElementPierceShadowDom();
232
- const element = this._elementRef.nativeElement;
233
- // Make sure that focus is still inside the dialog or is on the body (usually because a
234
- // non-focusable element like the backdrop was clicked) before moving it. It's possible that
235
- // the consumer moved it themselves before the animation was done, in which case we shouldn't
236
- // do anything.
237
- if (!activeElement ||
238
- activeElement === this._document.body ||
239
- activeElement === element ||
240
- element.contains(activeElement)) {
241
- if (this._focusMonitor) {
242
- this._focusMonitor.focusVia(previousElement, this._closeInteractionType);
243
- this._closeInteractionType = null;
244
- }
245
- else {
246
- previousElement.focus();
247
- }
248
- }
249
- }
250
- if (this._focusTrap) {
251
- this._focusTrap.destroy();
252
- }
253
- }
254
- /** Focuses the dialog container. */
255
- _focusDialogContainer() {
256
- // Note that there is no focus method when rendering on the server.
257
- if (this._elementRef.nativeElement.focus) {
258
- this._elementRef.nativeElement.focus();
259
- }
260
- }
261
- /** Returns whether focus is inside the dialog. */
262
- _containsFocus() {
263
- const element = this._elementRef.nativeElement;
264
- const activeElement = _getFocusedElementPierceShadowDom();
265
- return element === activeElement || element.contains(activeElement);
266
- }
267
- /** Sets up the focus trap. */
268
- _initializeFocusTrap() {
269
- this._focusTrap = this._focusTrapFactory.create(this._elementRef.nativeElement);
270
- // Save the previously focused element. This element will be re-focused
271
- // when the dialog closes.
272
- if (this._document) {
273
- this._elementFocusedBeforeDialogWasOpened = _getFocusedElementPierceShadowDom();
274
- }
275
- }
276
- /** Sets up the listener that handles clicks on the dialog backdrop. */
277
- _handleBackdropClicks() {
278
- // Clicking on the backdrop will move focus out of dialog.
279
- // Recapture it if closing via the backdrop is disabled.
280
- this._overlayRef.backdropClick().subscribe(() => {
281
- if (this._config.disableClose && !this._containsFocus()) {
282
- this._trapFocus();
283
- }
284
- });
285
- }
286
- }
287
- CdkDialogContainer.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.13", ngImport: i0, type: CdkDialogContainer, deps: [{ token: i0.ElementRef }, { token: i1.FocusTrapFactory }, { token: DOCUMENT, optional: true }, { token: DialogConfig }, { token: i1.InteractivityChecker }, { token: i0.NgZone }, { token: i1$1.OverlayRef }, { token: i1.FocusMonitor }], target: i0.ɵɵFactoryTarget.Component });
288
- CdkDialogContainer.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "14.0.0-next.13", type: CdkDialogContainer, selector: "cdk-dialog-container", host: { attributes: { "tabindex": "-1" }, properties: { "attr.id": "_config.id || null", "attr.role": "_config.role", "attr.aria-modal": "_config.ariaModal", "attr.aria-labelledby": "_config.ariaLabel ? null : _ariaLabelledBy", "attr.aria-label": "_config.ariaLabel", "attr.aria-describedby": "_config.ariaDescribedBy || null" }, classAttribute: "cdk-dialog-container" }, viewQueries: [{ propertyName: "_portalOutlet", first: true, predicate: CdkPortalOutlet, descendants: true, static: true }], usesInheritance: true, ngImport: i0, template: "<ng-template cdkPortalOutlet></ng-template>\n", directives: [{ type: i3.CdkPortalOutlet, selector: "[cdkPortalOutlet]", inputs: ["cdkPortalOutlet"], outputs: ["attached"], exportAs: ["cdkPortalOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.Default, encapsulation: i0.ViewEncapsulation.None });
289
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.13", ngImport: i0, type: CdkDialogContainer, decorators: [{
290
- type: Component,
291
- args: [{ selector: 'cdk-dialog-container', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.Default, host: {
292
- 'class': 'cdk-dialog-container',
293
- 'tabindex': '-1',
294
- '[attr.id]': '_config.id || null',
295
- '[attr.role]': '_config.role',
296
- '[attr.aria-modal]': '_config.ariaModal',
297
- '[attr.aria-labelledby]': '_config.ariaLabel ? null : _ariaLabelledBy',
298
- '[attr.aria-label]': '_config.ariaLabel',
299
- '[attr.aria-describedby]': '_config.ariaDescribedBy || null',
300
- }, template: "<ng-template cdkPortalOutlet></ng-template>\n" }]
301
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i1.FocusTrapFactory }, { type: undefined, decorators: [{
302
- type: Optional
303
- }, {
304
- type: Inject,
305
- args: [DOCUMENT]
306
- }] }, { type: undefined, decorators: [{
307
- type: Inject,
308
- args: [DialogConfig]
309
- }] }, { type: i1.InteractivityChecker }, { type: i0.NgZone }, { type: i1$1.OverlayRef }, { type: i1.FocusMonitor }]; }, propDecorators: { _portalOutlet: [{
310
- type: ViewChild,
311
- args: [CdkPortalOutlet, { static: true }]
312
- }] } });
313
-
314
- /**
315
- * @license
316
- * Copyright Google LLC All Rights Reserved.
317
- *
318
- * Use of this source code is governed by an MIT-style license that can be
319
- * found in the LICENSE file at https://angular.io/license
320
- */
321
- /**
322
- * Reference to a dialog opened via the Dialog service.
323
- */
324
- class DialogRef {
325
- constructor(overlayRef, config) {
326
- this.overlayRef = overlayRef;
327
- this.config = config;
328
- /** Emits when the dialog has been closed. */
329
- this.closed = new Subject();
330
- this.disableClose = config.disableClose;
331
- this.backdropClick = overlayRef.backdropClick();
332
- this.keydownEvents = overlayRef.keydownEvents();
333
- this.outsidePointerEvents = overlayRef.outsidePointerEvents();
334
- this.id = config.id; // By the time the dialog is created we are guaranteed to have an ID.
335
- this.keydownEvents.subscribe(event => {
336
- if (event.keyCode === ESCAPE && !this.disableClose && !hasModifierKey(event)) {
337
- event.preventDefault();
338
- this.close(undefined, { focusOrigin: 'keyboard' });
339
- }
340
- });
341
- this.backdropClick.subscribe(() => {
342
- if (!this.disableClose) {
343
- this.close(undefined, { focusOrigin: 'mouse' });
344
- }
345
- });
346
- }
347
- /**
348
- * Close the dialog.
349
- * @param result Optional result to return to the dialog opener.
350
- * @param options Additional options to customize the closing behavior.
351
- */
352
- close(result, options) {
353
- if (this.containerInstance) {
354
- const closedSubject = this.closed;
355
- this.containerInstance._closeInteractionType = options?.focusOrigin || 'program';
356
- this.overlayRef.dispose();
357
- closedSubject.next(result);
358
- closedSubject.complete();
359
- this.componentInstance = this.containerInstance = null;
360
- }
361
- }
362
- /** Updates the dialog's position. */
363
- updatePosition() {
364
- this.overlayRef.updatePosition();
365
- return this;
366
- }
367
- /**
368
- * Updates the dialog's width and height.
369
- * @param width New width of the dialog.
370
- * @param height New height of the dialog.
371
- */
372
- updateSize(width = '', height = '') {
373
- this.overlayRef.updateSize({ width, height });
374
- this.overlayRef.updatePosition();
375
- return this;
376
- }
377
- /** Add a CSS class or an array of classes to the overlay pane. */
378
- addPanelClass(classes) {
379
- this.overlayRef.addPanelClass(classes);
380
- return this;
381
- }
382
- /** Remove a CSS class or an array of classes from the overlay pane. */
383
- removePanelClass(classes) {
384
- this.overlayRef.removePanelClass(classes);
385
- return this;
386
- }
387
- }
388
-
389
- /**
390
- * @license
391
- * Copyright Google LLC All Rights Reserved.
392
- *
393
- * Use of this source code is governed by an MIT-style license that can be
394
- * found in the LICENSE file at https://angular.io/license
395
- */
396
- /** Injection token for the Dialog's ScrollStrategy. */
397
- const DIALOG_SCROLL_STRATEGY = new InjectionToken('DialogScrollStrategy');
398
- /** Injection token for the Dialog's Data. */
399
- const DIALOG_DATA = new InjectionToken('DialogData');
400
- /** Injection token that can be used to provide default options for the dialog module. */
401
- const DEFAULT_DIALOG_CONFIG = new InjectionToken('DefaultDialogConfig');
402
- /** @docs-private */
403
- function DIALOG_SCROLL_STRATEGY_PROVIDER_FACTORY(overlay) {
404
- return () => overlay.scrollStrategies.block();
405
- }
406
- /** @docs-private */
407
- const DIALOG_SCROLL_STRATEGY_PROVIDER = {
408
- provide: DIALOG_SCROLL_STRATEGY,
409
- deps: [Overlay],
410
- useFactory: DIALOG_SCROLL_STRATEGY_PROVIDER_FACTORY,
411
- };
412
-
413
- /**
414
- * @license
415
- * Copyright Google LLC All Rights Reserved.
416
- *
417
- * Use of this source code is governed by an MIT-style license that can be
418
- * found in the LICENSE file at https://angular.io/license
419
- */
420
- /** Unique id for the created dialog. */
421
- let uniqueId = 0;
422
- class Dialog {
423
- constructor(_overlay, _injector, _defaultOptions, _parentDialog, _overlayContainer, scrollStrategy) {
424
- this._overlay = _overlay;
425
- this._injector = _injector;
426
- this._defaultOptions = _defaultOptions;
427
- this._parentDialog = _parentDialog;
428
- this._overlayContainer = _overlayContainer;
429
- this._openDialogsAtThisLevel = [];
430
- this._afterAllClosedAtThisLevel = new Subject();
431
- this._afterOpenedAtThisLevel = new Subject();
432
- this._ariaHiddenElements = new Map();
433
- /**
434
- * Stream that emits when all open dialog have finished closing.
435
- * Will emit on subscribe if there are no open dialogs to begin with.
436
- */
437
- this.afterAllClosed = defer(() => this.openDialogs.length
438
- ? this._getAfterAllClosed()
439
- : this._getAfterAllClosed().pipe(startWith(undefined)));
440
- this._scrollStrategy = scrollStrategy;
441
- }
442
- /** Keeps track of the currently-open dialogs. */
443
- get openDialogs() {
444
- return this._parentDialog ? this._parentDialog.openDialogs : this._openDialogsAtThisLevel;
445
- }
446
- /** Stream that emits when a dialog has been opened. */
447
- get afterOpened() {
448
- return this._parentDialog ? this._parentDialog.afterOpened : this._afterOpenedAtThisLevel;
449
- }
450
- open(componentOrTemplateRef, config) {
451
- const defaults = (this._defaultOptions || new DialogConfig());
452
- config = { ...defaults, ...config };
453
- config.id = config.id || `cdk-dialog-${uniqueId++}`;
454
- if (config.id &&
455
- this.getDialogById(config.id) &&
456
- (typeof ngDevMode === 'undefined' || ngDevMode)) {
457
- throw Error(`Dialog with id "${config.id}" exists already. The dialog id must be unique.`);
458
- }
459
- const overlayConfig = this._getOverlayConfig(config);
460
- const overlayRef = this._overlay.create(overlayConfig);
461
- const dialogRef = new DialogRef(overlayRef, config);
462
- const dialogContainer = this._attachContainer(overlayRef, dialogRef, config);
463
- dialogRef.containerInstance = dialogContainer;
464
- this._attachDialogContent(componentOrTemplateRef, dialogRef, dialogContainer, config);
465
- // If this is the first dialog that we're opening, hide all the non-overlay content.
466
- if (!this.openDialogs.length) {
467
- this._hideNonDialogContentFromAssistiveTechnology();
468
- }
469
- this.openDialogs.push(dialogRef);
470
- dialogRef.closed.subscribe(() => this._removeOpenDialog(dialogRef));
471
- this.afterOpened.next(dialogRef);
472
- return dialogRef;
473
- }
474
- /**
475
- * Closes all of the currently-open dialogs.
476
- */
477
- closeAll() {
478
- this._closeDialogs(this.openDialogs);
479
- }
480
- /**
481
- * Finds an open dialog by its id.
482
- * @param id ID to use when looking up the dialog.
483
- */
484
- getDialogById(id) {
485
- return this.openDialogs.find(dialog => dialog.id === id);
486
- }
487
- ngOnDestroy() {
488
- // Only close the dialogs at this level on destroy
489
- // since the parent service may still be active.
490
- this._closeDialogs(this._openDialogsAtThisLevel);
491
- this._afterAllClosedAtThisLevel.complete();
492
- this._afterOpenedAtThisLevel.complete();
493
- }
494
- /**
495
- * Creates an overlay config from a dialog config.
496
- * @param config The dialog configuration.
497
- * @returns The overlay configuration.
498
- */
499
- _getOverlayConfig(config) {
500
- const state = new OverlayConfig({
501
- positionStrategy: config.positionStrategy ||
502
- this._overlay.position().global().centerHorizontally().centerVertically(),
503
- scrollStrategy: config.scrollStrategy || this._scrollStrategy(),
504
- panelClass: config.panelClass,
505
- hasBackdrop: config.hasBackdrop,
506
- direction: config.direction,
507
- minWidth: config.minWidth,
508
- minHeight: config.minHeight,
509
- maxWidth: config.maxWidth,
510
- maxHeight: config.maxHeight,
511
- width: config.width,
512
- height: config.height,
513
- disposeOnNavigation: config.closeOnNavigation,
514
- });
515
- if (config.backdropClass) {
516
- state.backdropClass = config.backdropClass;
517
- }
518
- return state;
519
- }
520
- /**
521
- * Attaches a dialog container to a dialog's already-created overlay.
522
- * @param overlay Reference to the dialog's underlying overlay.
523
- * @param config The dialog configuration.
524
- * @returns A promise resolving to a ComponentRef for the attached container.
525
- */
526
- _attachContainer(overlay, dialogRef, config) {
527
- const userInjector = config.injector ?? config.viewContainerRef?.injector;
528
- const providers = [
529
- { provide: DialogConfig, useValue: config },
530
- { provide: DialogRef, useValue: dialogRef },
531
- { provide: OverlayRef, useValue: overlay },
532
- ];
533
- let containerType;
534
- if (config.container) {
535
- if (typeof config.container === 'function') {
536
- containerType = config.container;
537
- }
538
- else {
539
- containerType = config.container.type;
540
- providers.push(...config.container.providers(config));
541
- }
542
- }
543
- else {
544
- containerType = CdkDialogContainer;
545
- }
546
- const containerPortal = new ComponentPortal(containerType, config.viewContainerRef, Injector.create({ parent: userInjector || this._injector, providers }), config.componentFactoryResolver);
547
- const containerRef = overlay.attach(containerPortal);
548
- return containerRef.instance;
549
- }
550
- /**
551
- * Attaches the user-provided component to the already-created dialog container.
552
- * @param componentOrTemplateRef The type of component being loaded into the dialog,
553
- * or a TemplateRef to instantiate as the content.
554
- * @param dialogRef Reference to the dialog being opened.
555
- * @param dialogContainer Component that is going to wrap the dialog content.
556
- * @param config Configuration used to open the dialog.
557
- */
558
- _attachDialogContent(componentOrTemplateRef, dialogRef, dialogContainer, config) {
559
- const injector = this._createInjector(config, dialogRef, dialogContainer);
560
- if (componentOrTemplateRef instanceof TemplateRef) {
561
- let context = { $implicit: config.data, dialogRef };
562
- if (config.templateContext) {
563
- context = {
564
- ...context,
565
- ...(typeof config.templateContext === 'function'
566
- ? config.templateContext()
567
- : config.templateContext),
568
- };
569
- }
570
- dialogContainer.attachTemplatePortal(new TemplatePortal(componentOrTemplateRef, null, context, injector));
571
- }
572
- else {
573
- const contentRef = dialogContainer.attachComponentPortal(new ComponentPortal(componentOrTemplateRef, config.viewContainerRef, injector, config.componentFactoryResolver));
574
- dialogRef.componentInstance = contentRef.instance;
575
- }
576
- }
577
- /**
578
- * Creates a custom injector to be used inside the dialog. This allows a component loaded inside
579
- * of a dialog to close itself and, optionally, to return a value.
580
- * @param config Config object that is used to construct the dialog.
581
- * @param dialogRef Reference to the dialog being opened.
582
- * @param dialogContainer Component that is going to wrap the dialog content.
583
- * @returns The custom injector that can be used inside the dialog.
584
- */
585
- _createInjector(config, dialogRef, dialogContainer) {
586
- const userInjector = config && config.viewContainerRef && config.viewContainerRef.injector;
587
- const providers = [
588
- { provide: DIALOG_DATA, useValue: config.data },
589
- { provide: DialogRef, useValue: dialogRef },
590
- ];
591
- if (config.providers) {
592
- if (typeof config.providers === 'function') {
593
- providers.push(...config.providers(dialogRef, config, dialogContainer));
594
- }
595
- else {
596
- providers.push(...config.providers);
597
- }
598
- }
599
- if (config.direction &&
600
- (!userInjector ||
601
- !userInjector.get(Directionality, null, InjectFlags.Optional))) {
602
- providers.push({
603
- provide: Directionality,
604
- useValue: { value: config.direction, change: of() },
605
- });
606
- }
607
- return Injector.create({ parent: userInjector || this._injector, providers });
608
- }
609
- /**
610
- * Removes a dialog from the array of open dialogs.
611
- * @param dialogRef Dialog to be removed.
612
- */
613
- _removeOpenDialog(dialogRef) {
614
- const index = this.openDialogs.indexOf(dialogRef);
615
- if (index > -1) {
616
- this.openDialogs.splice(index, 1);
617
- // If all the dialogs were closed, remove/restore the `aria-hidden`
618
- // to a the siblings and emit to the `afterAllClosed` stream.
619
- if (!this.openDialogs.length) {
620
- this._ariaHiddenElements.forEach((previousValue, element) => {
621
- if (previousValue) {
622
- element.setAttribute('aria-hidden', previousValue);
623
- }
624
- else {
625
- element.removeAttribute('aria-hidden');
626
- }
627
- });
628
- this._ariaHiddenElements.clear();
629
- this._getAfterAllClosed().next();
630
- }
631
- }
632
- }
633
- /** Hides all of the content that isn't an overlay from assistive technology. */
634
- _hideNonDialogContentFromAssistiveTechnology() {
635
- const overlayContainer = this._overlayContainer.getContainerElement();
636
- // Ensure that the overlay container is attached to the DOM.
637
- if (overlayContainer.parentElement) {
638
- const siblings = overlayContainer.parentElement.children;
639
- for (let i = siblings.length - 1; i > -1; i--) {
640
- const sibling = siblings[i];
641
- if (sibling !== overlayContainer &&
642
- sibling.nodeName !== 'SCRIPT' &&
643
- sibling.nodeName !== 'STYLE' &&
644
- !sibling.hasAttribute('aria-live')) {
645
- this._ariaHiddenElements.set(sibling, sibling.getAttribute('aria-hidden'));
646
- sibling.setAttribute('aria-hidden', 'true');
647
- }
648
- }
649
- }
650
- }
651
- /** Closes all of the dialogs in an array. */
652
- _closeDialogs(dialogs) {
653
- let i = dialogs.length;
654
- while (i--) {
655
- // The `_openDialogs` property isn't updated after close until the rxjs subscription
656
- // runs on the next microtask, in addition to modifying the array as we're going
657
- // through it. We loop through all of them and call close without assuming that
658
- // they'll be removed from the list instantaneously.
659
- dialogs[i].close();
660
- }
661
- }
662
- _getAfterAllClosed() {
663
- const parent = this._parentDialog;
664
- return parent ? parent._getAfterAllClosed() : this._afterAllClosedAtThisLevel;
665
- }
666
- }
667
- Dialog.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.13", ngImport: i0, type: Dialog, deps: [{ token: i1$1.Overlay }, { token: i0.Injector }, { token: DEFAULT_DIALOG_CONFIG, optional: true }, { token: Dialog, optional: true, skipSelf: true }, { token: i1$1.OverlayContainer }, { token: DIALOG_SCROLL_STRATEGY }], target: i0.ɵɵFactoryTarget.Injectable });
668
- Dialog.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.0-next.13", ngImport: i0, type: Dialog });
669
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.13", ngImport: i0, type: Dialog, decorators: [{
670
- type: Injectable
671
- }], ctorParameters: function () { return [{ type: i1$1.Overlay }, { type: i0.Injector }, { type: DialogConfig, decorators: [{
672
- type: Optional
673
- }, {
674
- type: Inject,
675
- args: [DEFAULT_DIALOG_CONFIG]
676
- }] }, { type: Dialog, decorators: [{
677
- type: Optional
678
- }, {
679
- type: SkipSelf
680
- }] }, { type: i1$1.OverlayContainer }, { type: undefined, decorators: [{
681
- type: Inject,
682
- args: [DIALOG_SCROLL_STRATEGY]
683
- }] }]; } });
684
-
685
- /**
686
- * @license
687
- * Copyright Google LLC All Rights Reserved.
688
- *
689
- * Use of this source code is governed by an MIT-style license that can be
690
- * found in the LICENSE file at https://angular.io/license
691
- */
692
- class DialogModule {
693
- }
694
- DialogModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.13", ngImport: i0, type: DialogModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
695
- DialogModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "14.0.0-next.13", ngImport: i0, type: DialogModule, declarations: [CdkDialogContainer], imports: [OverlayModule, PortalModule, A11yModule], exports: [
696
- // Re-export the PortalModule so that people extending the `CdkDialogContainer`
697
- // don't have to remember to import it or be faced with an unhelpful error.
698
- PortalModule,
699
- CdkDialogContainer] });
700
- DialogModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.0.0-next.13", ngImport: i0, type: DialogModule, providers: [Dialog, DIALOG_SCROLL_STRATEGY_PROVIDER], imports: [[OverlayModule, PortalModule, A11yModule],
701
- // Re-export the PortalModule so that people extending the `CdkDialogContainer`
702
- // don't have to remember to import it or be faced with an unhelpful error.
703
- PortalModule] });
704
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.13", ngImport: i0, type: DialogModule, decorators: [{
705
- type: NgModule,
706
- args: [{
707
- imports: [OverlayModule, PortalModule, A11yModule],
708
- exports: [
709
- // Re-export the PortalModule so that people extending the `CdkDialogContainer`
710
- // don't have to remember to import it or be faced with an unhelpful error.
711
- PortalModule,
712
- CdkDialogContainer,
713
- ],
714
- declarations: [CdkDialogContainer],
715
- providers: [Dialog, DIALOG_SCROLL_STRATEGY_PROVIDER],
716
- }]
717
- }] });
718
-
719
- /**
720
- * @license
721
- * Copyright Google LLC All Rights Reserved.
722
- *
723
- * Use of this source code is governed by an MIT-style license that can be
724
- * found in the LICENSE file at https://angular.io/license
725
- */
726
-
727
- /**
728
- * @license
729
- * Copyright Google LLC All Rights Reserved.
730
- *
731
- * Use of this source code is governed by an MIT-style license that can be
732
- * found in the LICENSE file at https://angular.io/license
733
- */
734
-
735
- /**
736
- * Generated bundle index. Do not edit.
737
- */
738
-
739
- export { CdkDialogContainer, DEFAULT_DIALOG_CONFIG, DIALOG_DATA, DIALOG_SCROLL_STRATEGY, DIALOG_SCROLL_STRATEGY_PROVIDER, DIALOG_SCROLL_STRATEGY_PROVIDER_FACTORY, Dialog, DialogConfig, DialogModule, DialogRef, throwDialogContentAlreadyAttachedError };
740
- //# sourceMappingURL=dialog.mjs.map