@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.
Files changed (228) hide show
  1. package/LICENSE +1 -1
  2. package/_a11y.scss +1 -1
  3. package/a11y/typings/focus-monitor/focus-monitor.d.ts +0 -1
  4. package/a11y/typings/focus-trap/focus-trap.d.ts +2 -0
  5. package/a11y/typings/index.metadata.json +1 -1
  6. package/bundles/cdk-a11y.umd.js +30 -24
  7. package/bundles/cdk-a11y.umd.js.map +1 -1
  8. package/bundles/cdk-a11y.umd.min.js +1 -1
  9. package/bundles/cdk-a11y.umd.min.js.map +1 -1
  10. package/bundles/cdk-coercion.umd.js +20 -4
  11. package/bundles/cdk-coercion.umd.js.map +1 -1
  12. package/bundles/cdk-coercion.umd.min.js +1 -1
  13. package/bundles/cdk-coercion.umd.min.js.map +1 -1
  14. package/bundles/cdk-drag-drop.umd.js +3246 -1894
  15. package/bundles/cdk-drag-drop.umd.js.map +1 -1
  16. package/bundles/cdk-drag-drop.umd.min.js +2 -1
  17. package/bundles/cdk-drag-drop.umd.min.js.map +1 -1
  18. package/bundles/cdk-observers.umd.js +2 -2
  19. package/bundles/cdk-observers.umd.js.map +1 -1
  20. package/bundles/cdk-observers.umd.min.js +1 -1
  21. package/bundles/cdk-observers.umd.min.js.map +1 -1
  22. package/bundles/cdk-overlay.umd.js +107 -45
  23. package/bundles/cdk-overlay.umd.js.map +1 -1
  24. package/bundles/cdk-overlay.umd.min.js +2 -2
  25. package/bundles/cdk-overlay.umd.min.js.map +1 -1
  26. package/bundles/cdk-portal.umd.js +3 -3
  27. package/bundles/cdk-portal.umd.js.map +1 -1
  28. package/bundles/cdk-portal.umd.min.js.map +1 -1
  29. package/bundles/cdk-scrolling.umd.js +9 -6
  30. package/bundles/cdk-scrolling.umd.js.map +1 -1
  31. package/bundles/cdk-scrolling.umd.min.js +1 -1
  32. package/bundles/cdk-scrolling.umd.min.js.map +1 -1
  33. package/bundles/cdk-stepper.umd.js +36 -16
  34. package/bundles/cdk-stepper.umd.js.map +1 -1
  35. package/bundles/cdk-stepper.umd.min.js +1 -1
  36. package/bundles/cdk-stepper.umd.min.js.map +1 -1
  37. package/bundles/cdk-table.umd.js +8 -4
  38. package/bundles/cdk-table.umd.js.map +1 -1
  39. package/bundles/cdk-table.umd.min.js +1 -1
  40. package/bundles/cdk-table.umd.min.js.map +1 -1
  41. package/bundles/cdk-text-field.umd.js +47 -22
  42. package/bundles/cdk-text-field.umd.js.map +1 -1
  43. package/bundles/cdk-text-field.umd.min.js +1 -1
  44. package/bundles/cdk-text-field.umd.min.js.map +1 -1
  45. package/bundles/cdk-tree.umd.js +1 -1
  46. package/bundles/cdk-tree.umd.js.map +1 -1
  47. package/bundles/cdk-tree.umd.min.js +1 -1
  48. package/bundles/cdk-tree.umd.min.js.map +1 -1
  49. package/bundles/cdk.umd.js +1 -1
  50. package/bundles/cdk.umd.js.map +1 -1
  51. package/bundles/cdk.umd.min.js +1 -1
  52. package/bundles/cdk.umd.min.js.map +1 -1
  53. package/coercion/typings/element.d.ts +13 -0
  54. package/coercion/typings/index.metadata.json +1 -1
  55. package/coercion/typings/public-api.d.ts +1 -0
  56. package/drag-drop/typings/{drag-handle.d.ts → directives/drag-handle.d.ts} +6 -2
  57. package/drag-drop/typings/{drag-placeholder.d.ts → directives/drag-placeholder.d.ts} +0 -0
  58. package/drag-drop/typings/{drag-preview.d.ts → directives/drag-preview.d.ts} +0 -0
  59. package/drag-drop/typings/directives/drag.d.ts +114 -0
  60. package/{typings/esm5/drag-drop → drag-drop/typings/directives}/drop-list-group.d.ts +3 -0
  61. package/drag-drop/typings/{drop-list.d.ts → directives/drop-list.d.ts} +44 -70
  62. package/drag-drop/typings/drag-drop-registry.d.ts +8 -3
  63. package/drag-drop/typings/drag-drop.d.ts +33 -0
  64. package/drag-drop/typings/drag-events.d.ts +14 -7
  65. package/{typings/esm5/drag-drop/drag.d.ts → drag-drop/typings/drag-ref.d.ts} +162 -86
  66. package/drag-drop/typings/drop-list-container.d.ts +19 -3
  67. package/drag-drop/typings/drop-list-ref.d.ts +238 -0
  68. package/drag-drop/typings/index.d.ts +2 -1
  69. package/drag-drop/typings/index.metadata.json +1 -1
  70. package/drag-drop/typings/public-api.d.ts +16 -6
  71. package/esm2015/a11y.js +30 -20
  72. package/esm2015/a11y.js.map +1 -1
  73. package/esm2015/cdk.js +1 -1
  74. package/esm2015/cdk.js.map +1 -1
  75. package/esm2015/coercion.js +18 -1
  76. package/esm2015/coercion.js.map +1 -1
  77. package/esm2015/drag-drop.js +2281 -1289
  78. package/esm2015/drag-drop.js.map +1 -1
  79. package/esm2015/observers.js +3 -3
  80. package/esm2015/observers.js.map +1 -1
  81. package/esm2015/overlay.js +75 -31
  82. package/esm2015/overlay.js.map +1 -1
  83. package/esm2015/portal.js +1 -1
  84. package/esm2015/portal.js.map +1 -1
  85. package/esm2015/scrolling.js +9 -6
  86. package/esm2015/scrolling.js.map +1 -1
  87. package/esm2015/stepper.js +30 -16
  88. package/esm2015/stepper.js.map +1 -1
  89. package/esm2015/table.js +8 -4
  90. package/esm2015/table.js.map +1 -1
  91. package/esm2015/text-field.js +31 -19
  92. package/esm2015/text-field.js.map +1 -1
  93. package/esm2015/tree.js +2 -2
  94. package/esm2015/tree.js.map +1 -1
  95. package/esm5/a11y.es5.js +31 -25
  96. package/esm5/a11y.es5.js.map +1 -1
  97. package/esm5/cdk.es5.js +1 -1
  98. package/esm5/cdk.es5.js.map +1 -1
  99. package/esm5/coercion.es5.js +18 -1
  100. package/esm5/coercion.es5.js.map +1 -1
  101. package/esm5/drag-drop.es5.js +3247 -1899
  102. package/esm5/drag-drop.es5.js.map +1 -1
  103. package/esm5/observers.es5.js +3 -3
  104. package/esm5/observers.es5.js.map +1 -1
  105. package/esm5/overlay.es5.js +107 -45
  106. package/esm5/overlay.es5.js.map +1 -1
  107. package/esm5/portal.es5.js +3 -3
  108. package/esm5/portal.es5.js.map +1 -1
  109. package/esm5/scrolling.es5.js +9 -6
  110. package/esm5/scrolling.es5.js.map +1 -1
  111. package/esm5/stepper.es5.js +36 -17
  112. package/esm5/stepper.es5.js.map +1 -1
  113. package/esm5/table.es5.js +8 -4
  114. package/esm5/table.es5.js.map +1 -1
  115. package/esm5/text-field.es5.js +44 -19
  116. package/esm5/text-field.es5.js.map +1 -1
  117. package/esm5/tree.es5.js +2 -2
  118. package/esm5/tree.es5.js.map +1 -1
  119. package/overlay/typings/index.metadata.json +1 -1
  120. package/overlay/typings/overlay-directives.d.ts +0 -2
  121. package/overlay/typings/overlay-ref.d.ts +5 -1
  122. package/overlay/typings/position/flexible-connected-position-strategy.d.ts +17 -4
  123. package/overlay/typings/position/overlay-position-builder.d.ts +3 -3
  124. package/package.json +4 -4
  125. package/portal/typings/portal.d.ts +1 -1
  126. package/schematics/migration.json +5 -0
  127. package/schematics/ng-generate/drag-drop/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.ts +2 -2
  128. package/schematics/ng-update/index.d.ts +2 -0
  129. package/schematics/ng-update/index.js +5 -0
  130. package/schematics/ng-update/index.js.map +1 -1
  131. package/schematics/ng-update/target-version.d.ts +7 -1
  132. package/schematics/ng-update/target-version.js +10 -0
  133. package/schematics/ng-update/target-version.js.map +1 -1
  134. package/schematics/ng-update/upgrade-data.js +2 -1
  135. package/schematics/ng-update/upgrade-data.js.map +1 -1
  136. package/schematics/ng-update/upgrade-rules/index.js +3 -2
  137. package/schematics/ng-update/upgrade-rules/index.js.map +1 -1
  138. package/schematics/utils/ast/ng-module-imports.d.ts +1 -1
  139. package/schematics/utils/ast/ng-module-imports.js +25 -13
  140. package/schematics/utils/ast/ng-module-imports.js.map +1 -1
  141. package/schematics/utils/get-project.js +2 -1
  142. package/schematics/utils/get-project.js.map +1 -1
  143. package/schematics/utils/parse5-element.js +3 -2
  144. package/schematics/utils/parse5-element.js.map +1 -1
  145. package/schematics/utils/project-targets.js +2 -1
  146. package/schematics/utils/project-targets.js.map +1 -1
  147. package/schematics/utils/version-agnostic-typescript.js +3 -2
  148. package/schematics/utils/version-agnostic-typescript.js.map +1 -1
  149. package/stepper/typings/index.metadata.json +1 -1
  150. package/stepper/typings/stepper.d.ts +14 -2
  151. package/text-field/typings/autosize.d.ts +6 -0
  152. package/text-field/typings/index.metadata.json +1 -1
  153. package/tree/typings/control/base-tree-control.d.ts +1 -1
  154. package/tree/typings/control/nested-tree-control.d.ts +2 -2
  155. package/tree/typings/control/tree-control.d.ts +1 -1
  156. package/typings/a11y/focus-monitor/focus-monitor.d.ts +0 -1
  157. package/typings/a11y/focus-trap/focus-trap.d.ts +2 -0
  158. package/typings/a11y/index.metadata.json +1 -1
  159. package/typings/coercion/element.d.ts +13 -0
  160. package/typings/coercion/index.metadata.json +1 -1
  161. package/typings/coercion/public-api.d.ts +1 -0
  162. package/typings/drag-drop/{drag-handle.d.ts → directives/drag-handle.d.ts} +6 -2
  163. package/typings/drag-drop/{drag-placeholder.d.ts → directives/drag-placeholder.d.ts} +0 -0
  164. package/typings/drag-drop/{drag-preview.d.ts → directives/drag-preview.d.ts} +0 -0
  165. package/typings/drag-drop/directives/drag.d.ts +114 -0
  166. package/typings/drag-drop/{drop-list-group.d.ts → directives/drop-list-group.d.ts} +3 -0
  167. package/typings/{esm5/drag-drop → drag-drop/directives}/drop-list.d.ts +44 -70
  168. package/typings/drag-drop/drag-drop-registry.d.ts +8 -3
  169. package/typings/drag-drop/drag-drop.d.ts +33 -0
  170. package/typings/drag-drop/drag-events.d.ts +14 -7
  171. package/typings/drag-drop/{drag.d.ts → drag-ref.d.ts} +162 -86
  172. package/typings/drag-drop/drop-list-container.d.ts +19 -3
  173. package/typings/drag-drop/drop-list-ref.d.ts +238 -0
  174. package/typings/drag-drop/index.d.ts +2 -1
  175. package/typings/drag-drop/index.metadata.json +1 -1
  176. package/typings/drag-drop/public-api.d.ts +16 -6
  177. package/typings/esm5/a11y/focus-monitor/focus-monitor.d.ts +0 -1
  178. package/typings/esm5/a11y/focus-trap/focus-trap.d.ts +2 -0
  179. package/typings/esm5/a11y/index.metadata.json +1 -1
  180. package/typings/esm5/coercion/element.d.ts +13 -0
  181. package/typings/esm5/coercion/index.metadata.json +1 -1
  182. package/typings/esm5/coercion/public-api.d.ts +1 -0
  183. package/typings/esm5/drag-drop/{drag-handle.d.ts → directives/drag-handle.d.ts} +6 -2
  184. package/typings/esm5/drag-drop/{drag-placeholder.d.ts → directives/drag-placeholder.d.ts} +0 -0
  185. package/typings/esm5/drag-drop/{drag-preview.d.ts → directives/drag-preview.d.ts} +0 -0
  186. package/typings/esm5/drag-drop/directives/drag.d.ts +114 -0
  187. package/{drag-drop/typings → typings/esm5/drag-drop/directives}/drop-list-group.d.ts +3 -0
  188. package/typings/{drag-drop → esm5/drag-drop/directives}/drop-list.d.ts +44 -70
  189. package/typings/esm5/drag-drop/drag-drop-registry.d.ts +8 -3
  190. package/typings/esm5/drag-drop/drag-drop.d.ts +33 -0
  191. package/typings/esm5/drag-drop/drag-events.d.ts +14 -7
  192. package/{drag-drop/typings/drag.d.ts → typings/esm5/drag-drop/drag-ref.d.ts} +162 -86
  193. package/typings/esm5/drag-drop/drop-list-container.d.ts +19 -3
  194. package/typings/esm5/drag-drop/drop-list-ref.d.ts +238 -0
  195. package/typings/esm5/drag-drop/index.d.ts +2 -1
  196. package/typings/esm5/drag-drop/index.metadata.json +1 -1
  197. package/typings/esm5/drag-drop/public-api.d.ts +16 -6
  198. package/typings/esm5/index.metadata.json +1 -1
  199. package/typings/esm5/overlay/index.metadata.json +1 -1
  200. package/typings/esm5/overlay/overlay-directives.d.ts +0 -2
  201. package/typings/esm5/overlay/overlay-ref.d.ts +5 -1
  202. package/typings/esm5/overlay/position/flexible-connected-position-strategy.d.ts +17 -4
  203. package/typings/esm5/overlay/position/overlay-position-builder.d.ts +3 -3
  204. package/typings/esm5/portal/portal.d.ts +1 -1
  205. package/typings/esm5/stepper/index.metadata.json +1 -1
  206. package/typings/esm5/stepper/stepper.d.ts +14 -2
  207. package/typings/esm5/text-field/autosize.d.ts +6 -0
  208. package/typings/esm5/text-field/index.metadata.json +1 -1
  209. package/typings/esm5/tree/control/base-tree-control.d.ts +1 -1
  210. package/typings/esm5/tree/control/nested-tree-control.d.ts +2 -2
  211. package/typings/esm5/tree/control/tree-control.d.ts +1 -1
  212. package/typings/index.metadata.json +1 -1
  213. package/typings/overlay/index.metadata.json +1 -1
  214. package/typings/overlay/overlay-directives.d.ts +0 -2
  215. package/typings/overlay/overlay-ref.d.ts +5 -1
  216. package/typings/overlay/position/flexible-connected-position-strategy.d.ts +17 -4
  217. package/typings/overlay/position/overlay-position-builder.d.ts +3 -3
  218. package/typings/portal/portal.d.ts +1 -1
  219. package/typings/schematics/ng-update/index.d.ts +2 -0
  220. package/typings/schematics/ng-update/target-version.d.ts +7 -1
  221. package/typings/schematics/utils/ast/ng-module-imports.d.ts +1 -1
  222. package/typings/stepper/index.metadata.json +1 -1
  223. package/typings/stepper/stepper.d.ts +14 -2
  224. package/typings/text-field/autosize.d.ts +6 -0
  225. package/typings/text-field/index.metadata.json +1 -1
  226. package/typings/tree/control/base-tree-control.d.ts +1 -1
  227. package/typings/tree/control/nested-tree-control.d.ts +2 -2
  228. package/typings/tree/control/tree-control.d.ts +1 -1
