@angular/cdk 7.1.1 → 7.3.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/LICENSE +1 -1
- package/_a11y.scss +1 -1
- package/a11y/typings/focus-monitor/focus-monitor.d.ts +0 -1
- package/a11y/typings/focus-trap/focus-trap.d.ts +2 -0
- package/a11y/typings/index.metadata.json +1 -1
- package/bundles/cdk-a11y.umd.js +30 -24
- package/bundles/cdk-a11y.umd.js.map +1 -1
- package/bundles/cdk-a11y.umd.min.js +1 -1
- package/bundles/cdk-a11y.umd.min.js.map +1 -1
- package/bundles/cdk-coercion.umd.js +20 -4
- package/bundles/cdk-coercion.umd.js.map +1 -1
- package/bundles/cdk-coercion.umd.min.js +1 -1
- package/bundles/cdk-coercion.umd.min.js.map +1 -1
- package/bundles/cdk-drag-drop.umd.js +3246 -1894
- package/bundles/cdk-drag-drop.umd.js.map +1 -1
- package/bundles/cdk-drag-drop.umd.min.js +2 -1
- package/bundles/cdk-drag-drop.umd.min.js.map +1 -1
- package/bundles/cdk-observers.umd.js +2 -2
- package/bundles/cdk-observers.umd.js.map +1 -1
- package/bundles/cdk-observers.umd.min.js +1 -1
- package/bundles/cdk-observers.umd.min.js.map +1 -1
- package/bundles/cdk-overlay.umd.js +107 -45
- package/bundles/cdk-overlay.umd.js.map +1 -1
- package/bundles/cdk-overlay.umd.min.js +2 -2
- package/bundles/cdk-overlay.umd.min.js.map +1 -1
- package/bundles/cdk-portal.umd.js +3 -3
- package/bundles/cdk-portal.umd.js.map +1 -1
- package/bundles/cdk-portal.umd.min.js.map +1 -1
- package/bundles/cdk-scrolling.umd.js +9 -6
- package/bundles/cdk-scrolling.umd.js.map +1 -1
- package/bundles/cdk-scrolling.umd.min.js +1 -1
- package/bundles/cdk-scrolling.umd.min.js.map +1 -1
- package/bundles/cdk-stepper.umd.js +36 -16
- package/bundles/cdk-stepper.umd.js.map +1 -1
- package/bundles/cdk-stepper.umd.min.js +1 -1
- package/bundles/cdk-stepper.umd.min.js.map +1 -1
- package/bundles/cdk-table.umd.js +8 -4
- package/bundles/cdk-table.umd.js.map +1 -1
- package/bundles/cdk-table.umd.min.js +1 -1
- package/bundles/cdk-table.umd.min.js.map +1 -1
- package/bundles/cdk-text-field.umd.js +47 -22
- package/bundles/cdk-text-field.umd.js.map +1 -1
- package/bundles/cdk-text-field.umd.min.js +1 -1
- package/bundles/cdk-text-field.umd.min.js.map +1 -1
- package/bundles/cdk-tree.umd.js +1 -1
- package/bundles/cdk-tree.umd.js.map +1 -1
- package/bundles/cdk-tree.umd.min.js +1 -1
- package/bundles/cdk-tree.umd.min.js.map +1 -1
- package/bundles/cdk.umd.js +1 -1
- package/bundles/cdk.umd.js.map +1 -1
- package/bundles/cdk.umd.min.js +1 -1
- package/bundles/cdk.umd.min.js.map +1 -1
- package/coercion/typings/element.d.ts +13 -0
- package/coercion/typings/index.metadata.json +1 -1
- package/coercion/typings/public-api.d.ts +1 -0
- package/drag-drop/typings/{drag-handle.d.ts → directives/drag-handle.d.ts} +6 -2
- package/drag-drop/typings/{drag-placeholder.d.ts → directives/drag-placeholder.d.ts} +0 -0
- package/drag-drop/typings/{drag-preview.d.ts → directives/drag-preview.d.ts} +0 -0
- package/drag-drop/typings/directives/drag.d.ts +114 -0
- package/{typings/esm5/drag-drop → drag-drop/typings/directives}/drop-list-group.d.ts +3 -0
- package/drag-drop/typings/{drop-list.d.ts → directives/drop-list.d.ts} +44 -70
- package/drag-drop/typings/drag-drop-registry.d.ts +8 -3
- package/drag-drop/typings/drag-drop.d.ts +33 -0
- package/drag-drop/typings/drag-events.d.ts +14 -7
- package/{typings/esm5/drag-drop/drag.d.ts → drag-drop/typings/drag-ref.d.ts} +162 -86
- package/drag-drop/typings/drop-list-container.d.ts +19 -3
- package/drag-drop/typings/drop-list-ref.d.ts +238 -0
- package/drag-drop/typings/index.d.ts +2 -1
- package/drag-drop/typings/index.metadata.json +1 -1
- package/drag-drop/typings/public-api.d.ts +16 -6
- package/esm2015/a11y.js +30 -20
- package/esm2015/a11y.js.map +1 -1
- package/esm2015/cdk.js +1 -1
- package/esm2015/cdk.js.map +1 -1
- package/esm2015/coercion.js +18 -1
- package/esm2015/coercion.js.map +1 -1
- package/esm2015/drag-drop.js +2281 -1289
- package/esm2015/drag-drop.js.map +1 -1
- package/esm2015/observers.js +3 -3
- package/esm2015/observers.js.map +1 -1
- package/esm2015/overlay.js +75 -31
- package/esm2015/overlay.js.map +1 -1
- package/esm2015/portal.js +1 -1
- package/esm2015/portal.js.map +1 -1
- package/esm2015/scrolling.js +9 -6
- package/esm2015/scrolling.js.map +1 -1
- package/esm2015/stepper.js +30 -16
- package/esm2015/stepper.js.map +1 -1
- package/esm2015/table.js +8 -4
- package/esm2015/table.js.map +1 -1
- package/esm2015/text-field.js +31 -19
- package/esm2015/text-field.js.map +1 -1
- package/esm2015/tree.js +2 -2
- package/esm2015/tree.js.map +1 -1
- package/esm5/a11y.es5.js +31 -25
- package/esm5/a11y.es5.js.map +1 -1
- package/esm5/cdk.es5.js +1 -1
- package/esm5/cdk.es5.js.map +1 -1
- package/esm5/coercion.es5.js +18 -1
- package/esm5/coercion.es5.js.map +1 -1
- package/esm5/drag-drop.es5.js +3247 -1899
- package/esm5/drag-drop.es5.js.map +1 -1
- package/esm5/observers.es5.js +3 -3
- package/esm5/observers.es5.js.map +1 -1
- package/esm5/overlay.es5.js +107 -45
- package/esm5/overlay.es5.js.map +1 -1
- package/esm5/portal.es5.js +3 -3
- package/esm5/portal.es5.js.map +1 -1
- package/esm5/scrolling.es5.js +9 -6
- package/esm5/scrolling.es5.js.map +1 -1
- package/esm5/stepper.es5.js +36 -17
- package/esm5/stepper.es5.js.map +1 -1
- package/esm5/table.es5.js +8 -4
- package/esm5/table.es5.js.map +1 -1
- package/esm5/text-field.es5.js +44 -19
- package/esm5/text-field.es5.js.map +1 -1
- package/esm5/tree.es5.js +2 -2
- package/esm5/tree.es5.js.map +1 -1
- package/overlay/typings/index.metadata.json +1 -1
- package/overlay/typings/overlay-directives.d.ts +0 -2
- package/overlay/typings/overlay-ref.d.ts +5 -1
- package/overlay/typings/position/flexible-connected-position-strategy.d.ts +17 -4
- package/overlay/typings/position/overlay-position-builder.d.ts +3 -3
- package/package.json +4 -4
- package/portal/typings/portal.d.ts +1 -1
- package/schematics/migration.json +5 -0
- package/schematics/ng-generate/drag-drop/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.ts +2 -2
- package/schematics/ng-update/index.d.ts +2 -0
- package/schematics/ng-update/index.js +5 -0
- package/schematics/ng-update/index.js.map +1 -1
- package/schematics/ng-update/target-version.d.ts +7 -1
- package/schematics/ng-update/target-version.js +10 -0
- package/schematics/ng-update/target-version.js.map +1 -1
- package/schematics/ng-update/upgrade-data.js +2 -1
- package/schematics/ng-update/upgrade-data.js.map +1 -1
- package/schematics/ng-update/upgrade-rules/index.js +3 -2
- package/schematics/ng-update/upgrade-rules/index.js.map +1 -1
- package/schematics/utils/ast/ng-module-imports.d.ts +1 -1
- package/schematics/utils/ast/ng-module-imports.js +25 -13
- package/schematics/utils/ast/ng-module-imports.js.map +1 -1
- package/schematics/utils/get-project.js +2 -1
- package/schematics/utils/get-project.js.map +1 -1
- package/schematics/utils/parse5-element.js +3 -2
- package/schematics/utils/parse5-element.js.map +1 -1
- package/schematics/utils/project-targets.js +2 -1
- package/schematics/utils/project-targets.js.map +1 -1
- package/schematics/utils/version-agnostic-typescript.js +3 -2
- package/schematics/utils/version-agnostic-typescript.js.map +1 -1
- package/stepper/typings/index.metadata.json +1 -1
- package/stepper/typings/stepper.d.ts +14 -2
- package/text-field/typings/autosize.d.ts +6 -0
- package/text-field/typings/index.metadata.json +1 -1
- package/tree/typings/control/base-tree-control.d.ts +1 -1
- package/tree/typings/control/nested-tree-control.d.ts +2 -2
- package/tree/typings/control/tree-control.d.ts +1 -1
- package/typings/a11y/focus-monitor/focus-monitor.d.ts +0 -1
- package/typings/a11y/focus-trap/focus-trap.d.ts +2 -0
- package/typings/a11y/index.metadata.json +1 -1
- package/typings/coercion/element.d.ts +13 -0
- package/typings/coercion/index.metadata.json +1 -1
- package/typings/coercion/public-api.d.ts +1 -0
- package/typings/drag-drop/{drag-handle.d.ts → directives/drag-handle.d.ts} +6 -2
- package/typings/drag-drop/{drag-placeholder.d.ts → directives/drag-placeholder.d.ts} +0 -0
- package/typings/drag-drop/{drag-preview.d.ts → directives/drag-preview.d.ts} +0 -0
- package/typings/drag-drop/directives/drag.d.ts +114 -0
- package/typings/drag-drop/{drop-list-group.d.ts → directives/drop-list-group.d.ts} +3 -0
- package/typings/{esm5/drag-drop → drag-drop/directives}/drop-list.d.ts +44 -70
- package/typings/drag-drop/drag-drop-registry.d.ts +8 -3
- package/typings/drag-drop/drag-drop.d.ts +33 -0
- package/typings/drag-drop/drag-events.d.ts +14 -7
- package/typings/drag-drop/{drag.d.ts → drag-ref.d.ts} +162 -86
- package/typings/drag-drop/drop-list-container.d.ts +19 -3
- package/typings/drag-drop/drop-list-ref.d.ts +238 -0
- package/typings/drag-drop/index.d.ts +2 -1
- package/typings/drag-drop/index.metadata.json +1 -1
- package/typings/drag-drop/public-api.d.ts +16 -6
- package/typings/esm5/a11y/focus-monitor/focus-monitor.d.ts +0 -1
- package/typings/esm5/a11y/focus-trap/focus-trap.d.ts +2 -0
- package/typings/esm5/a11y/index.metadata.json +1 -1
- package/typings/esm5/coercion/element.d.ts +13 -0
- package/typings/esm5/coercion/index.metadata.json +1 -1
- package/typings/esm5/coercion/public-api.d.ts +1 -0
- package/typings/esm5/drag-drop/{drag-handle.d.ts → directives/drag-handle.d.ts} +6 -2
- package/typings/esm5/drag-drop/{drag-placeholder.d.ts → directives/drag-placeholder.d.ts} +0 -0
- package/typings/esm5/drag-drop/{drag-preview.d.ts → directives/drag-preview.d.ts} +0 -0
- package/typings/esm5/drag-drop/directives/drag.d.ts +114 -0
- package/{drag-drop/typings → typings/esm5/drag-drop/directives}/drop-list-group.d.ts +3 -0
- package/typings/{drag-drop → esm5/drag-drop/directives}/drop-list.d.ts +44 -70
- package/typings/esm5/drag-drop/drag-drop-registry.d.ts +8 -3
- package/typings/esm5/drag-drop/drag-drop.d.ts +33 -0
- package/typings/esm5/drag-drop/drag-events.d.ts +14 -7
- package/{drag-drop/typings/drag.d.ts → typings/esm5/drag-drop/drag-ref.d.ts} +162 -86
- package/typings/esm5/drag-drop/drop-list-container.d.ts +19 -3
- package/typings/esm5/drag-drop/drop-list-ref.d.ts +238 -0
- package/typings/esm5/drag-drop/index.d.ts +2 -1
- package/typings/esm5/drag-drop/index.metadata.json +1 -1
- package/typings/esm5/drag-drop/public-api.d.ts +16 -6
- package/typings/esm5/index.metadata.json +1 -1
- package/typings/esm5/overlay/index.metadata.json +1 -1
- package/typings/esm5/overlay/overlay-directives.d.ts +0 -2
- package/typings/esm5/overlay/overlay-ref.d.ts +5 -1
- package/typings/esm5/overlay/position/flexible-connected-position-strategy.d.ts +17 -4
- package/typings/esm5/overlay/position/overlay-position-builder.d.ts +3 -3
- package/typings/esm5/portal/portal.d.ts +1 -1
- package/typings/esm5/stepper/index.metadata.json +1 -1
- package/typings/esm5/stepper/stepper.d.ts +14 -2
- package/typings/esm5/text-field/autosize.d.ts +6 -0
- package/typings/esm5/text-field/index.metadata.json +1 -1
- package/typings/esm5/tree/control/base-tree-control.d.ts +1 -1
- package/typings/esm5/tree/control/nested-tree-control.d.ts +2 -2
- package/typings/esm5/tree/control/tree-control.d.ts +1 -1
- package/typings/index.metadata.json +1 -1
- package/typings/overlay/index.metadata.json +1 -1
- package/typings/overlay/overlay-directives.d.ts +0 -2
- package/typings/overlay/overlay-ref.d.ts +5 -1
- package/typings/overlay/position/flexible-connected-position-strategy.d.ts +17 -4
- package/typings/overlay/position/overlay-position-builder.d.ts +3 -3
- package/typings/portal/portal.d.ts +1 -1
- package/typings/schematics/ng-update/index.d.ts +2 -0
- package/typings/schematics/ng-update/target-version.d.ts +7 -1
- package/typings/schematics/utils/ast/ng-module-imports.d.ts +1 -1
- package/typings/stepper/index.metadata.json +1 -1
- package/typings/stepper/stepper.d.ts +14 -2
- package/typings/text-field/autosize.d.ts +6 -0
- package/typings/text-field/index.metadata.json +1 -1
- package/typings/tree/control/base-tree-control.d.ts +1 -1
- package/typings/tree/control/nested-tree-control.d.ts +2 -2
- package/typings/tree/control/tree-control.d.ts +1 -1
package/esm5/observers.es5.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
|
-
import { coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coercion';
|
|
8
|
+
import { coerceBooleanProperty, coerceNumberProperty, coerceElement } from '@angular/cdk/coercion';
|
|
9
9
|
import { Directive, ElementRef, EventEmitter, Injectable, Input, NgModule, NgZone, Output, defineInjectable, inject } from '@angular/core';
|
|
10
10
|
import { Observable, Subject } from 'rxjs';
|
|
11
11
|
import { debounceTime } from 'rxjs/operators';
|
|
@@ -70,8 +70,8 @@ var ContentObserver = /** @class */ (function () {
|
|
|
70
70
|
function (elementOrRef) {
|
|
71
71
|
var _this = this;
|
|
72
72
|
/** @type {?} */
|
|
73
|
-
var element = elementOrRef
|
|
74
|
-
return Observable
|
|
73
|
+
var element = coerceElement(elementOrRef);
|
|
74
|
+
return new Observable(function (observer) {
|
|
75
75
|
/** @type {?} */
|
|
76
76
|
var stream = _this._observeElement(element);
|
|
77
77
|
/** @type {?} */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observers.es5.js","sources":["../../../src/cdk/observers/observe-content.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {coerceBooleanProperty, coerceNumberProperty} from '@angular/cdk/coercion';\nimport {\n AfterContentInit,\n Directive,\n ElementRef,\n EventEmitter,\n Injectable,\n Input,\n NgModule,\n NgZone,\n OnDestroy,\n Output,\n} from '@angular/core';\nimport {Observable, Subject, Subscription, Observer} from 'rxjs';\nimport {debounceTime} from 'rxjs/operators';\n\n/**\n * Factory that creates a new MutationObserver and allows us to stub it out in unit tests.\n * @docs-private\n */\n@Injectable({providedIn: 'root'})\nexport class MutationObserverFactory {\n create(callback: MutationCallback): MutationObserver | null {\n return typeof MutationObserver === 'undefined' ? null : new MutationObserver(callback);\n }\n}\n\n\n/** An injectable service that allows watching elements for changes to their content. */\n@Injectable({providedIn: 'root'})\nexport class ContentObserver implements OnDestroy {\n /** Keeps track of the existing MutationObservers so they can be reused. */\n private _observedElements = new Map<Element, {\n observer: MutationObserver | null,\n stream: Subject<MutationRecord[]>,\n count: number\n }>();\n\n constructor(private _mutationObserverFactory: MutationObserverFactory) {}\n\n ngOnDestroy() {\n this._observedElements.forEach((_, element) => this._cleanupObserver(element));\n }\n\n /**\n * Observe content changes on an element.\n * @param element The element to observe for content changes.\n */\n observe(element: Element): Observable<MutationRecord[]>;\n\n /**\n * Observe content changes on an element.\n * @param element The element to observe for content changes.\n */\n observe(element: ElementRef<Element>): Observable<MutationRecord[]>;\n\n observe(elementOrRef: Element | ElementRef<Element>): Observable<MutationRecord[]> {\n const element = elementOrRef instanceof ElementRef ? elementOrRef.nativeElement : elementOrRef;\n\n return Observable.create((observer: Observer<MutationRecord[]>) => {\n const stream = this._observeElement(element);\n const subscription = stream.subscribe(observer);\n\n return () => {\n subscription.unsubscribe();\n this._unobserveElement(element);\n };\n });\n }\n\n /**\n * Observes the given element by using the existing MutationObserver if available, or creating a\n * new one if not.\n */\n private _observeElement(element: Element): Subject<MutationRecord[]> {\n if (!this._observedElements.has(element)) {\n const stream = new Subject<MutationRecord[]>();\n const observer = this._mutationObserverFactory.create(mutations => stream.next(mutations));\n if (observer) {\n observer.observe(element, {\n characterData: true,\n childList: true,\n subtree: true\n });\n }\n this._observedElements.set(element, {observer, stream, count: 1});\n } else {\n this._observedElements.get(element)!.count++;\n }\n return this._observedElements.get(element)!.stream;\n }\n\n /**\n * Un-observes the given element and cleans up the underlying MutationObserver if nobody else is\n * observing this element.\n */\n private _unobserveElement(element: Element) {\n if (this._observedElements.has(element)) {\n this._observedElements.get(element)!.count--;\n if (!this._observedElements.get(element)!.count) {\n this._cleanupObserver(element);\n }\n }\n }\n\n /** Clean up the underlying MutationObserver for the specified element. */\n private _cleanupObserver(element: Element) {\n if (this._observedElements.has(element)) {\n const {observer, stream} = this._observedElements.get(element)!;\n if (observer) {\n observer.disconnect();\n }\n stream.complete();\n this._observedElements.delete(element);\n }\n }\n}\n\n\n/**\n * Directive that triggers a callback whenever the content of\n * its associated element has changed.\n */\n@Directive({\n selector: '[cdkObserveContent]',\n exportAs: 'cdkObserveContent',\n})\nexport class CdkObserveContent implements AfterContentInit, OnDestroy {\n /** Event emitted for each change in the element's content. */\n @Output('cdkObserveContent') event = new EventEmitter<MutationRecord[]>();\n\n /**\n * Whether observing content is disabled. This option can be used\n * to disconnect the underlying MutationObserver until it is needed.\n */\n @Input('cdkObserveContentDisabled')\n get disabled() { return this._disabled; }\n set disabled(value: any) {\n this._disabled = coerceBooleanProperty(value);\n this._disabled ? this._unsubscribe() : this._subscribe();\n }\n private _disabled = false;\n\n /** Debounce interval for emitting the changes. */\n @Input()\n get debounce(): number { return this._debounce; }\n set debounce(value: number) {\n this._debounce = coerceNumberProperty(value);\n this._subscribe();\n }\n private _debounce: number;\n\n private _currentSubscription: Subscription | null = null;\n\n constructor(private _contentObserver: ContentObserver,\n private _elementRef: ElementRef<HTMLElement>,\n private _ngZone: NgZone) {}\n\n ngAfterContentInit() {\n if (!this._currentSubscription && !this.disabled) {\n this._subscribe();\n }\n }\n\n ngOnDestroy() {\n this._unsubscribe();\n }\n\n private _subscribe() {\n this._unsubscribe();\n const stream = this._contentObserver.observe(this._elementRef);\n\n // TODO(mmalerba): We shouldn't be emitting on this @Output() outside the zone.\n // Consider brining it back inside the zone next time we're making breaking changes.\n // Bringing it back inside can cause things like infinite change detection loops and changed\n // after checked errors if people's code isn't handling it properly.\n this._ngZone.runOutsideAngular(() => {\n this._currentSubscription =\n (this.debounce ? stream.pipe(debounceTime(this.debounce)) : stream).subscribe(this.event);\n });\n }\n\n private _unsubscribe() {\n if (this._currentSubscription) {\n this._currentSubscription.unsubscribe();\n }\n }\n}\n\n\n@NgModule({\n exports: [CdkObserveContent],\n declarations: [CdkObserveContent],\n providers: [MutationObserverFactory]\n})\nexport class ObserversModule {}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AA4BA,AAAA,IAAA,uBAAA,kBAAA,YAAA;IAAA,SAAA,uBAAA,GAAA;KAKC;;;;;IAHC,uBAAF,CAAA,SAAA,CAAA,MAAQ;;;;IAAN,UAAO,QAA0B,EAAnC;QACI,OAAO,OAAO,gBAAgB,KAAK,WAAW,GAAG,IAAI,GAAG,IAAI,gBAAgB,CAAC,QAAQ,CAAC,CAAC;KACxF,CAAH;;QAJA,EAAA,IAAA,EAAC,UAAU,EAAX,IAAA,EAAA,CAAY,EAAC,UAAU,EAAE,MAAM,EAAC,EAAhC,EAAA;;;IA5BA,OAAA,uBAAA,CAAA;CAiCC,EAAD,CAAA,CAAC;AAJD;;;AAQA,AAAA,IAAA,eAAA,kBAAA,YAAA;IASE,SAAF,eAAA,CAAsB,wBAAiD,EAAvE;QAAsB,IAAtB,CAAA,wBAA8C,GAAxB,wBAAwB,CAAyB;;;;QAN7D,IAAV,CAAA,iBAA2B,GAAG,IAAI,GAAG,EAI/B,CAAC;KAEoE;;;;IAEzE,eAAF,CAAA,SAAA,CAAA,WAAa;;;IAAX,YAAF;QAAE,IAAF,KAAA,GAAA,IAAA,CAEG;QADC,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,UAAC,CAAC,EAAE,OAAO,EAA9C,EAAmD,OAAA,KAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAjF,EAAiF,CAAC,CAAC;KAChF,CAAH;;;;;IAcE,eAAF,CAAA,SAAA,CAAA,OAAS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S,2BAA2B,EAApC,EAAA,CAAA;QASA,QAAA,EAAA,CAAA,EAAA,IAAA,EAAG,KAAK,EAAR,CAAA;;IA2CA,OAAA,iBAAC,CAAD;CAAC,EAAD,CAAA,CAAC;AA5DD,AA+DA,IAAA,eAAA,kBAAA,YAAA;IAAA,SAAA,eAAA,GAAA;KAK+B;;QAL/B,EAAA,IAAA,EAAC,QAAQ,EAAT,IAAA,EAAA,CAAU;oBACR,OAAO,EAAE,CAAC,iBAAiB,CAAC;oBAC5B,YAAY,EAAE,CAAC,iBAAiB,CAAC;oBACjC,SAAS,EAAE,CAAC,uBAAuB,CAAC;iBACrC,EAAD,EAAA;;IAC8B,OAA9B,eAA+B,CAA/B;CAA+B,EAA/B,CAAA;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"observers.es5.js","sources":["../../../src/cdk/observers/observe-content.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {coerceBooleanProperty, coerceNumberProperty, coerceElement} from '@angular/cdk/coercion';\nimport {\n AfterContentInit,\n Directive,\n ElementRef,\n EventEmitter,\n Injectable,\n Input,\n NgModule,\n NgZone,\n OnDestroy,\n Output,\n} from '@angular/core';\nimport {Observable, Subject, Subscription, Observer} from 'rxjs';\nimport {debounceTime} from 'rxjs/operators';\n\n/**\n * Factory that creates a new MutationObserver and allows us to stub it out in unit tests.\n * @docs-private\n */\n@Injectable({providedIn: 'root'})\nexport class MutationObserverFactory {\n create(callback: MutationCallback): MutationObserver | null {\n return typeof MutationObserver === 'undefined' ? null : new MutationObserver(callback);\n }\n}\n\n\n/** An injectable service that allows watching elements for changes to their content. */\n@Injectable({providedIn: 'root'})\nexport class ContentObserver implements OnDestroy {\n /** Keeps track of the existing MutationObservers so they can be reused. */\n private _observedElements = new Map<Element, {\n observer: MutationObserver | null,\n stream: Subject<MutationRecord[]>,\n count: number\n }>();\n\n constructor(private _mutationObserverFactory: MutationObserverFactory) {}\n\n ngOnDestroy() {\n this._observedElements.forEach((_, element) => this._cleanupObserver(element));\n }\n\n /**\n * Observe content changes on an element.\n * @param element The element to observe for content changes.\n */\n observe(element: Element): Observable<MutationRecord[]>;\n\n /**\n * Observe content changes on an element.\n * @param element The element to observe for content changes.\n */\n observe(element: ElementRef<Element>): Observable<MutationRecord[]>;\n\n observe(elementOrRef: Element | ElementRef<Element>): Observable<MutationRecord[]> {\n const element = coerceElement(elementOrRef);\n\n return new Observable((observer: Observer<MutationRecord[]>) => {\n const stream = this._observeElement(element);\n const subscription = stream.subscribe(observer);\n\n return () => {\n subscription.unsubscribe();\n this._unobserveElement(element);\n };\n });\n }\n\n /**\n * Observes the given element by using the existing MutationObserver if available, or creating a\n * new one if not.\n */\n private _observeElement(element: Element): Subject<MutationRecord[]> {\n if (!this._observedElements.has(element)) {\n const stream = new Subject<MutationRecord[]>();\n const observer = this._mutationObserverFactory.create(mutations => stream.next(mutations));\n if (observer) {\n observer.observe(element, {\n characterData: true,\n childList: true,\n subtree: true\n });\n }\n this._observedElements.set(element, {observer, stream, count: 1});\n } else {\n this._observedElements.get(element)!.count++;\n }\n return this._observedElements.get(element)!.stream;\n }\n\n /**\n * Un-observes the given element and cleans up the underlying MutationObserver if nobody else is\n * observing this element.\n */\n private _unobserveElement(element: Element) {\n if (this._observedElements.has(element)) {\n this._observedElements.get(element)!.count--;\n if (!this._observedElements.get(element)!.count) {\n this._cleanupObserver(element);\n }\n }\n }\n\n /** Clean up the underlying MutationObserver for the specified element. */\n private _cleanupObserver(element: Element) {\n if (this._observedElements.has(element)) {\n const {observer, stream} = this._observedElements.get(element)!;\n if (observer) {\n observer.disconnect();\n }\n stream.complete();\n this._observedElements.delete(element);\n }\n }\n}\n\n\n/**\n * Directive that triggers a callback whenever the content of\n * its associated element has changed.\n */\n@Directive({\n selector: '[cdkObserveContent]',\n exportAs: 'cdkObserveContent',\n})\nexport class CdkObserveContent implements AfterContentInit, OnDestroy {\n /** Event emitted for each change in the element's content. */\n @Output('cdkObserveContent') event = new EventEmitter<MutationRecord[]>();\n\n /**\n * Whether observing content is disabled. This option can be used\n * to disconnect the underlying MutationObserver until it is needed.\n */\n @Input('cdkObserveContentDisabled')\n get disabled() { return this._disabled; }\n set disabled(value: any) {\n this._disabled = coerceBooleanProperty(value);\n this._disabled ? this._unsubscribe() : this._subscribe();\n }\n private _disabled = false;\n\n /** Debounce interval for emitting the changes. */\n @Input()\n get debounce(): number { return this._debounce; }\n set debounce(value: number) {\n this._debounce = coerceNumberProperty(value);\n this._subscribe();\n }\n private _debounce: number;\n\n private _currentSubscription: Subscription | null = null;\n\n constructor(private _contentObserver: ContentObserver,\n private _elementRef: ElementRef<HTMLElement>,\n private _ngZone: NgZone) {}\n\n ngAfterContentInit() {\n if (!this._currentSubscription && !this.disabled) {\n this._subscribe();\n }\n }\n\n ngOnDestroy() {\n this._unsubscribe();\n }\n\n private _subscribe() {\n this._unsubscribe();\n const stream = this._contentObserver.observe(this._elementRef);\n\n // TODO(mmalerba): We shouldn't be emitting on this @Output() outside the zone.\n // Consider brining it back inside the zone next time we're making breaking changes.\n // Bringing it back inside can cause things like infinite change detection loops and changed\n // after checked errors if people's code isn't handling it properly.\n this._ngZone.runOutsideAngular(() => {\n this._currentSubscription =\n (this.debounce ? stream.pipe(debounceTime(this.debounce)) : stream).subscribe(this.event);\n });\n }\n\n private _unsubscribe() {\n if (this._currentSubscription) {\n this._currentSubscription.unsubscribe();\n }\n }\n}\n\n\n@NgModule({\n exports: [CdkObserveContent],\n declarations: [CdkObserveContent],\n providers: [MutationObserverFactory]\n})\nexport class ObserversModule {}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AA4BA,AAAA,IAAA,uBAAA,kBAAA,YAAA;IAAA,SAAA,uBAAA,GAAA;KAKC;;;;;IAHC,uBAAF,CAAA,SAAA,CAAA,MAAQ;;;;IAAN,UAAO,QAA0B,EAAnC;QACI,OAAO,OAAO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 @@ OverlayRef = /** @class */ (function () {
|
|
|
916
916
|
this._attachments = new Subject();
|
|
917
917
|
this._detachments = new Subject();
|
|
918
918
|
this._locationChanges = Subscription.EMPTY;
|
|
919
|
-
this._keydownEventsObservable = Observable
|
|
919
|
+
this._keydownEventsObservable = new Observable(function (observer) {
|
|
920
920
|
/** @type {?} */
|
|
921
921
|
var subscription = _this._keydownEvents.subscribe(observer);
|
|
922
922
|
_this._keydownEventSubscriptions++;
|
|
@@ -1184,13 +1184,13 @@ OverlayRef = /** @class */ (function () {
|
|
|
1184
1184
|
function () {
|
|
1185
1185
|
return this._keydownEventsObservable;
|
|
1186
1186
|
};
|
|
1187
|
-
/** Gets the
|
|
1187
|
+
/** Gets the current overlay configuration, which is immutable. */
|
|
1188
1188
|
/**
|
|
1189
|
-
* Gets the
|
|
1189
|
+
* Gets the current overlay configuration, which is immutable.
|
|
1190
1190
|
* @return {?}
|
|
1191
1191
|
*/
|
|
1192
1192
|
OverlayRef.prototype.getConfig = /**
|
|
1193
|
-
* Gets the
|
|
1193
|
+
* Gets the current overlay configuration, which is immutable.
|
|
1194
1194
|
* @return {?}
|
|
1195
1195
|
*/
|
|
1196
1196
|
function () {
|
|
@@ -1264,6 +1264,38 @@ OverlayRef = /** @class */ (function () {
|
|
|
1264
1264
|
this._config = __assign({}, this._config, { direction: dir });
|
|
1265
1265
|
this._updateElementDirection();
|
|
1266
1266
|
};
|
|
1267
|
+
/** Add a CSS class or an array of classes to the overlay pane. */
|
|
1268
|
+
/**
|
|
1269
|
+
* Add a CSS class or an array of classes to the overlay pane.
|
|
1270
|
+
* @param {?} classes
|
|
1271
|
+
* @return {?}
|
|
1272
|
+
*/
|
|
1273
|
+
OverlayRef.prototype.addPanelClass = /**
|
|
1274
|
+
* Add a CSS class or an array of classes to the overlay pane.
|
|
1275
|
+
* @param {?} classes
|
|
1276
|
+
* @return {?}
|
|
1277
|
+
*/
|
|
1278
|
+
function (classes) {
|
|
1279
|
+
if (this._pane) {
|
|
1280
|
+
this._toggleClasses(this._pane, classes, true);
|
|
1281
|
+
}
|
|
1282
|
+
};
|
|
1283
|
+
/** Remove a CSS class or an array of classes from the overlay pane. */
|
|
1284
|
+
/**
|
|
1285
|
+
* Remove a CSS class or an array of classes from the overlay pane.
|
|
1286
|
+
* @param {?} classes
|
|
1287
|
+
* @return {?}
|
|
1288
|
+
*/
|
|
1289
|
+
OverlayRef.prototype.removePanelClass = /**
|
|
1290
|
+
* Remove a CSS class or an array of classes from the overlay pane.
|
|
1291
|
+
* @param {?} classes
|
|
1292
|
+
* @return {?}
|
|
1293
|
+
*/
|
|
1294
|
+
function (classes) {
|
|
1295
|
+
if (this._pane) {
|
|
1296
|
+
this._toggleClasses(this._pane, classes, false);
|
|
1297
|
+
}
|
|
1298
|
+
};
|
|
1267
1299
|
/**
|
|
1268
1300
|
* Returns the layout direction of the overlay panel.
|
|
1269
1301
|
*/
|
|
@@ -1614,7 +1646,7 @@ FlexibleConnectedPositionStrategy = /** @class */ (function () {
|
|
|
1614
1646
|
/**
|
|
1615
1647
|
* Observable sequence of position changes.
|
|
1616
1648
|
*/
|
|
1617
|
-
this.positionChanges = Observable
|
|
1649
|
+
this.positionChanges = new Observable(function (observer) {
|
|
1618
1650
|
/** @type {?} */
|
|
1619
1651
|
var subscription = _this._positionChanges.subscribe(observer);
|
|
1620
1652
|
_this._positionChangeSubscriptions++;
|
|
@@ -1734,7 +1766,7 @@ FlexibleConnectedPositionStrategy = /** @class */ (function () {
|
|
|
1734
1766
|
// the overlay relative to the origin.
|
|
1735
1767
|
// We use the viewport rect to determine whether a position would go off-screen.
|
|
1736
1768
|
this._viewportRect = this._getNarrowedViewportRect();
|
|
1737
|
-
this._originRect = this.
|
|
1769
|
+
this._originRect = this._getOriginRect();
|
|
1738
1770
|
this._overlayRect = this._pane.getBoundingClientRect();
|
|
1739
1771
|
/** @type {?} */
|
|
1740
1772
|
var originRect = this._originRect;
|
|
@@ -1890,7 +1922,7 @@ FlexibleConnectedPositionStrategy = /** @class */ (function () {
|
|
|
1890
1922
|
*/
|
|
1891
1923
|
function () {
|
|
1892
1924
|
if (!this._isDisposed && (!this._platform || this._platform.isBrowser)) {
|
|
1893
|
-
this._originRect = this.
|
|
1925
|
+
this._originRect = this._getOriginRect();
|
|
1894
1926
|
this._overlayRect = this._pane.getBoundingClientRect();
|
|
1895
1927
|
this._viewportRect = this._getNarrowedViewportRect();
|
|
1896
1928
|
/** @type {?} */
|
|
@@ -2062,25 +2094,34 @@ FlexibleConnectedPositionStrategy = /** @class */ (function () {
|
|
|
2062
2094
|
return (/** @type {?} */ (this));
|
|
2063
2095
|
};
|
|
2064
2096
|
/**
|
|
2065
|
-
* Sets the origin
|
|
2066
|
-
*
|
|
2097
|
+
* Sets the origin, relative to which to position the overlay.
|
|
2098
|
+
* Using an element origin is useful for building components that need to be positioned
|
|
2099
|
+
* relatively to a trigger (e.g. dropdown menus or tooltips), whereas using a point can be
|
|
2100
|
+
* used for cases like contextual menus which open relative to the user's pointer.
|
|
2101
|
+
* @param origin Reference to the new origin.
|
|
2067
2102
|
*/
|
|
2068
2103
|
/**
|
|
2069
|
-
* Sets the origin
|
|
2104
|
+
* Sets the origin, relative to which to position the overlay.
|
|
2105
|
+
* Using an element origin is useful for building components that need to be positioned
|
|
2106
|
+
* relatively to a trigger (e.g. dropdown menus or tooltips), whereas using a point can be
|
|
2107
|
+
* used for cases like contextual menus which open relative to the user's pointer.
|
|
2070
2108
|
* @template THIS
|
|
2071
2109
|
* @this {THIS}
|
|
2072
|
-
* @param {?} origin Reference to the new origin
|
|
2110
|
+
* @param {?} origin Reference to the new origin.
|
|
2073
2111
|
* @return {THIS}
|
|
2074
2112
|
*/
|
|
2075
2113
|
FlexibleConnectedPositionStrategy.prototype.setOrigin = /**
|
|
2076
|
-
* Sets the origin
|
|
2114
|
+
* Sets the origin, relative to which to position the overlay.
|
|
2115
|
+
* Using an element origin is useful for building components that need to be positioned
|
|
2116
|
+
* relatively to a trigger (e.g. dropdown menus or tooltips), whereas using a point can be
|
|
2117
|
+
* used for cases like contextual menus which open relative to the user's pointer.
|
|
2077
2118
|
* @template THIS
|
|
2078
2119
|
* @this {THIS}
|
|
2079
|
-
* @param {?} origin Reference to the new origin
|
|
2120
|
+
* @param {?} origin Reference to the new origin.
|
|
2080
2121
|
* @return {THIS}
|
|
2081
2122
|
*/
|
|
2082
2123
|
function (origin) {
|
|
2083
|
-
(/** @type {?} */ (this))._origin = origin
|
|
2124
|
+
(/** @type {?} */ (this))._origin = origin;
|
|
2084
2125
|
return (/** @type {?} */ (this));
|
|
2085
2126
|
};
|
|
2086
2127
|
/**
|
|
@@ -2548,7 +2589,7 @@ FlexibleConnectedPositionStrategy = /** @class */ (function () {
|
|
|
2548
2589
|
if (position.overlayY === 'top') {
|
|
2549
2590
|
// Overlay is opening "downward" and thus is bound by the bottom viewport edge.
|
|
2550
2591
|
top = origin.y;
|
|
2551
|
-
height = viewport.
|
|
2592
|
+
height = viewport.height - top + this._viewportMargin;
|
|
2552
2593
|
}
|
|
2553
2594
|
else if (position.overlayY === 'bottom') {
|
|
2554
2595
|
// Overlay is opening "upward" and thus is bound by the top viewport edge. We need to add
|
|
@@ -2727,6 +2768,7 @@ FlexibleConnectedPositionStrategy = /** @class */ (function () {
|
|
|
2727
2768
|
bottom: '',
|
|
2728
2769
|
right: '',
|
|
2729
2770
|
position: '',
|
|
2771
|
+
transform: '',
|
|
2730
2772
|
})));
|
|
2731
2773
|
};
|
|
2732
2774
|
/** Sets positioning styles to the overlay element. */
|
|
@@ -2907,7 +2949,7 @@ FlexibleConnectedPositionStrategy = /** @class */ (function () {
|
|
|
2907
2949
|
function () {
|
|
2908
2950
|
// Note: needs fresh rects since the position could've changed.
|
|
2909
2951
|
/** @type {?} */
|
|
2910
|
-
var originBounds = this.
|
|
2952
|
+
var originBounds = this._getOriginRect();
|
|
2911
2953
|
/** @type {?} */
|
|
2912
2954
|
var overlayBounds = this._pane.getBoundingClientRect();
|
|
2913
2955
|
// TODO(jelbourn): instead of needing all of the client rects for these scrolling containers
|
|
@@ -3097,6 +3139,36 @@ FlexibleConnectedPositionStrategy = /** @class */ (function () {
|
|
|
3097
3139
|
this._appliedPanelClasses = [];
|
|
3098
3140
|
}
|
|
3099
3141
|
};
|
|
3142
|
+
/** Returns the ClientRect of the current origin. */
|
|
3143
|
+
/**
|
|
3144
|
+
* Returns the ClientRect of the current origin.
|
|
3145
|
+
* @private
|
|
3146
|
+
* @return {?}
|
|
3147
|
+
*/
|
|
3148
|
+
FlexibleConnectedPositionStrategy.prototype._getOriginRect = /**
|
|
3149
|
+
* Returns the ClientRect of the current origin.
|
|
3150
|
+
* @private
|
|
3151
|
+
* @return {?}
|
|
3152
|
+
*/
|
|
3153
|
+
function () {
|
|
3154
|
+
/** @type {?} */
|
|
3155
|
+
var origin = this._origin;
|
|
3156
|
+
if (origin instanceof ElementRef) {
|
|
3157
|
+
return origin.nativeElement.getBoundingClientRect();
|
|
3158
|
+
}
|
|
3159
|
+
if (origin instanceof HTMLElement) {
|
|
3160
|
+
return origin.getBoundingClientRect();
|
|
3161
|
+
}
|
|
3162
|
+
// If the origin is a point, return a client rect as if it was a 0x0 element at the point.
|
|
3163
|
+
return {
|
|
3164
|
+
top: origin.y,
|
|
3165
|
+
bottom: origin.y,
|
|
3166
|
+
left: origin.x,
|
|
3167
|
+
right: origin.x,
|
|
3168
|
+
height: 0,
|
|
3169
|
+
width: 0
|
|
3170
|
+
};
|
|
3171
|
+
};
|
|
3100
3172
|
return FlexibleConnectedPositionStrategy;
|
|
3101
3173
|
}());
|
|
3102
3174
|
/**
|
|
@@ -3908,20 +3980,20 @@ var OverlayPositionBuilder = /** @class */ (function () {
|
|
|
3908
3980
|
};
|
|
3909
3981
|
/**
|
|
3910
3982
|
* Creates a flexible position strategy.
|
|
3911
|
-
* @param
|
|
3983
|
+
* @param origin Origin relative to which to position the overlay.
|
|
3912
3984
|
*/
|
|
3913
3985
|
/**
|
|
3914
3986
|
* Creates a flexible position strategy.
|
|
3915
|
-
* @param {?}
|
|
3987
|
+
* @param {?} origin Origin relative to which to position the overlay.
|
|
3916
3988
|
* @return {?}
|
|
3917
3989
|
*/
|
|
3918
3990
|
OverlayPositionBuilder.prototype.flexibleConnectedTo = /**
|
|
3919
3991
|
* Creates a flexible position strategy.
|
|
3920
|
-
* @param {?}
|
|
3992
|
+
* @param {?} origin Origin relative to which to position the overlay.
|
|
3921
3993
|
* @return {?}
|
|
3922
3994
|
*/
|
|
3923
|
-
function (
|
|
3924
|
-
return new FlexibleConnectedPositionStrategy(
|
|
3995
|
+
function (origin) {
|
|
3996
|
+
return new FlexibleConnectedPositionStrategy(origin, this._viewportRuler, this._document, this._platform, this._overlayContainer);
|
|
3925
3997
|
};
|
|
3926
3998
|
OverlayPositionBuilder.decorators = [
|
|
3927
3999
|
{ type: Injectable, args: [{ providedIn: 'root' },] },
|
|
@@ -4359,7 +4431,10 @@ var CdkConnectedOverlay = /** @class */ (function () {
|
|
|
4359
4431
|
* @return {?}
|
|
4360
4432
|
*/
|
|
4361
4433
|
function () {
|
|
4362
|
-
this.
|
|
4434
|
+
if (this._overlayRef) {
|
|
4435
|
+
this._overlayRef.dispose();
|
|
4436
|
+
}
|
|
4437
|
+
this._backdropSubscription.unsubscribe();
|
|
4363
4438
|
};
|
|
4364
4439
|
/**
|
|
4365
4440
|
* @param {?} changes
|
|
@@ -4372,6 +4447,12 @@ var CdkConnectedOverlay = /** @class */ (function () {
|
|
|
4372
4447
|
function (changes) {
|
|
4373
4448
|
if (this._position) {
|
|
4374
4449
|
this._updatePositionStrategy(this._position);
|
|
4450
|
+
this._overlayRef.updateSize({
|
|
4451
|
+
width: this.width,
|
|
4452
|
+
minWidth: this.minWidth,
|
|
4453
|
+
height: this.height,
|
|
4454
|
+
minHeight: this.minHeight,
|
|
4455
|
+
});
|
|
4375
4456
|
if (changes['origin'] && this.open) {
|
|
4376
4457
|
this._position.apply();
|
|
4377
4458
|
}
|
|
@@ -4515,12 +4596,7 @@ var CdkConnectedOverlay = /** @class */ (function () {
|
|
|
4515
4596
|
}
|
|
4516
4597
|
else {
|
|
4517
4598
|
// Update the overlay size, in case the directive's inputs have changed
|
|
4518
|
-
this._overlayRef.
|
|
4519
|
-
width: this.width,
|
|
4520
|
-
minWidth: this.minWidth,
|
|
4521
|
-
height: this.height,
|
|
4522
|
-
minHeight: this.minHeight,
|
|
4523
|
-
});
|
|
4599
|
+
this._overlayRef.getConfig().hasBackdrop = this.hasBackdrop;
|
|
4524
4600
|
}
|
|
4525
4601
|
if (!this._overlayRef.hasAttached()) {
|
|
4526
4602
|
this._overlayRef.attach(this._templatePortal);
|
|
@@ -4531,6 +4607,9 @@ var CdkConnectedOverlay = /** @class */ (function () {
|
|
|
4531
4607
|
_this.backdropClick.emit(event);
|
|
4532
4608
|
});
|
|
4533
4609
|
}
|
|
4610
|
+
else {
|
|
4611
|
+
this._backdropSubscription.unsubscribe();
|
|
4612
|
+
}
|
|
4534
4613
|
};
|
|
4535
4614
|
/** Detaches the overlay and unsubscribes to backdrop clicks if backdrop exists */
|
|
4536
4615
|
/**
|
|
@@ -4550,23 +4629,6 @@ var CdkConnectedOverlay = /** @class */ (function () {
|
|
|
4550
4629
|
}
|
|
4551
4630
|
this._backdropSubscription.unsubscribe();
|
|
4552
4631
|
};
|
|
4553
|
-
/** Destroys the overlay created by this directive. */
|
|
4554
|
-
/**
|
|
4555
|
-
* Destroys the overlay created by this directive.
|
|
4556
|
-
* @private
|
|
4557
|
-
* @return {?}
|
|
4558
|
-
*/
|
|
4559
|
-
CdkConnectedOverlay.prototype._destroyOverlay = /**
|
|
4560
|
-
* Destroys the overlay created by this directive.
|
|
4561
|
-
* @private
|
|
4562
|
-
* @return {?}
|
|
4563
|
-
*/
|
|
4564
|
-
function () {
|
|
4565
|
-
if (this._overlayRef) {
|
|
4566
|
-
this._overlayRef.dispose();
|
|
4567
|
-
}
|
|
4568
|
-
this._backdropSubscription.unsubscribe();
|
|
4569
|
-
};
|
|
4570
4632
|
CdkConnectedOverlay.decorators = [
|
|
4571
4633
|
{ type: Directive, args: [{
|
|
4572
4634
|
selector: '[cdk-connected-overlay], [connected-overlay], [cdkConnectedOverlay]',
|