1import { 2 BasePortalOutlet, 3 CdkPortalOutlet, 4 ComponentPortal, 5 Overlay, 6 OverlayConfig, 7 OverlayContainer, 8 OverlayModule, 9 OverlayRef, 10 PortalModule, 11 TemplatePortal 12} from "./chunk-QSUWJHQF.js"; 13import { 14 A11yModule, 15 Directionality, 16 ESCAPE, 17 FocusMonitor, 18 FocusTrapFactory, 19 InteractivityChecker, 20 Platform, 21 _getFocusedElementPierceShadowDom, 22 hasModifierKey 23} from "./chunk-HY5K3LOQ.js"; 24import { 25 ChangeDetectionStrategy, 26 ChangeDetectorRef, 27 Component, 28 DOCUMENT, 29 ElementRef, 30 Inject, 31 Injectable, 32 InjectionToken, 33 Injector, 34 NgModule, 35 NgZone, 36 Optional, 37 SkipSelf, 38 Subject, 39 TemplateRef, 40 ViewChild, 41 ViewEncapsulation$1, 42 __spreadValues, 43 afterNextRender, 44 defer, 45 inject, 46 of, 47 setClassMetadata, 48 startWith, 49 ɵɵInheritDefinitionFeature, 50 ɵɵStandaloneFeature, 51 ɵɵattribute, 52 ɵɵdefineComponent, 53 ɵɵdefineInjectable, 54 ɵɵdefineInjector, 55 ɵɵdefineNgModule, 56 ɵɵdirectiveInject, 57 ɵɵinject, 58 ɵɵloadQuery, 59 ɵɵqueryRefresh, 60 ɵɵtemplate, 61 ɵɵviewQuery 62} from "./chunk-3FLWNURB.js"; 63 64// node_modules/@angular/cdk/fesm2022/dialog.mjs 65function CdkDialogContainer_ng_template_0_Template(rf, ctx) { 66} 67var DialogConfig = class { 68 constructor() { 69 this.role = "dialog"; 70 this.panelClass = ""; 71 this.hasBackdrop = true; 72 this.backdropClass = ""; 73 this.disableClose = false; 74 this.width = ""; 75 this.height = ""; 76 this.data = null; 77 this.ariaDescribedBy = null; 78 this.ariaLabelledBy = null; 79 this.ariaLabel = null; 80 this.ariaModal = true; 81 this.autoFocus = "first-tabbable"; 82 this.restoreFocus = true; 83 this.closeOnNavigation = true; 84 this.closeOnDestroy = true; 85 this.closeOnOverlayDetachments = true; 86 } 87}; 88function throwDialogContentAlreadyAttachedError() { 89 throw Error("Attempting to attach dialog content after content is already attached"); 90} 91var CdkDialogContainer = class _CdkDialogContainer extends BasePortalOutlet { 92 constructor(_elementRef, _focusTrapFactory, _document, _config, _interactivityChecker, _ngZone, _overlayRef, _focusMonitor) { 93 super(); 94 this._elementRef = _elementRef; 95 this._focusTrapFactory = _focusTrapFactory; 96 this._config = _config; 97 this._interactivityChecker = _interactivityChecker; 98 this._ngZone = _ngZone; 99 this._overlayRef = _overlayRef; 100 this._focusMonitor = _focusMonitor; 101 this._platform = inject(Platform); 102 this._focusTrap = null; 103 this._elementFocusedBeforeDialogWasOpened = null; 104 this._closeInteractionType = null; 105 this._ariaLabelledByQueue = []; 106 this._changeDetectorRef = inject(ChangeDetectorRef); 107 this._injector = inject(Injector); 108 this._isDestroyed = false; 109 this.attachDomPortal = (portal) => { 110 if (this._portalOutlet.hasAttached() && (typeof ngDevMode === "undefined" || ngDevMode)) { 111 throwDialogContentAlreadyAttachedError(); 112 } 113 const result = this._portalOutlet.attachDomPortal(portal); 114 this._contentAttached(); 115 return result; 116 }; 117 this._document = _document; 118 if (this._config.ariaLabelledBy) { 119 this._ariaLabelledByQueue.push(this._config.ariaLabelledBy); 120 } 121 } 122 _addAriaLabelledBy(id) { 123 this._ariaLabelledByQueue.push(id); 124 this._changeDetectorRef.markForCheck(); 125 } 126 _removeAriaLabelledBy(id) { 127 const index = this._ariaLabelledByQueue.indexOf(id); 128 if (index > -1) { 129 this._ariaLabelledByQueue.splice(index, 1); 130 this._changeDetectorRef.markForCheck(); 131 } 132 } 133 _contentAttached() { 134 this._initializeFocusTrap(); 135 this._handleBackdropClicks(); 136 this._captureInitialFocus(); 137 } 138 /** 139 * Can be used by child classes to customize the initial focus 140 * capturing behavior (e.g. if it's tied to an animation). 141 */ 142 _captureInitialFocus() { 143 this._trapFocus(); 144 } 145 ngOnDestroy() { 146 this._isDestroyed = true; 147 this._restoreFocus(); 148 } 149 /** 150 * Attach a ComponentPortal as content to this dialog container. 151 * @param portal Portal to be attached as the dialog content. 152 */ 153 attachComponentPortal(portal) { 154 if (this._portalOutlet.hasAttached() && (typeof ngDevMode === "undefined" || ngDevMode)) { 155 throwDialogContentAlreadyAttachedError(); 156 } 157 const result = this._portalOutlet.attachComponentPortal(portal); 158 this._contentAttached(); 159 return result; 160 } 161 /** 162 * Attach a TemplatePortal as content to this dialog container. 163 * @param portal Portal to be attached as the dialog content. 164 */ 165 attachTemplatePortal(portal) { 166 if (this._portalOutlet.hasAttached() && (typeof ngDevMode === "undefined" || ngDevMode)) { 167 throwDialogContentAlreadyAttachedError(); 168 } 169 const result = this._portalOutlet.attachTemplatePortal(portal); 170 this._contentAttached(); 171 return result; 172 } 173 // TODO(crisbeto): this shouldn't be exposed, but there are internal references to it. 174 /** Captures focus if it isn't already inside the dialog. */ 175 _recaptureFocus() { 176 if (!this._containsFocus()) { 177 this._trapFocus(); 178 } 179 } 180 /** 181 * Focuses the provided element. If the element is not focusable, it will add a tabIndex 182 * attribute to forcefully focus it. The attribute is removed after focus is moved. 183 * @param element The element to focus. 184 */ 185 _forceFocus(element, options) { 186 if (!this._interactivityChecker.isFocusable(element)) { 187 element.tabIndex = -1; 188 this._ngZone.runOutsideAngular(() => { 189 const callback = () => { 190 element.removeEventListener("blur", callback); 191 element.removeEventListener("mousedown", callback); 192 element.removeAttribute("tabindex"); 193 }; 194 element.addEventListener("blur", callback); 195 element.addEventListener("mousedown", callback); 196 }); 197 } 198 element.focus(options); 199 } 200 /** 201 * Focuses the first element that matches the given selector within the focus trap. 202 * @param selector The CSS selector for the element to set focus to. 203 */ 204 _focusByCssSelector(selector, options) { 205 let elementToFocus = this._elementRef.nativeElement.querySelector(selector); 206 if (elementToFocus) { 207 this._forceFocus(elementToFocus, options); 208 } 209 } 210 /** 211 * Moves the focus inside the focus trap. When autoFocus is not set to 'dialog', if focus 212 * cannot be moved then focus will go to the dialog container. 213 */ 214 _trapFocus() { 215 if (this._isDestroyed) { 216 return; 217 } 218 afterNextRender(() => { 219 const element = this._elementRef.nativeElement; 220 switch (this._config.autoFocus) { 221 case false: 222 case "dialog": 223 if (!this._containsFocus()) { 224 element.focus(); 225 } 226 break; 227 case true: 228 case "first-tabbable": 229 const focusedSuccessfully = this._focusTrap?.focusInitialElement(); 230 if (!focusedSuccessfully) { 231 this._focusDialogContainer(); 232 } 233 break; 234 case "first-heading": 235 this._focusByCssSelector('h1, h2, h3, h4, h5, h6, [role="heading"]'); 236 break; 237 default: 238 this._focusByCssSelector(this._config.autoFocus); 239 break; 240 } 241 }, {
242 injector: this._injector 243 }); 244 } 245 /** Restores focus to the element that was focused before the dialog opened. */ 246 _restoreFocus() { 247 const focusConfig = this._config.restoreFocus; 248 let focusTargetElement = null; 249 if (typeof focusConfig === "string") { 250 focusTargetElement = this._document.querySelector(focusConfig); 251 } else if (typeof focusConfig === "boolean") { 252 focusTargetElement = focusConfig ? this._elementFocusedBeforeDialogWasOpened : null; 253 } else if (focusConfig) { 254 focusTargetElement = focusConfig; 255 } 256 if (this._config.restoreFocus && focusTargetElement && typeof focusTargetElement.focus === "function") { 257 const activeElement = _getFocusedElementPierceShadowDom(); 258 const element = this._elementRef.nativeElement; 259 if (!activeElement || activeElement === this._document.body || activeElement === element || element.contains(activeElement)) { 260 if (this._focusMonitor) { 261 this._focusMonitor.focusVia(focusTargetElement, this._closeInteractionType); 262 this._closeInteractionType = null; 263 } else { 264 focusTargetElement.focus(); 265 } 266 } 267 } 268 if (this._focusTrap) { 269 this._focusTrap.destroy(); 270 } 271 } 272 /** Focuses the dialog container. */ 273 _focusDialogContainer() { 274 if (this._elementRef.nativeElement.focus) { 275 this._elementRef.nativeElement.focus(); 276 } 277 } 278 /** Returns whether focus is inside the dialog. */ 279 _containsFocus() { 280 const element = this._elementRef.nativeElement; 281 const activeElement = _getFocusedElementPierceShadowDom(); 282 return element === activeElement || element.contains(activeElement); 283 } 284 /** Sets up the focus trap. */ 285 _initializeFocusTrap() { 286 if (this._platform.isBrowser) { 287 this._focusTrap = this._focusTrapFactory.create(this._elementRef.nativeElement); 288 if (this._document) { 289 this._elementFocusedBeforeDialogWasOpened = _getFocusedElementPierceShadowDom(); 290 } 291 } 292 } 293 /** Sets up the listener that handles clicks on the dialog backdrop. */ 294 _handleBackdropClicks() { 295 this._overlayRef.backdropClick().subscribe(() => { 296 if (this._config.disableClose) { 297 this._recaptureFocus(); 298 } 299 }); 300 } 301 static { 302 this.\u0275fac = function CdkDialogContainer_Factory(__ngFactoryType__) { 303 return new (__ngFactoryType__ || _CdkDialogContainer)(\u0275\u0275directiveInject(ElementRef), \u0275\u0275directiveInject(FocusTrapFactory), \u0275\u0275directiveInject(DOCUMENT, 8), \u0275\u0275directiveInject(DialogConfig), \u0275\u0275directiveInject(InteractivityChecker), \u0275\u0275directiveInject(NgZone), \u0275\u0275directiveInject(OverlayRef), \u0275\u0275directiveInject(FocusMonitor)); 304 }; 305 } 306 static { 307 this.\u0275cmp = /* @__PURE__ */ \u0275\u0275defineComponent({ 308 type: _CdkDialogContainer, 309 selectors: [["cdk-dialog-container"]], 310 viewQuery: function CdkDialogContainer_Query(rf, ctx) { 311 if (rf & 1) { 312 \u0275\u0275viewQuery(CdkPortalOutlet, 7); 313 } 314 if (rf & 2) { 315 let _t; 316 \u0275\u0275queryRefresh(_t = \u0275\u0275loadQuery()) && (ctx._portalOutlet = _t.first); 317 } 318 }, 319 hostAttrs: ["tabindex", "-1", 1, "cdk-dialog-container"], 320 hostVars: 6, 321 hostBindings: function CdkDialogContainer_HostBindings(rf, ctx) { 322 if (rf & 2) { 323 \u0275\u0275attribute("id", ctx._config.id || null)("role", ctx._config.role)("aria-modal", ctx._config.ariaModal)("aria-labelledby", ctx._config.ariaLabel ? null : ctx._ariaLabelledByQueue[0])("aria-label", ctx._config.ariaLabel)("aria-describedby", ctx._config.ariaDescribedBy || null); 324 } 325 }, 326 standalone: true, 327 features: [\u0275\u0275InheritDefinitionFeature, \u0275\u0275StandaloneFeature], 328 decls: 1, 329 vars: 0, 330 consts: [["cdkPortalOutlet", ""]], 331 template: function CdkDialogContainer_Template(rf, ctx) { 332 if (rf & 1) { 333 \u0275\u0275template(0, CdkDialogContainer_ng_template_0_Template, 0, 0, "ng-template", 0); 334 } 335 }, 336 dependencies: [CdkPortalOutlet], 337 styles: [".cdk-dialog-container{display:block;width:100%;height:100%;min-height:inherit;max-height:inherit}"], 338 encapsulation: 2 339 }); 340 } 341}; 342(() => { 343 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(CdkDialogContainer, [{ 344 type: Component, 345 args: [{ 346 selector: "cdk-dialog-container", 347 encapsulation: ViewEncapsulation$1.None, 348 changeDetection: ChangeDetectionStrategy.Default, 349 standalone: true, 350 imports: [CdkPortalOutlet], 351 host: { 352 "class": "cdk-dialog-container", 353 "tabindex": "-1", 354 "[attr.id]": "_config.id || null", 355 "[attr.role]": "_config.role", 356 "[attr.aria-modal]": "_config.ariaModal", 357 "[attr.aria-labelledby]": "_config.ariaLabel ? null : _ariaLabelledByQueue[0]", 358 "[attr.aria-label]": "_config.ariaLabel", 359 "[attr.aria-describedby]": "_config.ariaDescribedBy || null" 360 }, 361 template: "<ng-template cdkPortalOutlet />\n", 362 styles: [".cdk-dialog-container{display:block;width:100%;height:100%;min-height:inherit;max-height:inherit}"] 363 }] 364 }], () => [{ 365 type: ElementRef 366 }, { 367 type: FocusTrapFactory 368 }, { 369 type: void 0, 370 decorators: [{ 371 type: Optional 372 }, {
373 type: Inject, 374 args: [DOCUMENT] 375 }] 376 }, { 377 type: void 0, 378 decorators: [{ 379 type: Inject, 380 args: [DialogConfig] 381 }] 382 }, { 383 type: InteractivityChecker 384 }, { 385 type: NgZone 386 }, { 387 type: OverlayRef 388 }, { 389 type: FocusMonitor 390 }], { 391 _portalOutlet: [{ 392 type: ViewChild, 393 args: [CdkPortalOutlet, { 394 static: true 395 }] 396 }] 397 }); 398})(); 399var DialogRef = class { 400 constructor(overlayRef, config) { 401 this.overlayRef = overlayRef; 402 this.config = config; 403 this.closed = new Subject(); 404 this.disableClose = config.disableClose; 405 this.backdropClick = overlayRef.backdropClick(); 406 this.keydownEvents = overlayRef.keydownEvents(); 407 this.outsidePointerEvents = overlayRef.outsidePointerEvents(); 408 this.id = config.id; 409 this.keydownEvents.subscribe((event) => { 410 if (event.keyCode === ESCAPE && !this.disableClose && !hasModifierKey(event)) { 411 event.preventDefault(); 412 this.close(void 0, { 413 focusOrigin: "keyboard" 414 }); 415 } 416 }); 417 this.backdropClick.subscribe(() => { 418 if (!this.disableClose) { 419 this.close(void 0, { 420 focusOrigin: "mouse" 421 }); 422 } 423 }); 424 this._detachSubscription = overlayRef.detachments().subscribe(() => { 425 if (config.closeOnOverlayDetachments !== false) { 426 this.close(); 427 } 428 }); 429 } 430 /** 431 * Close the dialog. 432 * @param result Optional result to return to the dialog opener. 433 * @param options Additional options to customize the closing behavior. 434 */ 435 close(result, options) { 436 if (this.containerInstance) { 437 const closedSubject = this.closed; 438 this.containerInstance._closeInteractionType = options?.focusOrigin || "program"; 439 this._detachSubscription.unsubscribe(); 440 this.overlayRef.dispose(); 441 closedSubject.next(result); 442 closedSubject.complete(); 443 this.componentInstance = this.containerInstance = null; 444 } 445 } 446 /** Updates the position of the dialog based on the current position strategy. */ 447 updatePosition() { 448 this.overlayRef.updatePosition(); 449 return this; 450 } 451 /** 452 * Updates the dialog's width and height. 453 * @param width New width of the dialog. 454 * @param height New height of the dialog. 455 */ 456 updateSize(width = "", height = "") { 457 this.overlayRef.updateSize({ 458 width, 459 height 460 }); 461 return this; 462 } 463 /** Add a CSS class or an array of classes to the overlay pane. */ 464 addPanelClass(classes) { 465 this.overlayRef.addPanelClass(classes); 466 return this; 467 } 468 /** Remove a CSS class or an array of classes from the overlay pane. */ 469 removePanelClass(classes) { 470 this.overlayRef.removePanelClass(classes); 471 return this; 472 } 473}; 474var DIALOG_SCROLL_STRATEGY = new InjectionToken("DialogScrollStrategy", { 475 providedIn: "root", 476 factory: () => { 477 const overlay = inject(Overlay); 478 return () => overlay.scrollStrategies.block(); 479 } 480}); 481var DIALOG_DATA = new InjectionToken("DialogData"); 482var DEFAULT_DIALOG_CONFIG = new InjectionToken("DefaultDialogConfig"); 483var uniqueId = 0; 484var Dialog = class _Dialog { 485 /** Keeps track of the currently-open dialogs. */ 486 get openDialogs() { 487 return this._parentDialog ? this._parentDialog.openDialogs : this._openDialogsAtThisLevel; 488 } 489 /** Stream that emits when a dialog has been opened. */ 490 get afterOpened() { 491 return this._parentDialog ? this._parentDialog.afterOpened : this._afterOpenedAtThisLevel; 492 } 493 constructor(_overlay, _injector, _defaultOptions, _parentDialog, _overlayContainer, scrollStrategy) { 494 this._overlay = _overlay; 495 this._injector = _injector; 496 this._defaultOptions = _defaultOptions; 497 this._parentDialog = _parentDialog; 498 this._overlayContainer = _overlayContainer; 499 this._openDialogsAtThisLevel = []; 500 this._afterAllClosedAtThisLevel = new Subject(); 501 this._afterOpenedAtThisLevel = new Subject(); 502 this._ariaHiddenElements = /* @__PURE__ */ new Map(); 503 this.afterAllClosed = defer(() => this.openDialogs.length ? this._getAfterAllClosed() : this._getAfterAllClosed().pipe(startWith(void 0))); 504 this._scrollStrategy = scrollStrategy; 505 } 506 open(componentOrTemplateRef, config) { 507 const defaults = this._defaultOptions || new DialogConfig(); 508 config = __spreadValues(__spreadValues({}, defaults), config); 509 config.id = config.id || `cdk-dialog-${uniqueId++}`; 510 if (config.id && this.getDialogById(config.id) && (typeof ngDevMode === "undefined" || ngDevMode)) { 511 throw Error(`Dialog with id "${config.id}" exists already. The dialog id must be unique.`); 512 } 513 const overlayConfig = this._getOverlayConfig(config); 514 const overlayRef = this._overlay.create(overlayConfig); 515 const dialogRef = new DialogRef(overlayRef, config); 516 const dialogContainer = this._attachContainer(overlayRef, dialogRef, config); 517 dialogRef.containerInstance = dialogContainer; 518 this._attachDialogContent(componentOrTemplateRef, dialogRef, dialogContainer, config); 519 if (!this.openDialogs.length) { 520 this._hideNonDialogContentFromAssistiveTechnology(); 521 } 522 this.openDialogs.push(dialogRef); 523 dialogRef.closed.subscribe(() => this._removeOpenDialog(dialogRef, true)); 524 this.afterOpened.next(dialogRef); 525 return dialogRef; 526 } 527 /** 528 * Closes all of the currently-open dialogs. 529 */ 530 closeAll() { 531 reverseForEach(this.openDialogs, (dialog) => dialog.close()); 532 } 533 /** 534 * Finds an open dialog by its id. 535 * @param id ID to use when looking up the dialog. 536 */ 537 getDialogById(id) { 538 return this.openDialogs.find((dialog) => dialog.id === id); 539 } 540 ngOnDestroy() { 541 reverseForEach(this._openDialogsAtThisLevel, (dialog) => { 542 if (dialog.config.closeOnDestroy === false) { 543 this._removeOpenDialog(dialog, false); 544 } 545 }); 546 reverseForEach(this._openDialogsAtThisLevel, (dialog) => dialog.close()); 547 this._afterAllClosedAtThisLevel.complete(); 548 this._afterOpenedAtThisLevel.complete(); 549 this._openDialogsAtThisLevel = []; 550 } 551 /** 552 * Creates an overlay config from a dialog config. 553 * @param config The dialog configuration. 554 * @returns The overlay configuration. 555 */ 556 _getOverlayConfig(config) { 557 const state = new OverlayConfig({ 558 positionStrategy: config.positionStrategy || this._overlay.position().global().centerHorizontally().centerVertically(), 559 scrollStrategy: config.scrollStrategy || this._scrollStrategy(), 560 panelClass: config.panelClass, 561 hasBackdrop: config.hasBackdrop, 562 direction: config.direction, 563 minWidth: config.minWidth, 564 minHeight: config.minHeight, 565 maxWidth: config.maxWidth, 566 maxHeight: config.maxHeight, 567 width: config.width, 568 height: config.height, 569 disposeOnNavigation: config.closeOnNavigation 570 }); 571 if (config.backdropClass) { 572 state.backdropClass = config.backdropClass; 573 } 574 return state; 575 } 576 /** 577 * Attaches a dialog container to a dialog's already-created overlay. 578 * @param overlay Reference to the dialog's underlying overlay. 579 * @param config The dialog configuration. 580 * @returns A promise resolving to a ComponentRef for the attached container. 581 */ 582 _attachContainer(overlay, dialogRef, config) { 583 const userInjector = config.injector || config.viewContainerRef?.injector; 584 const providers = [{ 585 provide: DialogConfig, 586 useValue: config 587 }, {
588 provide: DialogRef, 589 useValue: dialogRef 590 }, { 591 provide: OverlayRef, 592 useValue: overlay 593 }]; 594 let containerType; 595 if (config.container) { 596 if (typeof config.container === "function") { 597 containerType = config.container; 598 } else { 599 containerType = config.container.type; 600 providers.push(...config.container.providers(config)); 601 } 602 } else { 603 containerType = CdkDialogContainer; 604 } 605 const containerPortal = new ComponentPortal(containerType, config.viewContainerRef, Injector.create({ 606 parent: userInjector || this._injector, 607 providers 608 }), config.componentFactoryResolver); 609 const containerRef = overlay.attach(containerPortal); 610 return containerRef.instance; 611 } 612 /** 613 * Attaches the user-provided component to the already-created dialog container. 614 * @param componentOrTemplateRef The type of component being loaded into the dialog, 615 * or a TemplateRef to instantiate as the content. 616 * @param dialogRef Reference to the dialog being opened. 617 * @param dialogContainer Component that is going to wrap the dialog content. 618 * @param config Configuration used to open the dialog. 619 */ 620 _attachDialogContent(componentOrTemplateRef, dialogRef, dialogContainer, config) { 621 if (componentOrTemplateRef instanceof TemplateRef) { 622 const injector = this._createInjector(config, dialogRef, dialogContainer, void 0); 623 let context = { 624 $implicit: config.data, 625 dialogRef 626 }; 627 if (config.templateContext) { 628 context = __spreadValues(__spreadValues({}, context), typeof config.templateContext === "function" ? config.templateContext() : config.templateContext); 629 } 630 dialogContainer.attachTemplatePortal(new TemplatePortal(componentOrTemplateRef, null, context, injector)); 631 } else { 632 const injector = this._createInjector(config, dialogRef, dialogContainer, this._injector); 633 const contentRef = dialogContainer.attachComponentPortal(new ComponentPortal(componentOrTemplateRef, config.viewContainerRef, injector, config.componentFactoryResolver)); 634 dialogRef.componentRef = contentRef; 635 dialogRef.componentInstance = contentRef.instance; 636 } 637 } 638 /** 639 * Creates a custom injector to be used inside the dialog. This allows a component loaded inside 640 * of a dialog to close itself and, optionally, to return a value. 641 * @param config Config object that is used to construct the dialog. 642 * @param dialogRef Reference to the dialog being opened. 643 * @param dialogContainer Component that is going to wrap the dialog content. 644 * @param fallbackInjector Injector to use as a fallback when a lookup fails in the custom 645 * dialog injector, if the user didn't provide a custom one. 646 * @returns The custom injector that can be used inside the dialog. 647 */ 648 _createInjector(config, dialogRef, dialogContainer, fallbackInjector) { 649 const userInjector = config.injector || config.viewContainerRef?.injector; 650 const providers = [{ 651 provide: DIALOG_DATA, 652 useValue: config.data 653 }, { 654 provide: DialogRef, 655 useValue: dialogRef 656 }]; 657 if (config.providers) { 658 if (typeof config.providers === "function") { 659 providers.push(...config.providers(dialogRef, config, dialogContainer)); 660 } else { 661 providers.push(...config.providers); 662 } 663 } 664 if (config.direction && (!userInjector || !userInjector.get(Directionality, null, { 665 optional: true 666 }))) { 667 providers.push({ 668 provide: Directionality, 669 useValue: { 670 value: config.direction, 671 change: of() 672 } 673 }); 674 } 675 return Injector.create({ 676 parent: userInjector || fallbackInjector, 677 providers 678 }); 679 } 680 /** 681 * Removes a dialog from the array of open dialogs. 682 * @param dialogRef Dialog to be removed. 683 * @param emitEvent Whether to emit an event if this is the last dialog. 684 */ 685 _removeOpenDialog(dialogRef, emitEvent) { 686 const index = this.openDialogs.indexOf(dialogRef); 687 if (index > -1) { 688 this.openDialogs.splice(index, 1); 689 if (!this.openDialogs.length) {
690 this._ariaHiddenElements.forEach((previousValue, element) => { 691 if (previousValue) { 692 element.setAttribute("aria-hidden", previousValue); 693 } else { 694 element.removeAttribute("aria-hidden"); 695 } 696 }); 697 this._ariaHiddenElements.clear(); 698 if (emitEvent) { 699 this._getAfterAllClosed().next(); 700 } 701 } 702 } 703 } 704 /** Hides all of the content that isn't an overlay from assistive technology. */ 705 _hideNonDialogContentFromAssistiveTechnology() { 706 const overlayContainer = this._overlayContainer.getContainerElement(); 707 if (overlayContainer.parentElement) { 708 const siblings = overlayContainer.parentElement.children; 709 for (let i = siblings.length - 1; i > -1; i--) { 710 const sibling = siblings[i]; 711 if (sibling !== overlayContainer && sibling.nodeName !== "SCRIPT" && sibling.nodeName !== "STYLE" && !sibling.hasAttribute("aria-live")) { 712 this._ariaHiddenElements.set(sibling, sibling.getAttribute("aria-hidden")); 713 sibling.setAttribute("aria-hidden", "true"); 714 } 715 } 716 } 717 } 718 _getAfterAllClosed() { 719 const parent = this._parentDialog; 720 return parent ? parent._getAfterAllClosed() : this._afterAllClosedAtThisLevel; 721 } 722 static { 723 this.\u0275fac = function Dialog_Factory(__ngFactoryType__) { 724 return new (__ngFactoryType__ || _Dialog)(\u0275\u0275inject(Overlay), \u0275\u0275inject(Injector), \u0275\u0275inject(DEFAULT_DIALOG_CONFIG, 8), \u0275\u0275inject(_Dialog, 12), \u0275\u0275inject(OverlayContainer), \u0275\u0275inject(DIALOG_SCROLL_STRATEGY)); 725 }; 726 } 727 static { 728 this.\u0275prov = /* @__PURE__ */ \u0275\u0275defineInjectable({ 729 token: _Dialog, 730 factory: _Dialog.\u0275fac, 731 providedIn: "root" 732 }); 733 } 734}; 735(() => { 736 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(Dialog, [{ 737 type: Injectable, 738 args: [{ 739 providedIn: "root" 740 }] 741 }], () => [{ 742 type: Overlay 743 }, { 744 type: Injector 745 }, { 746 type: DialogConfig, 747 decorators: [{ 748 type: Optional 749 }, { 750 type: Inject, 751 args: [DEFAULT_DIALOG_CONFIG] 752 }] 753 }, { 754 type: Dialog, 755 decorators: [{ 756 type: Optional 757 }, { 758 type: SkipSelf 759 }] 760 }, { 761 type: OverlayContainer 762 }, { 763 type: void 0, 764 decorators: [{ 765 type: Inject, 766 args: [DIALOG_SCROLL_STRATEGY] 767 }] 768 }], null); 769})(); 770function reverseForEach(items, callback) { 771 let i = items.length; 772 while (i--) { 773 callback(items[i]); 774 } 775} 776var DialogModule = class _DialogModule { 777 static { 778 this.\u0275fac = function DialogModule_Factory(__ngFactoryType__) { 779 return new (__ngFactoryType__ || _DialogModule)(); 780 }; 781 } 782 static { 783 this.\u0275mod = /* @__PURE__ */ \u0275\u0275defineNgModule({ 784 type: _DialogModule 785 }); 786 } 787 static { 788 this.\u0275inj = /* @__PURE__ */ \u0275\u0275defineInjector({ 789 providers: [Dialog], 790 imports: [ 791 OverlayModule, 792 PortalModule, 793 A11yModule, 794 // Re-export the PortalModule so that people extending the `CdkDialogContainer` 795 // don't have to remember to import it or be faced with an unhelpful error. 796 PortalModule 797 ] 798 }); 799 } 800}; 801(() => { 802 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(DialogModule, [{ 803 type: NgModule, 804 args: [{ 805 imports: [OverlayModule, PortalModule, A11yModule, CdkDialogContainer], 806 exports: [ 807 // Re-export the PortalModule so that people extending the `CdkDialogContainer` 808 // don't have to remember to import it or be faced with an unhelpful error. 809 PortalModule, 810 CdkDialogContainer 811 ], 812 providers: [Dialog] 813 }] 814 }], null, null); 815})(); 816 817export { 818 DIALOG_DATA, 819 Dialog, 820 DialogModule 821}; 822//# sourceMappingURL=chunk-Q3MUBKM2.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.