@angular/cdk 10.0.2 → 10.1.3

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 (216) hide show
  1. package/a11y/aria-describer/aria-describer.d.ts +10 -1
  2. package/a11y/index.metadata.json +1 -1
  3. package/a11y/interactivity-checker/interactivity-checker.d.ts +11 -1
  4. package/a11y/key-manager/list-key-manager.d.ts +6 -0
  5. package/accordion/accordion.d.ts +7 -1
  6. package/accordion/index.d.ts +1 -0
  7. package/accordion/index.metadata.json +1 -1
  8. package/bundles/cdk-a11y.umd.js +514 -410
  9. package/bundles/cdk-a11y.umd.js.map +1 -1
  10. package/bundles/cdk-a11y.umd.min.js +35 -11
  11. package/bundles/cdk-a11y.umd.min.js.map +1 -1
  12. package/bundles/cdk-accordion.umd.js +47 -39
  13. package/bundles/cdk-accordion.umd.js.map +1 -1
  14. package/bundles/cdk-accordion.umd.min.js +10 -2
  15. package/bundles/cdk-accordion.umd.min.js.map +1 -1
  16. package/bundles/cdk-bidi.umd.js +25 -25
  17. package/bundles/cdk-bidi.umd.js.map +1 -1
  18. package/bundles/cdk-bidi.umd.min.js +5 -4
  19. package/bundles/cdk-bidi.umd.min.js.map +1 -1
  20. package/bundles/cdk-clipboard.umd.js +37 -36
  21. package/bundles/cdk-clipboard.umd.js.map +1 -1
  22. package/bundles/cdk-clipboard.umd.min.js +10 -2
  23. package/bundles/cdk-clipboard.umd.min.js.map +1 -1
  24. package/bundles/cdk-coercion.umd.js.map +1 -1
  25. package/bundles/cdk-collections.umd.js +303 -237
  26. package/bundles/cdk-collections.umd.js.map +1 -1
  27. package/bundles/cdk-collections.umd.min.js +3 -9
  28. package/bundles/cdk-collections.umd.min.js.map +1 -1
  29. package/bundles/cdk-drag-drop.umd.js +1059 -927
  30. package/bundles/cdk-drag-drop.umd.js.map +1 -1
  31. package/bundles/cdk-drag-drop.umd.min.js +72 -10
  32. package/bundles/cdk-drag-drop.umd.min.js.map +1 -1
  33. package/bundles/cdk-keycodes.umd.js.map +1 -1
  34. package/bundles/cdk-layout.umd.js +18 -18
  35. package/bundles/cdk-layout.umd.js.map +1 -1
  36. package/bundles/cdk-layout.umd.min.js +6 -5
  37. package/bundles/cdk-layout.umd.min.js.map +1 -1
  38. package/bundles/cdk-observers.umd.js +34 -34
  39. package/bundles/cdk-observers.umd.js.map +1 -1
  40. package/bundles/cdk-observers.umd.min.js +2 -2
  41. package/bundles/cdk-observers.umd.min.js.map +1 -1
  42. package/bundles/cdk-overlay.umd.js +638 -416
  43. package/bundles/cdk-overlay.umd.js.map +1 -1
  44. package/bundles/cdk-overlay.umd.min.js +51 -12
  45. package/bundles/cdk-overlay.umd.min.js.map +1 -1
  46. package/bundles/cdk-platform.umd.js +10 -10
  47. package/bundles/cdk-platform.umd.js.map +1 -1
  48. package/bundles/cdk-platform.umd.min.js +4 -11
  49. package/bundles/cdk-platform.umd.min.js.map +1 -1
  50. package/bundles/cdk-portal.umd.js +355 -300
  51. package/bundles/cdk-portal.umd.js.map +1 -1
  52. package/bundles/cdk-portal.umd.min.js +4 -5
  53. package/bundles/cdk-portal.umd.min.js.map +1 -1
  54. package/bundles/cdk-scrolling.umd.js +482 -392
  55. package/bundles/cdk-scrolling.umd.js.map +1 -1
  56. package/bundles/cdk-scrolling.umd.min.js +20 -12
  57. package/bundles/cdk-scrolling.umd.min.js.map +1 -1
  58. package/bundles/cdk-stepper.umd.js +117 -117
  59. package/bundles/cdk-stepper.umd.js.map +1 -1
  60. package/bundles/cdk-stepper.umd.min.js +11 -2
  61. package/bundles/cdk-stepper.umd.min.js.map +1 -1
  62. package/bundles/cdk-table.umd.js +862 -607
  63. package/bundles/cdk-table.umd.js.map +1 -1
  64. package/bundles/cdk-table.umd.min.js +8 -15
  65. package/bundles/cdk-table.umd.min.js.map +1 -1
  66. package/bundles/cdk-testing-protractor.umd.js +300 -241
  67. package/bundles/cdk-testing-protractor.umd.js.map +1 -1
  68. package/bundles/cdk-testing-protractor.umd.min.js +2 -9
  69. package/bundles/cdk-testing-protractor.umd.min.js.map +1 -1
  70. package/bundles/cdk-testing-testbed.umd.js +337 -276
  71. package/bundles/cdk-testing-testbed.umd.js.map +1 -1
  72. package/bundles/cdk-testing-testbed.umd.min.js +7 -30
  73. package/bundles/cdk-testing-testbed.umd.min.js.map +1 -1
  74. package/bundles/cdk-testing.umd.js +358 -270
  75. package/bundles/cdk-testing.umd.js.map +1 -1
  76. package/bundles/cdk-testing.umd.min.js +3 -18
  77. package/bundles/cdk-testing.umd.min.js.map +1 -1
  78. package/bundles/cdk-text-field.umd.js +51 -51
  79. package/bundles/cdk-text-field.umd.js.map +1 -1
  80. package/bundles/cdk-text-field.umd.min.js +10 -2
  81. package/bundles/cdk-text-field.umd.min.js.map +1 -1
  82. package/bundles/cdk-tree.umd.js +449 -396
  83. package/bundles/cdk-tree.umd.js.map +1 -1
  84. package/bundles/cdk-tree.umd.min.js +28 -3
  85. package/bundles/cdk-tree.umd.min.js.map +1 -1
  86. package/bundles/cdk.umd.js +1 -1
  87. package/bundles/cdk.umd.js.map +1 -1
  88. package/bundles/cdk.umd.min.js +1 -1
  89. package/bundles/cdk.umd.min.js.map +1 -1
  90. package/drag-drop/clone-node.d.ts +9 -0
  91. package/drag-drop/directives/drag-handle.d.ts +8 -2
  92. package/drag-drop/directives/drag-placeholder.d.ts +7 -1
  93. package/drag-drop/directives/drag-preview.d.ts +7 -1
  94. package/drag-drop/directives/drag.d.ts +3 -7
  95. package/drag-drop/directives/drop-list-group.d.ts +7 -1
  96. package/drag-drop/directives/drop-list.d.ts +7 -1
  97. package/drag-drop/index.d.ts +2 -2
  98. package/drag-drop/index.metadata.json +1 -1
  99. package/drag-drop/parent-position-tracker.d.ts +1 -1
  100. package/esm2015/a11y/aria-describer/aria-describer.js +21 -7
  101. package/esm2015/a11y/focus-trap/configurable-focus-trap-factory.js +3 -3
  102. package/esm2015/a11y/focus-trap/focus-trap.js +1 -1
  103. package/esm2015/a11y/interactivity-checker/interactivity-checker.js +43 -30
  104. package/esm2015/a11y/key-manager/list-key-manager.js +27 -2
  105. package/esm2015/a11y/live-announcer/live-announcer.js +1 -1
  106. package/esm2015/accordion/accordion-item.js +7 -7
  107. package/esm2015/accordion/accordion.js +9 -2
  108. package/esm2015/accordion/index.js +2 -1
  109. package/esm2015/clipboard/pending-copy.js +7 -6
  110. package/esm2015/drag-drop/clone-node.js +54 -0
  111. package/esm2015/drag-drop/directives/drag-handle.js +12 -5
  112. package/esm2015/drag-drop/directives/drag-placeholder.js +10 -3
  113. package/esm2015/drag-drop/directives/drag-preview.js +10 -3
  114. package/esm2015/drag-drop/directives/drag.js +19 -15
  115. package/esm2015/drag-drop/directives/drop-list-group.js +9 -2
  116. package/esm2015/drag-drop/directives/drop-list.js +19 -8
  117. package/esm2015/drag-drop/drag-ref.js +2 -29
  118. package/esm2015/drag-drop/index.js +3 -2
  119. package/esm2015/layout/breakpoints-observer.js +1 -1
  120. package/esm2015/overlay/dispatchers/base-overlay-dispatcher.js +51 -0
  121. package/esm2015/overlay/dispatchers/index.js +10 -0
  122. package/esm2015/overlay/dispatchers/overlay-keyboard-dispatcher.js +79 -0
  123. package/esm2015/overlay/dispatchers/overlay-outside-click-dispatcher.js +94 -0
  124. package/esm2015/overlay/index.js +5 -4
  125. package/esm2015/overlay/overlay-config.js +5 -1
  126. package/esm2015/overlay/overlay-directives.js +34 -8
  127. package/esm2015/overlay/overlay-module.js +2 -2
  128. package/esm2015/overlay/overlay-ref.js +24 -2
  129. package/esm2015/overlay/overlay-reference.js +1 -1
  130. package/esm2015/overlay/overlay.js +10 -5
  131. package/esm2015/overlay/position/connected-position-strategy.js +1 -5
  132. package/esm2015/overlay/position/flexible-connected-position-strategy.js +3 -3
  133. package/esm2015/overlay/position/overlay-position-builder.js +1 -1
  134. package/esm2015/overlay/public-api.js +2 -2
  135. package/esm2015/portal/dom-portal-outlet.js +5 -2
  136. package/esm2015/scrolling/public-api.js +2 -1
  137. package/esm2015/scrolling/scrolling-module.js +4 -1
  138. package/esm2015/scrolling/viewport-ruler.js +24 -10
  139. package/esm2015/scrolling/virtual-for-of.js +26 -12
  140. package/esm2015/scrolling/virtual-scroll-repeater.js +8 -0
  141. package/esm2015/scrolling/virtual-scroll-viewport.js +2 -2
  142. package/esm2015/table/cell.js +18 -3
  143. package/esm2015/table/coalesced-style-scheduler.js +87 -0
  144. package/esm2015/table/public-api.js +2 -1
  145. package/esm2015/table/sticky-styler.js +79 -45
  146. package/esm2015/table/table.js +33 -12
  147. package/esm2015/testing/component-harness.js +19 -1
  148. package/esm2015/testing/harness-environment.js +7 -1
  149. package/esm2015/testing/testbed/fake-events/dispatch-events.js +5 -4
  150. package/esm2015/testing/testbed/fake-events/event-objects.js +10 -7
  151. package/esm2015/testing/testbed/fake-events/type-in-element.js +4 -4
  152. package/esm2015/testing/testbed/unit-test-element.js +20 -12
  153. package/esm2015/tree/control/nested-tree-control.js +7 -3
  154. package/esm2015/tree/tree.js +9 -23
  155. package/esm2015/version.js +1 -1
  156. package/fesm2015/a11y.js +88 -38
  157. package/fesm2015/a11y.js.map +1 -1
  158. package/fesm2015/accordion.js +13 -6
  159. package/fesm2015/accordion.js.map +1 -1
  160. package/fesm2015/cdk.js +1 -1
  161. package/fesm2015/cdk.js.map +1 -1
  162. package/fesm2015/clipboard.js +6 -5
  163. package/fesm2015/clipboard.js.map +1 -1
  164. package/fesm2015/drag-drop.js +669 -600
  165. package/fesm2015/drag-drop.js.map +1 -1
  166. package/fesm2015/overlay.js +215 -40
  167. package/fesm2015/overlay.js.map +1 -1
  168. package/fesm2015/portal.js +4 -1
  169. package/fesm2015/portal.js.map +1 -1
  170. package/fesm2015/scrolling.js +60 -21
  171. package/fesm2015/scrolling.js.map +1 -1
  172. package/fesm2015/table.js +214 -61
  173. package/fesm2015/table.js.map +1 -1
  174. package/fesm2015/testing/testbed.js +35 -23
  175. package/fesm2015/testing/testbed.js.map +1 -1
  176. package/fesm2015/testing.js +25 -1
  177. package/fesm2015/testing.js.map +1 -1
  178. package/fesm2015/tree.js +13 -23
  179. package/fesm2015/tree.js.map +1 -1
  180. package/overlay/dispatchers/base-overlay-dispatcher.d.ts +28 -0
  181. package/overlay/dispatchers/index.d.ts +9 -0
  182. package/overlay/{keyboard → dispatchers}/overlay-keyboard-dispatcher.d.ts +4 -10
  183. package/overlay/dispatchers/overlay-outside-click-dispatcher.d.ts +27 -0
  184. package/overlay/index.d.ts +4 -3
  185. package/overlay/index.metadata.json +1 -1
  186. package/overlay/overlay-config.d.ts +4 -0
  187. package/overlay/overlay-directives.d.ts +5 -0
  188. package/overlay/overlay-ref.d.ts +8 -2
  189. package/overlay/overlay-reference.d.ts +1 -0
  190. package/overlay/overlay.d.ts +4 -2
  191. package/overlay/position/connected-position-strategy.d.ts +0 -2
  192. package/overlay/public-api.d.ts +1 -1
  193. package/package.json +1 -1
  194. package/schematics/ng-add/index.js +1 -1
  195. package/scrolling/index.metadata.json +1 -1
  196. package/scrolling/public-api.d.ts +1 -0
  197. package/scrolling/scrolling-module.d.ts +3 -0
  198. package/scrolling/viewport-ruler.d.ts +2 -2
  199. package/scrolling/virtual-for-of.d.ts +2 -1
  200. package/scrolling/virtual-scroll-repeater.d.ts +16 -0
  201. package/scrolling/virtual-scroll-viewport.d.ts +4 -4
  202. package/table/cell.d.ts +13 -0
  203. package/table/coalesced-style-scheduler.d.ts +41 -0
  204. package/table/index.metadata.json +1 -1
  205. package/table/public-api.d.ts +1 -0
  206. package/table/sticky-styler.d.ts +7 -1
  207. package/table/table.d.ts +9 -1
  208. package/testing/component-harness.d.ts +12 -0
  209. package/testing/harness-environment.d.ts +1 -0
  210. package/testing/testbed/fake-events/dispatch-events.d.ts +3 -2
  211. package/testing/testbed/fake-events/event-objects.d.ts +2 -2
  212. package/testing/testbed/unit-test-element.d.ts +7 -0
  213. package/tree/control/nested-tree-control.d.ts +7 -2
  214. package/tree/index.metadata.json +1 -1
  215. package/tree/tree.d.ts +2 -4
  216. package/esm2015/overlay/keyboard/overlay-keyboard-dispatcher.js +0 -96