@@ -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';
@@ -57,8 +57,8 @@ class ContentObserver {
57
57
  */
58
58
  observe(elementOrRef) {
59
59
  /** @type {?} */
60
- const element = elementOrRef instanceof ElementRef ? elementOrRef.nativeElement : elementOrRef;
61
- return Observable.create((observer) => {
60
+ const element = coerceElement(elementOrRef);
61
+ return new Observable((observer) => {
62
62
  /** @type {?} */
63
63
  const stream = this._observeElement(element);
64
64
  /** @type {?} */
@@ -1 +1 @@
1
- {"version":3,"file":"observers.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":";;;;;;;;;;;;;;;;;;;;AA6BA,AAAA,MAAa,uBAAuB,CAApC;;;;;IACE,MAAM,CAAC,QAA0B,EAAnC;QACI,OAAO,OAAO,gBAAgB,KAAK,WAAW,GAAG,IAAI,GAAG,IAAI,gBAAgB,CAAC,QAAQ,CAAC,CAAC;KACxF;;;IAJH,EAAA,IAAA,EAAC,UAAU,EAAX,IAAA,EAAA,CAAY,EAAC,UAAU,EAAE,MAAM,EAAC,EAAhC,EAAA;;;;;;AAUA,AAAA,MAAa,eAAe,CAA5B;;;;IAQE,WAAF,CAAsB,wBAAiD,EAAvE;QAAsB,IAAtB,CAAA,wBAA8C,GAAxB,wBAAwB,CAAyB;;;;QAN7D,IAAV,CAAA,iBAA2B,GAAG,IAAI,GAAG,EAI/B,CAAC;KAEoE;;;;IAEzE,WAAW,GAAb;QAC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AI,CAAC,QAAQ,CAAC,CAAC,GAAG,MAAM,EAAE,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SAC/F,CAAC,CAAC;KACJ;;;;;IAEO,YAAY,GAAtB;QACI,IAAI,IAAI,CAAC,oBAAoB,EAAE;YAC7B,IAAI,CAAC,oBAAoB,CAAC,WAAW,EAAE,CAAC;SACzC;KACF;;;IA/DH,EAAA,IAAA,EAAC,SAAS,EAAV,IAAA,EAAA,CAAW;gBACT,QAAQ,EAAE,qBAAqB;gBAC/B,QAAQ,EAAE,mBAAmB;aAC9B,EAAD,EAAA;;;;IA4BA,EAAA,IAAA,EAAwC,eAAe,EAAvD;IAtJA,EAAA,IAAA,EAAE,UAAU,EAAZ;IAKA,EAAA,IAAA,EAAE,MAAM,EAAR;;;IAwHA,KAAA,EAAA,CAAA,EAAA,IAAA,EAAG,MAAM,EAAT,IAAA,EAAA,CAAU,mBAAmB,EAA7B,EAAA,CAAA;IAMA,QAAA,EAAA,CAAA,EAAA,IAAA,EAAG,KAAK,EAAR,IAAA,EAAA,CAAS,2BAA2B,EAApC,EAAA,CAAA;IASA,QAAA,EAAA,CAAA,EAAA,IAAA,EAAG,KAAK,EAAR,CAAA;;AAmDA,MAAa,eAAe,CAA5B;;;IALA,EAAA,IAAA,EAAC,QAAQ,EAAT,IAAA,EAAA,CAAU;gBACR,OAAO,EAAE,CAAC,iBAAiB,CAAC;gBAC5B,YAAY,EAAE,CAAC,iBAAiB,CAAC;gBACjC,SAAS,EAAE,CAAC,uBAAuB,CAAC;aACrC,EAAD,EAAA;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"observers.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":";;;;;;;;;;;;;;;;;;;;AA6BA,AAAA,MAAa,uBAAuB,CAApC;;;;;IACE,MAAM,CAAC,QAA0B,EAAnC;QACI,OAAO,OAAO,gBAAgB,KAAK,WAAW,GAAG,IAAI,GAAG,IAAI,gBAAgB,CAAC,QAAQ,CAAC,CAAC;KACxF;;;IAJH,EAAA,IAAA,EAAC,UAAU,EAAX,IAAA,EAAA,CAAY,EAAC,UAAU,EAAE,MAAM,EAAC,EAAhC,EAAA;;;;;;AAUA,AAAA,MAAa,eAAe,CAA5B;;;;IAQE,WAAF,CAAsB,wBAAiD,EAAvE;QAAsB,IAAtB,CAAA,wBAA8C,GAAxB,wBAAwB,CAAyB;;;;QAN7D,IAAV,CAAA,iBAA2B,GAAG,IAAI,GAAG,EAI/B,CAAC;KAEoE;;;;IAEzE,WAAW,GAAb;QACI,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;KAChF;;;;;IAcD,OAAO,CAAC,YAA2C,EAArD;;QACA,MAAU,OAAO,GAAG,aAAa,CAAC,YAAY,CAAC,CAA/C;QAEI,OAAO,IAAI,UAAU,CAAC,CAAC,QAAoC,KAA/D;;YACA,MAAY,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAlD;;YACA,MAAY,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ,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,IAAA,EAAE,UAAU,EAAZ;IAKA,EAAA,IAAA,EAAE,MAAM,EAAR;;;IAwHA,KAAA,EAAA,CAAA,EAAA,IAAA,EAAG,MAAM,EAAT,IAAA,EAAA,CAAU,mBAAmB,EAA7B,EAAA,CAAA;IAMA,QAAA,EAAA,CAAA,EAAA,IAAA,EAAG,KAAK,EAAR,IAAA,EAAA,CAAS,2BAA2B,EAApC,EAAA,CAAA;IASA,QAAA,EAAA,CAAA,EAAA,IAAA,EAAG,KAAK,EAAR,CAAA;;AAmDA,MAAa,eAAe,CAA5B;;;IALA,EAAA,IAAA,EAAC,QAAQ,EAAT,IAAA,EAAA,CAAU;gBACR,OAAO,EAAE,CAAC,iBAAiB,CAAC;gBAC5B,YAAY,EAAE,CAAC,iBAAiB,CAAC;gBACjC,SAAS,EAAE,CAAC,uBAAuB,CAAC;aACrC,EAAD,EAAA;;;;;;;;;;;;;;;"}
@@ -786,7 +786,7 @@ class OverlayRef {
786
786
  this._attachments = new Subject();
787
787
  this._detachments = new Subject();
788
788
  this._locationChanges = Subscription.EMPTY;
789
- this._keydownEventsObservable = Observable.create((observer) => {
789
+ this._keydownEventsObservable = new Observable((observer) => {
790
790
  /** @type {?} */
791
791
  const subscription = this._keydownEvents.subscribe(observer);
792
792
  this._keydownEventSubscriptions++;
@@ -983,7 +983,7 @@ class OverlayRef {
983
983
  return this._keydownEventsObservable;
984
984
  }
985
985
  /**
986
- * Gets the the current overlay configuration, which is immutable.
986
+ * Gets the current overlay configuration, which is immutable.
987
987
  * @return {?}
988
988
  */
989
989
  getConfig() {
@@ -1034,6 +1034,26 @@ class OverlayRef {
1034
1034
  this._config = Object.assign({}, this._config, { direction: dir });
1035
1035
  this._updateElementDirection();
1036
1036
  }
1037
+ /**
1038
+ * Add a CSS class or an array of classes to the overlay pane.
1039
+ * @param {?} classes
1040
+ * @return {?}
1041
+ */
1042
+ addPanelClass(classes) {
1043
+ if (this._pane) {
1044
+ this._toggleClasses(this._pane, classes, true);
1045
+ }
1046
+ }
1047
+ /**
1048
+ * Remove a CSS class or an array of classes from the overlay pane.
1049
+ * @param {?} classes
1050
+ * @return {?}
1051
+ */
1052
+ removePanelClass(classes) {
1053
+ if (this._pane) {
1054
+ this._toggleClasses(this._pane, classes, false);
1055
+ }
1056
+ }
1037
1057
  /**
1038
1058
  * Returns the layout direction of the overlay panel.
1039
1059
  * @return {?}
@@ -1311,7 +1331,7 @@ class FlexibleConnectedPositionStrategy {
1311
1331
  /**
1312
1332
  * Observable sequence of position changes.
1313
1333
  */
1314
- this.positionChanges = Observable.create((observer) => {
1334
+ this.positionChanges = new Observable((observer) => {
1315
1335
  /** @type {?} */
1316
1336
  const subscription = this._positionChanges.subscribe(observer);
1317
1337
  this._positionChangeSubscriptions++;
@@ -1390,7 +1410,7 @@ class FlexibleConnectedPositionStrategy {
1390
1410
  // the overlay relative to the origin.
1391
1411
  // We use the viewport rect to determine whether a position would go off-screen.
1392
1412
  this._viewportRect = this._getNarrowedViewportRect();
1393
- this._originRect = this._origin.getBoundingClientRect();
1413
+ this._originRect = this._getOriginRect();
1394
1414
  this._overlayRect = this._pane.getBoundingClientRect();
1395
1415
  /** @type {?} */
1396
1416
  const originRect = this._originRect;
@@ -1525,7 +1545,7 @@ class FlexibleConnectedPositionStrategy {
1525
1545
  */
1526
1546
  reapplyLastPosition() {
1527
1547
  if (!this._isDisposed && (!this._platform || this._platform.isBrowser)) {
1528
- this._originRect = this._origin.getBoundingClientRect();
1548
+ this._originRect = this._getOriginRect();
1529
1549
  this._overlayRect = this._pane.getBoundingClientRect();
1530
1550
  this._viewportRect = this._getNarrowedViewportRect();
1531
1551
  /** @type {?} */
@@ -1620,14 +1640,17 @@ class FlexibleConnectedPositionStrategy {
1620
1640
  return (/** @type {?} */ (this));
1621
1641
  }
1622
1642
  /**
1623
- * Sets the origin element, relative to which to position the overlay.
1643
+ * Sets the origin, relative to which to position the overlay.
1644
+ * Using an element origin is useful for building components that need to be positioned
1645
+ * relatively to a trigger (e.g. dropdown menus or tooltips), whereas using a point can be
1646
+ * used for cases like contextual menus which open relative to the user's pointer.
1624
1647
  * @template THIS
1625
1648
  * @this {THIS}
1626
- * @param {?} origin Reference to the new origin element.
1649
+ * @param {?} origin Reference to the new origin.
1627
1650
  * @return {THIS}
1628
1651
  */
1629
1652
  setOrigin(origin) {
1630
- (/** @type {?} */ (this))._origin = origin instanceof ElementRef ? origin.nativeElement : origin;
1653
+ (/** @type {?} */ (this))._origin = origin;
1631
1654
  return (/** @type {?} */ (this));
1632
1655
  }
1633
1656
  /**
@@ -1949,7 +1972,7 @@ class FlexibleConnectedPositionStrategy {
1949
1972
  if (position.overlayY === 'top') {
1950
1973
  // Overlay is opening "downward" and thus is bound by the bottom viewport edge.
1951
1974
  top = origin.y;
1952
- height = viewport.bottom - origin.y;
1975
+ height = viewport.height - top + this._viewportMargin;
1953
1976
  }
1954
1977
  else if (position.overlayY === 'bottom') {
1955
1978
  // Overlay is opening "upward" and thus is bound by the top viewport edge. We need to add
@@ -2100,6 +2123,7 @@ class FlexibleConnectedPositionStrategy {
2100
2123
  bottom: '',
2101
2124
  right: '',
2102
2125
  position: '',
2126
+ transform: '',
2103
2127
  })));
2104
2128
  }
2105
2129
  /**
@@ -2244,7 +2268,7 @@ class FlexibleConnectedPositionStrategy {
2244
2268
  _getScrollVisibility() {
2245
2269
  // Note: needs fresh rects since the position could've changed.
2246
2270
  /** @type {?} */
2247
- const originBounds = this._origin.getBoundingClientRect();
2271
+ const originBounds = this._getOriginRect();
2248
2272
  /** @type {?} */
2249
2273
  const overlayBounds = this._pane.getBoundingClientRect();
2250
2274
  // TODO(jelbourn): instead of needing all of the client rects for these scrolling containers
@@ -2375,6 +2399,30 @@ class FlexibleConnectedPositionStrategy {
2375
2399
  this._appliedPanelClasses = [];
2376
2400
  }
2377
2401
  }
2402
+ /**
2403
+ * Returns the ClientRect of the current origin.
2404
+ * @private
2405
+ * @return {?}
2406
+ */
2407
+ _getOriginRect() {
2408
+ /** @type {?} */
2409
+ const origin = this._origin;
2410
+ if (origin instanceof ElementRef) {
2411
+ return origin.nativeElement.getBoundingClientRect();
2412
+ }
2413
+ if (origin instanceof HTMLElement) {
2414
+ return origin.getBoundingClientRect();
2415
+ }
2416
+ // If the origin is a point, return a client rect as if it was a 0x0 element at the point.
2417
+ return {
2418
+ top: origin.y,
2419
+ bottom: origin.y,
2420
+ left: origin.x,
2421
+ right: origin.x,
2422
+ height: 0,
2423
+ width: 0
2424
+ };
2425
+ }
2378
2426
  }
2379
2427
  /**
2380
2428
  * Shallow-extends a stylesheet object with another stylesheet object.
@@ -2874,11 +2922,11 @@ class OverlayPositionBuilder {
2874
2922
  }
2875
2923
  /**
2876
2924
  * Creates a flexible position strategy.
2877
- * @param {?} elementRef
2925
+ * @param {?} origin Origin relative to which to position the overlay.
2878
2926
  * @return {?}
2879
2927
  */
2880
- flexibleConnectedTo(elementRef) {
2881
- return new FlexibleConnectedPositionStrategy(elementRef, this._viewportRuler, this._document, this._platform, this._overlayContainer);
2928
+ flexibleConnectedTo(origin) {
2929
+ return new FlexibleConnectedPositionStrategy(origin, this._viewportRuler, this._document, this._platform, this._overlayContainer);
2882
2930
  }
2883
2931
  }
2884
2932
  OverlayPositionBuilder.decorators = [
@@ -3235,7 +3283,10 @@ class CdkConnectedOverlay {
3235
3283
  * @return {?}
3236
3284
  */
3237
3285
  ngOnDestroy() {
3238
- this._destroyOverlay();
3286
+ if (this._overlayRef) {
3287
+ this._overlayRef.dispose();
3288
+ }
3289
+ this._backdropSubscription.unsubscribe();
3239
3290
  }
3240
3291
  /**
3241
3292
  * @param {?} changes
@@ -3244,6 +3295,12 @@ class CdkConnectedOverlay {
3244
3295
  ngOnChanges(changes) {
3245
3296
  if (this._position) {
3246
3297
  this._updatePositionStrategy(this._position);
3298
+ this._overlayRef.updateSize({
3299
+ width: this.width,
3300
+ minWidth: this.minWidth,
3301
+ height: this.height,
3302
+ minHeight: this.minHeight,
3303
+ });
3247
3304
  if (changes['origin'] && this.open) {
3248
3305
  this._position.apply();
3249
3306
  }
@@ -3352,12 +3409,7 @@ class CdkConnectedOverlay {
3352
3409
  }
3353
3410
  else {
3354
3411
  // Update the overlay size, in case the directive's inputs have changed
3355
- this._overlayRef.updateSize({
3356
- width: this.width,
3357
- minWidth: this.minWidth,
3358
- height: this.height,
3359
- minHeight: this.minHeight,
3360
- });
3412
+ this._overlayRef.getConfig().hasBackdrop = this.hasBackdrop;
3361
3413
  }
3362
3414
  if (!this._overlayRef.hasAttached()) {
3363
3415
  this._overlayRef.attach(this._templatePortal);
@@ -3368,6 +3420,9 @@ class CdkConnectedOverlay {
3368
3420
  this.backdropClick.emit(event);
3369
3421
  });
3370
3422
  }
3423
+ else {
3424
+ this._backdropSubscription.unsubscribe();
3425
+ }
3371
3426
  }
3372
3427
  /**
3373
3428
  * Detaches the overlay and unsubscribes to backdrop clicks if backdrop exists
@@ -3381,17 +3436,6 @@ class CdkConnectedOverlay {
3381
3436
  }
3382
3437
  this._backdropSubscription.unsubscribe();
3383
3438
  }
3384
- /**
3385
- * Destroys the overlay created by this directive.
3386
- * @private
3387
- * @return {?}
3388
- */
3389
- _destroyOverlay() {
3390
- if (this._overlayRef) {
3391
- this._overlayRef.dispose();
3392
- }
3393
- this._backdropSubscription.unsubscribe();
3394
- }
3395
3439
  }
3396
3440
  CdkConnectedOverlay.decorators = [
3397
3441
  { type: Directive, args: [{