@@ -7,7 +7,7 @@ import { Directionality, BidiModule } from '@angular/cdk/bidi';
7
7
  import { DomPortalOutlet, TemplatePortal, PortalModule } from '@angular/cdk/portal';
8
8
  import { Platform } from '@angular/cdk/platform';
9
9
  import { Subject, Subscription, merge } from 'rxjs';
10
- import { take, takeUntil } from 'rxjs/operators';
10
+ import { take, takeUntil, takeWhile } from 'rxjs/operators';
11
11
  import { ESCAPE, hasModifierKey } from '@angular/cdk/keycodes';
12
12
 
13
13
  /**
@@ -351,6 +351,10 @@ class OverlayConfig {
351
351
  * the `HashLocationStrategy`).
352
352
  */
353
353
  this.disposeOnNavigation = false;
354
+ /**
355
+ * Array of HTML elements clicking on which should not be considered as outside click
356
+ */
357
+ this.excludeFromOutsideClick = [];
354
358
  if (config) {
355
359
  // Use `Iterable` instead of `Array` because TypeScript, as of 3.6.3,
356
360
  // loses the array generic type in the `for of`. But we *also* have to use `Array` because
@@ -471,14 +475,60 @@ function validateHorizontalPosition(property, value) {
471
475
  * found in the LICENSE file at https://angular.io/license
472
476
  */
473
477
  /**
474
- * Service for dispatching keyboard events that land on the body to appropriate overlay ref,
478
+ * Service for dispatching events that land on the body to appropriate overlay ref,
475
479
  * if any. It maintains a list of attached overlays to determine best suited overlay based
476
480
  * on event target and order of overlay opens.
477
481
  */
478
- class OverlayKeyboardDispatcher {
482
+ class BaseOverlayDispatcher {
479
483
  constructor(document) {
480
484
  /** Currently attached overlays in the order they were attached. */
481
485
  this._attachedOverlays = [];
486
+ this._document = document;
487
+ }
488
+ ngOnDestroy() {
489
+ this.detach();
490
+ }
491
+ /** Add a new overlay to the list of attached overlay refs. */
492
+ add(overlayRef) {
493
+ // Ensure that we don't get the same overlay multiple times.
494
+ this.remove(overlayRef);
495
+ this._attachedOverlays.push(overlayRef);
496
+ }
497
+ /** Remove an overlay from the list of attached overlay refs. */
498
+ remove(overlayRef) {
499
+ const index = this._attachedOverlays.indexOf(overlayRef);
500
+ if (index > -1) {
501
+ this._attachedOverlays.splice(index, 1);
502
+ }
503
+ // Remove the global listener once there are no more overlays.
504
+ if (this._attachedOverlays.length === 0) {
505
+ this.detach();
506
+ }
507
+ }
508
+ }
509
+ BaseOverlayDispatcher.ɵprov = ɵɵdefineInjectable({ factory: function BaseOverlayDispatcher_Factory() { return new BaseOverlayDispatcher(ɵɵinject(DOCUMENT)); }, token: BaseOverlayDispatcher, providedIn: "root" });
510
+ BaseOverlayDispatcher.decorators = [
511
+ { type: Injectable, args: [{ providedIn: 'root' },] }
512
+ ];
513
+ BaseOverlayDispatcher.ctorParameters = () => [
514
+ { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
515
+ ];
516
+
517
+ /**
518
+ * @license
519
+ * Copyright Google LLC All Rights Reserved.
520
+ *
521
+ * Use of this source code is governed by an MIT-style license that can be
522
+ * found in the LICENSE file at https://angular.io/license
523
+ */
524
+ /**
525
+ * Service for dispatching keyboard events that land on the body to appropriate overlay ref,
526
+ * if any. It maintains a list of attached overlays to determine best suited overlay based
527
+ * on event target and order of overlay opens.
528
+ */
529
+ class OverlayKeyboardDispatcher extends BaseOverlayDispatcher {
530
+ constructor(document) {
531
+ super(document);
482
532
  /** Keyboard event listener that will be attached to the body. */
483
533
  this._keydownListener = (event) => {
484
534
  const overlays = this._attachedOverlays;
@@ -495,35 +545,18 @@ class OverlayKeyboardDispatcher {
495
545
  }
496
546
  }
497
547
  };
498
- this._document = document;
499
- }
500
- ngOnDestroy() {
501
- this._detach();
502
548
  }
503
549
  /** Add a new overlay to the list of attached overlay refs. */
504
550
  add(overlayRef) {
505
- // Ensure that we don't get the same overlay multiple times.
506
- this.remove(overlayRef);
551
+ super.add(overlayRef);
507
552
  // Lazily start dispatcher once first overlay is added
508
553
  if (!this._isAttached) {
509
554
  this._document.body.addEventListener('keydown', this._keydownListener);
510
555
  this._isAttached = true;
511
556
  }
512
- this._attachedOverlays.push(overlayRef);
513
- }
514
- /** Remove an overlay from the list of attached overlay refs. */
515
- remove(overlayRef) {
516
- const index = this._attachedOverlays.indexOf(overlayRef);
517
- if (index > -1) {
518
- this._attachedOverlays.splice(index, 1);
519
- }
520
- // Remove the global listener once there are no more overlays.
521
- if (this._attachedOverlays.length === 0) {
522
- this._detach();
523
- }
524
557
  }
525
558
  /** Detaches the global keyboard event listener. */
526
- _detach() {
559
+ detach() {
527
560
  if (this._isAttached) {
528
561
  this._document.body.removeEventListener('keydown', this._keydownListener);
529
562
  this._isAttached = false;
@@ -555,6 +588,93 @@ const OVERLAY_KEYBOARD_DISPATCHER_PROVIDER = {
555
588
  useFactory: OVERLAY_KEYBOARD_DISPATCHER_PROVIDER_FACTORY
556
589
  };
557
590
 
591
+ /**
592
+ * @license
593
+ * Copyright Google LLC All Rights Reserved.
594
+ *
595
+ * Use of this source code is governed by an MIT-style license that can be
596
+ * found in the LICENSE file at https://angular.io/license
597
+ */
598
+ /**
599
+ * Service for dispatching mouse click events that land on the body to appropriate overlay ref,
600
+ * if any. It maintains a list of attached overlays to determine best suited overlay based
601
+ * on event target and order of overlay opens.
602
+ */
603
+ class OverlayOutsideClickDispatcher extends BaseOverlayDispatcher {
604
+ constructor(document, _platform) {
605
+ super(document);
606
+ this._platform = _platform;
607
+ this._cursorStyleIsSet = false;
608
+ /** Click event listener that will be attached to the body propagate phase. */
609
+ this._clickListener = (event) => {
610
+ // Get the target through the `composedPath` if possible to account for shadow DOM.
611
+ const target = event.composedPath ? event.composedPath()[0] : event.target;
612
+ const overlays = this._attachedOverlays;
613
+ // Dispatch the mouse event to the top overlay which has subscribers to its mouse events.
614
+ // We want to target all overlays for which the click could be considered as outside click.
615
+ // As soon as we reach an overlay for which the click is not outside click we break off
616
+ // the loop.
617
+ for (let i = overlays.length - 1; i > -1; i--) {
618
+ const overlayRef = overlays[i];
619
+ if (overlayRef._outsidePointerEvents.observers.length < 1) {
620
+ continue;
621
+ }
622
+ const config = overlayRef.getConfig();
623
+ const excludeElements = [...config.excludeFromOutsideClick, overlayRef.overlayElement];
624
+ const isInsideClick = excludeElements.some(e => e.contains(target));
625
+ // If it is inside click just break - we should do nothing
626
+ // If it is outside click dispatch the mouse event, and proceed with the next overlay
627
+ if (isInsideClick) {
628
+ break;
629
+ }
630
+ overlayRef._outsidePointerEvents.next(event);
631
+ }
632
+ };
633
+ }
634
+ /** Add a new overlay to the list of attached overlay refs. */
635
+ add(overlayRef) {
636
+ super.add(overlayRef);
637
+ // tslint:disable: max-line-length
638
+ // Safari on iOS does not generate click events for non-interactive
639
+ // elements. However, we want to receive a click for any element outside
640
+ // the overlay. We can force a "clickable" state by setting
641
+ // `cursor: pointer` on the document body.
642
+ // See https://developer.mozilla.org/en-US/docs/Web/API/Element/click_event#Safari_Mobile
643
+ // and https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html
644
+ // tslint:enable: max-line-length
645
+ if (!this._isAttached) {
646
+ this._document.body.addEventListener('click', this._clickListener, true);
647
+ // click event is not fired on iOS. To make element "clickable" we are
648
+ // setting the cursor to pointer
649
+ if (this._platform.IOS && !this._cursorStyleIsSet) {
650
+ this._cursorOriginalValue = this._document.body.style.cursor;
651
+ this._document.body.style.cursor = 'pointer';
652
+ this._cursorStyleIsSet = true;
653
+ }
654
+ this._isAttached = true;
655
+ }
656
+ }
657
+ /** Detaches the global keyboard event listener. */
658
+ detach() {
659
+ if (this._isAttached) {
660
+ this._document.body.removeEventListener('click', this._clickListener, true);
661
+ if (this._platform.IOS && this._cursorStyleIsSet) {
662
+ this._document.body.style.cursor = this._cursorOriginalValue;
663
+ this._cursorStyleIsSet = false;
664
+ }
665
+ this._isAttached = false;
666
+ }
667
+ }
668
+ }
669
+ OverlayOutsideClickDispatcher.ɵprov = ɵɵdefineInjectable({ factory: function OverlayOutsideClickDispatcher_Factory() { return new OverlayOutsideClickDispatcher(ɵɵinject(DOCUMENT), ɵɵinject(Platform)); }, token: OverlayOutsideClickDispatcher, providedIn: "root" });
670
+ OverlayOutsideClickDispatcher.decorators = [
671
+ { type: Injectable, args: [{ providedIn: 'root' },] }
672
+ ];
673
+ OverlayOutsideClickDispatcher.ctorParameters = () => [
674
+ { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] },
675
+ { type: Platform }
676
+ ];
677
+
558
678
  /**
559
679
  * @license
560
680
  * Copyright Google LLC All Rights Reserved.
@@ -672,7 +792,9 @@ const OVERLAY_CONTAINER_PROVIDER = {
672
792
  class OverlayRef {
673
793
  constructor(_portalOutlet, _host, _pane, _config, _ngZone, _keyboardDispatcher, _document,
674
794
  // @breaking-change 8.0.0 `_location` parameter to be made required.
675
- _location) {
795
+ _location,
796
+ // @breaking-change 9.0.0 `_mouseClickDispatcher` parameter to be made required.
797
+ _outsideClickDispatcher) {
676
798
  this._portalOutlet = _portalOutlet;
677
799
  this._host = _host;
678
800
  this._pane = _pane;
@@ -681,6 +803,7 @@ class OverlayRef {
681
803
  this._keyboardDispatcher = _keyboardDispatcher;
682
804
  this._document = _document;
683
805
  this._location = _location;
806
+ this._outsideClickDispatcher = _outsideClickDispatcher;
684
807
  this._backdropElement = null;
685
808
  this._backdropClick = new Subject();
686
809
  this._attachments = new Subject();
@@ -689,6 +812,8 @@ class OverlayRef {
689
812
  this._backdropClickHandler = (event) => this._backdropClick.next(event);
690
813
  /** Stream of keydown events dispatched to this overlay. */
691
814
  this._keydownEvents = new Subject();
815
+ /** Stream of mouse outside events dispatched to this overlay. */
816
+ this._outsidePointerEvents = new Subject();
692
817
  if (_config.scrollStrategy) {
693
818
  this._scrollStrategy = _config.scrollStrategy;
694
819
  this._scrollStrategy.attach(this);
@@ -762,6 +887,10 @@ class OverlayRef {
762
887
  if (this._config.disposeOnNavigation && this._location) {
763
888
  this._locationChanges = this._location.subscribe(() => this.dispose());
764
889
  }
890
+ // @breaking-change 9.0.0 remove the null check for `_mouseClickDispatcher`
891
+ if (this._outsideClickDispatcher) {
892
+ this._outsideClickDispatcher.add(this);
893
+ }
765
894
  return attachResult;
766
895
  }
767
896
  /**
@@ -793,6 +922,10 @@ class OverlayRef {
793
922
  this._detachContentWhenStable();
794
923
  // Stop listening for location changes.
795
924
  this._locationChanges.unsubscribe();
925
+ // @breaking-change 9.0.0 remove the null check for `_outsideClickDispatcher`
926
+ if (this._outsideClickDispatcher) {
927
+ this._outsideClickDispatcher.remove(this);
928
+ }
796
929
  return detachmentResult;
797
930
  }
798
931
  /** Cleans up the overlay from the DOM. */
@@ -809,6 +942,11 @@ class OverlayRef {
809
942
  this._attachments.complete();
810
943
  this._backdropClick.complete();
811
944
  this._keydownEvents.complete();
945
+ this._outsidePointerEvents.complete();
946
+ // @breaking-change 9.0.0 remove the null check for `_outsideClickDispatcher`
947
+ if (this._outsideClickDispatcher) {
948
+ this._outsideClickDispatcher.remove(this);
949
+ }
812
950
  if (this._host && this._host.parentNode) {
813
951
  this._host.parentNode.removeChild(this._host);
814
952
  this._host = null;
@@ -839,6 +977,10 @@ class OverlayRef {
839
977
  keydownEvents() {
840
978
  return this._keydownEvents.asObservable();
841
979
  }
980
+ /** Gets an observable of pointer events targeted outside this overlay. */
981
+ outsidePointerEvents() {
982
+ return this._outsidePointerEvents.asObservable();
983
+ }
842
984
  /** Gets the current overlay configuration, which is immutable. */
843
985
  getConfig() {
844
986
  return this._config;
@@ -1521,8 +1663,8 @@ class FlexibleConnectedPositionStrategy {
1521
1663
  const viewport = this._viewportRect;
1522
1664
  // Determine how much the overlay goes outside the viewport on each
1523
1665
  // side, which we'll use to decide which direction to push it.
1524
- const overflowRight = Math.max(start.x + overlay.width - viewport.right, 0);
1525
- const overflowBottom = Math.max(start.y + overlay.height - viewport.bottom, 0);
1666
+ const overflowRight = Math.max(start.x + overlay.width - viewport.width, 0);
1667
+ const overflowBottom = Math.max(start.y + overlay.height - viewport.height, 0);
1526
1668
  const overflowTop = Math.max(viewport.top - scrollPosition.top - start.y, 0);
1527
1669
  const overflowLeft = Math.max(viewport.left - scrollPosition.left - start.x, 0);
1528
1670
  // Amount by which to push the overlay in each axis such that it remains on-screen.
@@ -2018,10 +2160,6 @@ class ConnectedPositionStrategy {
2018
2160
  .withViewportMargin(0);
2019
2161
  this.withFallbackPosition(originPos, overlayPos);
2020
2162
  }
2021
- /** Whether the we're dealing with an RTL context */
2022
- get _isRtl() {
2023
- return this._overlayRef.getDirection() === 'rtl';
2024
- }
2025
2163
  /** Emits an event when the connection point changes. */
2026
2164
  get onPositionChange() {
2027
2165
  return this._positionStrategy.positionChanges;
@@ -2415,7 +2553,9 @@ class Overlay {
2415
2553
  /** Scrolling strategies that can be used when creating an overlay. */
2416
2554
  scrollStrategies, _overlayContainer, _componentFactoryResolver, _positionBuilder, _keyboardDispatcher, _injector, _ngZone, _document, _directionality,
2417
2555
  // @breaking-change 8.0.0 `_location` parameter to be made required.
2418
- _location) {
2556
+ _location,
2557
+ // @breaking-change 9.0.0 `_outsideClickDispatcher` parameter to be made required.
2558
+ _outsideClickDispatcher) {
2419
2559
  this.scrollStrategies = scrollStrategies;
2420
2560
  this._overlayContainer = _overlayContainer;
2421
2561
  this._componentFactoryResolver = _componentFactoryResolver;
@@ -2426,6 +2566,7 @@ class Overlay {
2426
2566
  this._document = _document;
2427
2567
  this._directionality = _directionality;
2428
2568
  this._location = _location;
2569
+ this._outsideClickDispatcher = _outsideClickDispatcher;
2429
2570
  }
2430
2571
  /**
2431
2572
  * Creates an overlay.
@@ -2438,7 +2579,7 @@ class Overlay {
2438
2579
  const portalOutlet = this._createPortalOutlet(pane);
2439
2580
  const overlayConfig = new OverlayConfig(config);
2440
2581
  overlayConfig.direction = overlayConfig.direction || this._directionality.value;
2441
- return new OverlayRef(portalOutlet, host, pane, overlayConfig, this._ngZone, this._keyboardDispatcher, this._document, this._location);
2582
+ return new OverlayRef(portalOutlet, host, pane, overlayConfig, this._ngZone, this._keyboardDispatcher, this._document, this._location, this._outsideClickDispatcher);
2442
2583
  }
2443
2584
  /**
2444
2585
  * Gets a position builder that can be used, via fluent API,
@@ -2496,7 +2637,8 @@ Overlay.ctorParameters = () => [
2496
2637
  { type: NgZone },
2497
2638
  { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] },
2498
2639
  { type: Directionality },
2499
- { type: Location, decorators: [{ type: Optional }] }
2640
+ { type: Location, decorators: [{ type: Optional }] },
2641
+ { type: OverlayOutsideClickDispatcher, decorators: [{ type: Optional }] }
2500
2642
  ];
2501
2643
 
2502
2644
  /**
@@ -2574,6 +2716,9 @@ class CdkConnectedOverlay {
2574
2716
  this._flexibleDimensions = false;
2575
2717
  this._push = false;
2576
2718
  this._backdropSubscription = Subscription.EMPTY;
2719
+ this._attachSubscription = Subscription.EMPTY;
2720
+ this._detachSubscription = Subscription.EMPTY;
2721
+ this._positionSubscription = Subscription.EMPTY;
2577
2722
  /** Margin between the overlay and the viewport edges. */
2578
2723
  this.viewportMargin = 0;
2579
2724
  /** Whether the overlay is open. */
@@ -2588,6 +2733,8 @@ class CdkConnectedOverlay {
2588
2733
  this.detach = new EventEmitter();
2589
2734
  /** Emits when there are keyboard events that are targeted at the overlay. */
2590
2735
  this.overlayKeydown = new EventEmitter();
2736
+ /** Emits when there are mouse outside click events that are targeted at the overlay. */
2737
+ this.overlayOutsideClick = new EventEmitter();
2591
2738
  this._templatePortal = new TemplatePortal(templateRef, viewContainerRef);
2592
2739
  this._scrollStrategyFactory = scrollStrategyFactory;
2593
2740
  this.scrollStrategy = this._scrollStrategyFactory();
@@ -2634,10 +2781,13 @@ class CdkConnectedOverlay {
2634
2781
  return this._dir ? this._dir.value : 'ltr';
2635
2782
  }
2636
2783
  ngOnDestroy() {
2784
+ this._attachSubscription.unsubscribe();
2785
+ this._detachSubscription.unsubscribe();
2786
+ this._backdropSubscription.unsubscribe();
2787
+ this._positionSubscription.unsubscribe();
2637
2788
  if (this._overlayRef) {
2638
2789
  this._overlayRef.dispose();
2639
2790
  }
2640
- this._backdropSubscription.unsubscribe();
2641
2791
  }
2642
2792
  ngOnChanges(changes) {
2643
2793
  if (this._position) {
@@ -2661,14 +2811,19 @@ class CdkConnectedOverlay {
2661
2811
  if (!this.positions || !this.positions.length) {
2662
2812
  this.positions = defaultPositionList;
2663
2813
  }
2664
- this._overlayRef = this._overlay.create(this._buildConfig());
2665
- this._overlayRef.keydownEvents().subscribe((event) => {
2814
+ const overlayRef = this._overlayRef = this._overlay.create(this._buildConfig());
2815
+ this._attachSubscription = overlayRef.attachments().subscribe(() => this.attach.emit());
2816
+ this._detachSubscription = overlayRef.detachments().subscribe(() => this.detach.emit());
2817
+ overlayRef.keydownEvents().subscribe((event) => {
2666
2818
  this.overlayKeydown.next(event);
2667
2819
  if (event.keyCode === ESCAPE && !hasModifierKey(event)) {
2668
2820
  event.preventDefault();
2669
2821
  this._detachOverlay();
2670
2822
  }
2671
2823
  });
2824
+ this._overlayRef.outsidePointerEvents().subscribe((event) => {
2825
+ this.overlayOutsideClick.next(event);
2826
+ });
2672
2827
  }
2673
2828
  /** Builds the overlay config based on the directive's inputs */
2674
2829
  _buildConfig() {
@@ -2725,7 +2880,6 @@ class CdkConnectedOverlay {
2725
2880
  _createPositionStrategy() {
2726
2881
  const strategy = this._overlay.position().flexibleConnectedTo(this.origin.elementRef);
2727
2882
  this._updatePositionStrategy(strategy);
2728
- strategy.positionChanges.subscribe(p => this.positionChange.emit(p));
2729
2883
  return strategy;
2730
2884
  }
2731
2885
  /** Attaches the overlay and subscribes to backdrop clicks if backdrop exists */
@@ -2739,7 +2893,6 @@ class CdkConnectedOverlay {
2739
2893
  }
2740
2894
  if (!this._overlayRef.hasAttached()) {
2741
2895
  this._overlayRef.attach(this._templatePortal);
2742
- this.attach.emit();
2743
2896
  }
2744
2897
  if (this.hasBackdrop) {
2745
2898
  this._backdropSubscription = this._overlayRef.backdropClick().subscribe(event => {
@@ -2749,14 +2902,27 @@ class CdkConnectedOverlay {
2749
2902
  else {
2750
2903
  this._backdropSubscription.unsubscribe();
2751
2904
  }
2905
+ this._positionSubscription.unsubscribe();
2906
+ // Only subscribe to `positionChanges` if requested, because putting
2907
+ // together all the information for it can be expensive.
2908
+ if (this.positionChange.observers.length > 0) {
2909
+ this._positionSubscription = this._position.positionChanges
2910
+ .pipe(takeWhile(() => this.positionChange.observers.length > 0))
2911
+ .subscribe(position => {
2912
+ this.positionChange.emit(position);
2913
+ if (this.positionChange.observers.length === 0) {
2914
+ this._positionSubscription.unsubscribe();
2915
+ }
2916
+ });
2917
+ }
2752
2918
  }
2753
2919
  /** Detaches the overlay and unsubscribes to backdrop clicks if backdrop exists */
2754
2920
  _detachOverlay() {
2755
2921
  if (this._overlayRef) {
2756
2922
  this._overlayRef.detach();
2757
- this.detach.emit();
2758
2923
  }
2759
2924
  this._backdropSubscription.unsubscribe();
2925
+ this._positionSubscription.unsubscribe();
2760
2926
  }
2761
2927
  }
2762
2928
  CdkConnectedOverlay.decorators = [
@@ -2797,7 +2963,8 @@ CdkConnectedOverlay.propDecorators = {
2797
2963
  positionChange: [{ type: Output }],
2798
2964
  attach: [{ type: Output }],
2799
2965
  detach: [{ type: Output }],
2800
- overlayKeydown: [{ type: Output }]
2966
+ overlayKeydown: [{ type: Output }],
2967
+ overlayOutsideClick: [{ type: Output }]
2801
2968
  };
2802
2969
  /** @docs-private */
2803
2970
  function CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER_FACTORY(overlay) {
@@ -2843,6 +3010,14 @@ const OVERLAY_PROVIDERS = [
2843
3010
  CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER,
2844
3011
  ];
2845
3012
 
3013
+ /**
3014
+ * @license
3015
+ * Copyright Google LLC All Rights Reserved.
3016
+ *
3017
+ * Use of this source code is governed by an MIT-style license that can be
3018
+ * found in the LICENSE file at https://angular.io/license
3019
+ */
3020
+
2846
3021
  /**
2847
3022
  * @license
2848
3023
  * Copyright Google LLC All Rights Reserved.
@@ -2947,5 +3122,5 @@ FullscreenOverlayContainer.ctorParameters = () => [
2947
3122
  * Generated bundle index. Do not edit.
2948
3123
  */
2949
3124
 
2950
- export { BlockScrollStrategy, CdkConnectedOverlay, CdkOverlayOrigin, CloseScrollStrategy, ConnectedOverlayPositionChange, ConnectedPositionStrategy, ConnectionPositionPair, FlexibleConnectedPositionStrategy, FullscreenOverlayContainer, GlobalPositionStrategy, NoopScrollStrategy, OVERLAY_PROVIDERS, Overlay, OverlayConfig, OverlayContainer, OverlayKeyboardDispatcher, OverlayModule, OverlayPositionBuilder, OverlayRef, RepositionScrollStrategy, ScrollStrategyOptions, ScrollingVisibility, validateHorizontalPosition, validateVerticalPosition, OVERLAY_CONTAINER_PROVIDER_FACTORY as ɵangular_material_src_cdk_overlay_overlay_a, OVERLAY_CONTAINER_PROVIDER as ɵangular_material_src_cdk_overlay_overlay_b, CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY as ɵangular_material_src_cdk_overlay_overlay_c, CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER_FACTORY as ɵangular_material_src_cdk_overlay_overlay_d, CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER as ɵangular_material_src_cdk_overlay_overlay_e, OVERLAY_KEYBOARD_DISPATCHER_PROVIDER_FACTORY as ɵangular_material_src_cdk_overlay_overlay_f, OVERLAY_KEYBOARD_DISPATCHER_PROVIDER as ɵangular_material_src_cdk_overlay_overlay_g };
3125
+ export { BlockScrollStrategy, CdkConnectedOverlay, CdkOverlayOrigin, CloseScrollStrategy, ConnectedOverlayPositionChange, ConnectedPositionStrategy, ConnectionPositionPair, FlexibleConnectedPositionStrategy, FullscreenOverlayContainer, GlobalPositionStrategy, NoopScrollStrategy, OVERLAY_PROVIDERS, Overlay, OverlayConfig, OverlayContainer, OverlayKeyboardDispatcher, OverlayModule, OverlayOutsideClickDispatcher, OverlayPositionBuilder, OverlayRef, RepositionScrollStrategy, ScrollStrategyOptions, ScrollingVisibility, validateHorizontalPosition, validateVerticalPosition, OVERLAY_KEYBOARD_DISPATCHER_PROVIDER_FACTORY as ɵangular_material_src_cdk_overlay_overlay_a, OVERLAY_KEYBOARD_DISPATCHER_PROVIDER as ɵangular_material_src_cdk_overlay_overlay_b, OVERLAY_CONTAINER_PROVIDER_FACTORY as ɵangular_material_src_cdk_overlay_overlay_c, OVERLAY_CONTAINER_PROVIDER as ɵangular_material_src_cdk_overlay_overlay_d, CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY as ɵangular_material_src_cdk_overlay_overlay_e, CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER_FACTORY as ɵangular_material_src_cdk_overlay_overlay_f, CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER as ɵangular_material_src_cdk_overlay_overlay_g, BaseOverlayDispatcher as ɵangular_material_src_cdk_overlay_overlay_h };
2951
3126
  //# sourceMappingURL=overlay.js.map