@angular/cdk 10.0.2 → 10.1.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 (128) 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 +63 -11
  9. package/bundles/cdk-a11y.umd.js.map +1 -1
  10. package/bundles/cdk-a11y.umd.min.js +11 -11
  11. package/bundles/cdk-a11y.umd.min.js.map +1 -1
  12. package/bundles/cdk-accordion.umd.js +12 -4
  13. package/bundles/cdk-accordion.umd.js.map +1 -1
  14. package/bundles/cdk-accordion.umd.min.js +2 -2
  15. package/bundles/cdk-accordion.umd.min.js.map +1 -1
  16. package/bundles/cdk-drag-drop.umd.js +640 -599
  17. package/bundles/cdk-drag-drop.umd.js.map +1 -1
  18. package/bundles/cdk-drag-drop.umd.min.js +8 -16
  19. package/bundles/cdk-drag-drop.umd.min.js.map +1 -1
  20. package/bundles/cdk-overlay.umd.js +199 -42
  21. package/bundles/cdk-overlay.umd.js.map +1 -1
  22. package/bundles/cdk-overlay.umd.min.js +11 -18
  23. package/bundles/cdk-overlay.umd.min.js.map +1 -1
  24. package/bundles/cdk-platform.umd.min.js +1 -1
  25. package/bundles/cdk-platform.umd.min.js.map +1 -1
  26. package/bundles/cdk-scrolling.umd.js +9 -1
  27. package/bundles/cdk-scrolling.umd.js.map +1 -1
  28. package/bundles/cdk-scrolling.umd.min.js +7 -0
  29. package/bundles/cdk-scrolling.umd.min.js.map +1 -1
  30. package/bundles/cdk-testing-protractor.umd.min.js +1 -1
  31. package/bundles/cdk-testing-protractor.umd.min.js.map +1 -1
  32. package/bundles/cdk-testing-testbed.umd.min.js +8 -8
  33. package/bundles/cdk-testing-testbed.umd.min.js.map +1 -1
  34. package/bundles/cdk-testing.umd.js +32 -0
  35. package/bundles/cdk-testing.umd.js.map +1 -1
  36. package/bundles/cdk-testing.umd.min.js +5 -5
  37. package/bundles/cdk-testing.umd.min.js.map +1 -1
  38. package/bundles/cdk-tree.umd.js +6 -2
  39. package/bundles/cdk-tree.umd.js.map +1 -1
  40. package/bundles/cdk-tree.umd.min.js +3 -3
  41. package/bundles/cdk-tree.umd.min.js.map +1 -1
  42. package/bundles/cdk.umd.js +1 -1
  43. package/bundles/cdk.umd.js.map +1 -1
  44. package/bundles/cdk.umd.min.js +1 -1
  45. package/bundles/cdk.umd.min.js.map +1 -1
  46. package/drag-drop/directives/drag-handle.d.ts +7 -1
  47. package/drag-drop/directives/drag-placeholder.d.ts +7 -1
  48. package/drag-drop/directives/drag-preview.d.ts +7 -1
  49. package/drag-drop/directives/drag.d.ts +3 -7
  50. package/drag-drop/directives/drop-list-group.d.ts +7 -1
  51. package/drag-drop/directives/drop-list.d.ts +7 -1
  52. package/drag-drop/index.d.ts +2 -2
  53. package/drag-drop/index.metadata.json +1 -1
  54. package/esm2015/a11y/aria-describer/aria-describer.js +20 -6
  55. package/esm2015/a11y/interactivity-checker/interactivity-checker.js +16 -3
  56. package/esm2015/a11y/key-manager/list-key-manager.js +27 -2
  57. package/esm2015/accordion/accordion-item.js +7 -7
  58. package/esm2015/accordion/accordion.js +9 -2
  59. package/esm2015/accordion/index.js +2 -1
  60. package/esm2015/drag-drop/directives/drag-handle.js +11 -4
  61. package/esm2015/drag-drop/directives/drag-placeholder.js +10 -3
  62. package/esm2015/drag-drop/directives/drag-preview.js +10 -3
  63. package/esm2015/drag-drop/directives/drag.js +19 -15
  64. package/esm2015/drag-drop/directives/drop-list-group.js +9 -2
  65. package/esm2015/drag-drop/directives/drop-list.js +11 -6
  66. package/esm2015/drag-drop/index.js +3 -2
  67. package/esm2015/layout/breakpoints-observer.js +1 -1
  68. package/esm2015/overlay/dispatchers/base-overlay-dispatcher.js +51 -0
  69. package/esm2015/overlay/dispatchers/index.js +10 -0
  70. package/esm2015/overlay/dispatchers/overlay-keyboard-dispatcher.js +79 -0
  71. package/esm2015/overlay/dispatchers/overlay-outside-click-dispatcher.js +94 -0
  72. package/esm2015/overlay/index.js +5 -4
  73. package/esm2015/overlay/overlay-config.js +5 -1
  74. package/esm2015/overlay/overlay-directives.js +17 -7
  75. package/esm2015/overlay/overlay-module.js +2 -2
  76. package/esm2015/overlay/overlay-ref.js +24 -2
  77. package/esm2015/overlay/overlay-reference.js +1 -1
  78. package/esm2015/overlay/overlay.js +10 -5
  79. package/esm2015/overlay/position/overlay-position-builder.js +1 -1
  80. package/esm2015/overlay/public-api.js +2 -2
  81. package/esm2015/scrolling/public-api.js +2 -1
  82. package/esm2015/scrolling/virtual-for-of.js +1 -1
  83. package/esm2015/scrolling/virtual-scroll-repeater.js +8 -0
  84. package/esm2015/scrolling/virtual-scroll-viewport.js +2 -2
  85. package/esm2015/testing/component-harness.js +19 -1
  86. package/esm2015/testing/harness-environment.js +7 -1
  87. package/esm2015/tree/control/nested-tree-control.js +7 -3
  88. package/esm2015/version.js +1 -1
  89. package/fesm2015/a11y.js +60 -10
  90. package/fesm2015/a11y.js.map +1 -1
  91. package/fesm2015/accordion.js +13 -6
  92. package/fesm2015/accordion.js.map +1 -1
  93. package/fesm2015/cdk.js +1 -1
  94. package/fesm2015/cdk.js.map +1 -1
  95. package/fesm2015/drag-drop.js +607 -570
  96. package/fesm2015/drag-drop.js.map +1 -1
  97. package/fesm2015/overlay.js +196 -32
  98. package/fesm2015/overlay.js.map +1 -1
  99. package/fesm2015/scrolling.js +9 -1
  100. package/fesm2015/scrolling.js.map +1 -1
  101. package/fesm2015/testing.js +25 -1
  102. package/fesm2015/testing.js.map +1 -1
  103. package/fesm2015/tree.js +6 -2
  104. package/fesm2015/tree.js.map +1 -1
  105. package/overlay/dispatchers/base-overlay-dispatcher.d.ts +28 -0
  106. package/overlay/dispatchers/index.d.ts +9 -0
  107. package/overlay/{keyboard → dispatchers}/overlay-keyboard-dispatcher.d.ts +4 -10
  108. package/overlay/dispatchers/overlay-outside-click-dispatcher.d.ts +27 -0
  109. package/overlay/index.d.ts +4 -3
  110. package/overlay/index.metadata.json +1 -1
  111. package/overlay/overlay-config.d.ts +4 -0
  112. package/overlay/overlay-directives.d.ts +4 -0
  113. package/overlay/overlay-ref.d.ts +8 -2
  114. package/overlay/overlay-reference.d.ts +1 -0
  115. package/overlay/overlay.d.ts +4 -2
  116. package/overlay/public-api.d.ts +1 -1
  117. package/package.json +1 -1
  118. package/schematics/ng-add/index.js +1 -1
  119. package/scrolling/index.metadata.json +1 -1
  120. package/scrolling/public-api.d.ts +1 -0
  121. package/scrolling/virtual-for-of.d.ts +2 -1
  122. package/scrolling/virtual-scroll-repeater.d.ts +16 -0
  123. package/scrolling/virtual-scroll-viewport.d.ts +4 -4
  124. package/testing/component-harness.d.ts +12 -0
  125. package/testing/harness-environment.d.ts +1 -0
  126. package/tree/control/nested-tree-control.d.ts +7 -2
  127. package/tree/index.metadata.json +1 -1
  128. package/esm2015/overlay/keyboard/overlay-keyboard-dispatcher.js +0 -96
@@ -585,6 +585,10 @@
585
585
  * the `HashLocationStrategy`).
586
586
  */
587
587
  this.disposeOnNavigation = false;
588
+ /**
589
+ * Array of HTML elements clicking on which should not be considered as outside click
590
+ */
591
+ this.excludeFromOutsideClick = [];
588
592
  if (config) {
589
593
  // Use `Iterable` instead of `Array` because TypeScript, as of 3.6.3,
590
594
  // loses the array generic type in the `for of`. But we *also* have to use `Array` because
@@ -721,17 +725,57 @@
721
725
  * found in the LICENSE file at https://angular.io/license
722
726
  */
723
727
  /**
724
- * Service for dispatching keyboard events that land on the body to appropriate overlay ref,
728
+ * Service for dispatching events that land on the body to appropriate overlay ref,
725
729
  * if any. It maintains a list of attached overlays to determine best suited overlay based
726
730
  * on event target and order of overlay opens.
727
731
  */
728
- var OverlayKeyboardDispatcher = /** @class */ (function () {
729
- function OverlayKeyboardDispatcher(document) {
730
- var _this = this;
732
+ var BaseOverlayDispatcher = /** @class */ (function () {
733
+ function BaseOverlayDispatcher(document) {
731
734
  /** Currently attached overlays in the order they were attached. */
732
735
  this._attachedOverlays = [];
736
+ this._document = document;
737
+ }
738
+ BaseOverlayDispatcher.prototype.ngOnDestroy = function () {
739
+ this.detach();
740
+ };
741
+ /** Add a new overlay to the list of attached overlay refs. */
742
+ BaseOverlayDispatcher.prototype.add = function (overlayRef) {
743
+ // Ensure that we don't get the same overlay multiple times.
744
+ this.remove(overlayRef);
745
+ this._attachedOverlays.push(overlayRef);
746
+ };
747
+ /** Remove an overlay from the list of attached overlay refs. */
748
+ BaseOverlayDispatcher.prototype.remove = function (overlayRef) {
749
+ var index = this._attachedOverlays.indexOf(overlayRef);
750
+ if (index > -1) {
751
+ this._attachedOverlays.splice(index, 1);
752
+ }
753
+ // Remove the global listener once there are no more overlays.
754
+ if (this._attachedOverlays.length === 0) {
755
+ this.detach();
756
+ }
757
+ };
758
+ BaseOverlayDispatcher.ɵprov = i0.ɵɵdefineInjectable({ factory: function BaseOverlayDispatcher_Factory() { return new BaseOverlayDispatcher(i0.ɵɵinject(i1$1.DOCUMENT)); }, token: BaseOverlayDispatcher, providedIn: "root" });
759
+ BaseOverlayDispatcher.decorators = [
760
+ { type: i0.Injectable, args: [{ providedIn: 'root' },] }
761
+ ];
762
+ BaseOverlayDispatcher.ctorParameters = function () { return [
763
+ { type: undefined, decorators: [{ type: i0.Inject, args: [i1$1.DOCUMENT,] }] }
764
+ ]; };
765
+ return BaseOverlayDispatcher;
766
+ }());
767
+
768
+ /**
769
+ * Service for dispatching keyboard events that land on the body to appropriate overlay ref,
770
+ * if any. It maintains a list of attached overlays to determine best suited overlay based
771
+ * on event target and order of overlay opens.
772
+ */
773
+ var OverlayKeyboardDispatcher = /** @class */ (function (_super) {
774
+ __extends(OverlayKeyboardDispatcher, _super);
775
+ function OverlayKeyboardDispatcher(document) {
776
+ var _this = _super.call(this, document) || this;
733
777
  /** Keyboard event listener that will be attached to the body. */
734
- this._keydownListener = function (event) {
778
+ _this._keydownListener = function (event) {
735
779
  var overlays = _this._attachedOverlays;
736
780
  for (var i = overlays.length - 1; i > -1; i--) {
737
781
  // Dispatch the keydown event to the top overlay which has subscribers to its keydown events.
@@ -746,35 +790,19 @@
746
790
  }
747
791
  }
748
792
  };
749
- this._document = document;
793
+ return _this;
750
794
  }
751
- OverlayKeyboardDispatcher.prototype.ngOnDestroy = function () {
752
- this._detach();
753
- };
754
795
  /** Add a new overlay to the list of attached overlay refs. */
755
796
  OverlayKeyboardDispatcher.prototype.add = function (overlayRef) {
756
- // Ensure that we don't get the same overlay multiple times.
757
- this.remove(overlayRef);
797
+ _super.prototype.add.call(this, overlayRef);
758
798
  // Lazily start dispatcher once first overlay is added
759
799
  if (!this._isAttached) {
760
800
  this._document.body.addEventListener('keydown', this._keydownListener);
761
801
  this._isAttached = true;
762
802
  }
763
- this._attachedOverlays.push(overlayRef);
764
- };
765
- /** Remove an overlay from the list of attached overlay refs. */
766
- OverlayKeyboardDispatcher.prototype.remove = function (overlayRef) {
767
- var index = this._attachedOverlays.indexOf(overlayRef);
768
- if (index > -1) {
769
- this._attachedOverlays.splice(index, 1);
770
- }
771
- // Remove the global listener once there are no more overlays.
772
- if (this._attachedOverlays.length === 0) {
773
- this._detach();
774
- }
775
803
  };
776
804
  /** Detaches the global keyboard event listener. */
777
- OverlayKeyboardDispatcher.prototype._detach = function () {
805
+ OverlayKeyboardDispatcher.prototype.detach = function () {
778
806
  if (this._isAttached) {
779
807
  this._document.body.removeEventListener('keydown', this._keydownListener);
780
808
  this._isAttached = false;
@@ -788,7 +816,7 @@
788
816
  { type: undefined, decorators: [{ type: i0.Inject, args: [i1$1.DOCUMENT,] }] }
789
817
  ]; };
790
818
  return OverlayKeyboardDispatcher;
791
- }());
819
+ }(BaseOverlayDispatcher));
792
820
  /** @docs-private @deprecated @breaking-change 8.0.0 */
793
821
  function OVERLAY_KEYBOARD_DISPATCHER_PROVIDER_FACTORY(dispatcher, _document) {
794
822
  return dispatcher || new OverlayKeyboardDispatcher(_document);
@@ -807,6 +835,89 @@
807
835
  useFactory: OVERLAY_KEYBOARD_DISPATCHER_PROVIDER_FACTORY
808
836
  };
809
837
 
838
+ /**
839
+ * Service for dispatching mouse click events that land on the body to appropriate overlay ref,
840
+ * if any. It maintains a list of attached overlays to determine best suited overlay based
841
+ * on event target and order of overlay opens.
842
+ */
843
+ var OverlayOutsideClickDispatcher = /** @class */ (function (_super) {
844
+ __extends(OverlayOutsideClickDispatcher, _super);
845
+ function OverlayOutsideClickDispatcher(document, _platform) {
846
+ var _this = _super.call(this, document) || this;
847
+ _this._platform = _platform;
848
+ _this._cursorStyleIsSet = false;
849
+ /** Click event listener that will be attached to the body propagate phase. */
850
+ _this._clickListener = function (event) {
851
+ // Get the target through the `composedPath` if possible to account for shadow DOM.
852
+ var target = event.composedPath ? event.composedPath()[0] : event.target;
853
+ var overlays = _this._attachedOverlays;
854
+ // Dispatch the mouse event to the top overlay which has subscribers to its mouse events.
855
+ // We want to target all overlays for which the click could be considered as outside click.
856
+ // As soon as we reach an overlay for which the click is not outside click we break off
857
+ // the loop.
858
+ for (var i = overlays.length - 1; i > -1; i--) {
859
+ var overlayRef = overlays[i];
860
+ if (overlayRef._outsidePointerEvents.observers.length < 1) {
861
+ continue;
862
+ }
863
+ var config = overlayRef.getConfig();
864
+ var excludeElements = __spread(config.excludeFromOutsideClick, [overlayRef.overlayElement]);
865
+ var isInsideClick = excludeElements.some(function (e) { return e.contains(target); });
866
+ // If it is inside click just break - we should do nothing
867
+ // If it is outside click dispatch the mouse event, and proceed with the next overlay
868
+ if (isInsideClick) {
869
+ break;
870
+ }
871
+ overlayRef._outsidePointerEvents.next(event);
872
+ }
873
+ };
874
+ return _this;
875
+ }
876
+ /** Add a new overlay to the list of attached overlay refs. */
877
+ OverlayOutsideClickDispatcher.prototype.add = function (overlayRef) {
878
+ _super.prototype.add.call(this, overlayRef);
879
+ // tslint:disable: max-line-length
880
+ // Safari on iOS does not generate click events for non-interactive
881
+ // elements. However, we want to receive a click for any element outside
882
+ // the overlay. We can force a "clickable" state by setting
883
+ // `cursor: pointer` on the document body.
884
+ // See https://developer.mozilla.org/en-US/docs/Web/API/Element/click_event#Safari_Mobile
885
+ // and https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html
886
+ // tslint:enable: max-line-length
887
+ if (!this._isAttached) {
888
+ this._document.body.addEventListener('click', this._clickListener, true);
889
+ // click event is not fired on iOS. To make element "clickable" we are
890
+ // setting the cursor to pointer
891
+ if (this._platform.IOS && !this._cursorStyleIsSet) {
892
+ this._cursorOriginalValue = this._document.body.style.cursor;
893
+ this._document.body.style.cursor = 'pointer';
894
+ this._cursorStyleIsSet = true;
895
+ }
896
+ this._isAttached = true;
897
+ }
898
+ };
899
+ /** Detaches the global keyboard event listener. */
900
+ OverlayOutsideClickDispatcher.prototype.detach = function () {
901
+ if (this._isAttached) {
902
+ this._document.body.removeEventListener('click', this._clickListener, true);
903
+ if (this._platform.IOS && this._cursorStyleIsSet) {
904
+ this._document.body.style.cursor = this._cursorOriginalValue;
905
+ this._cursorStyleIsSet = false;
906
+ }
907
+ this._isAttached = false;
908
+ }
909
+ };
910
+ OverlayOutsideClickDispatcher.ɵprov = i0.ɵɵdefineInjectable({ factory: function OverlayOutsideClickDispatcher_Factory() { return new OverlayOutsideClickDispatcher(i0.ɵɵinject(i1$1.DOCUMENT), i0.ɵɵinject(i2.Platform)); }, token: OverlayOutsideClickDispatcher, providedIn: "root" });
911
+ OverlayOutsideClickDispatcher.decorators = [
912
+ { type: i0.Injectable, args: [{ providedIn: 'root' },] }
913
+ ];
914
+ OverlayOutsideClickDispatcher.ctorParameters = function () { return [
915
+ { type: undefined, decorators: [{ type: i0.Inject, args: [i1$1.DOCUMENT,] }] },
916
+ { type: i2.Platform }
917
+ ]; };
918
+ return OverlayOutsideClickDispatcher;
919
+ }(BaseOverlayDispatcher));
920
+
810
921
  /**
811
922
  * @license
812
923
  * Copyright Google LLC All Rights Reserved.
@@ -925,7 +1036,9 @@
925
1036
  var OverlayRef = /** @class */ (function () {
926
1037
  function OverlayRef(_portalOutlet, _host, _pane, _config, _ngZone, _keyboardDispatcher, _document,
927
1038
  // @breaking-change 8.0.0 `_location` parameter to be made required.
928
- _location) {
1039
+ _location,
1040
+ // @breaking-change 9.0.0 `_mouseClickDispatcher` parameter to be made required.
1041
+ _outsideClickDispatcher) {
929
1042
  var _this = this;
930
1043
  this._portalOutlet = _portalOutlet;
931
1044
  this._host = _host;
@@ -935,6 +1048,7 @@
935
1048
  this._keyboardDispatcher = _keyboardDispatcher;
936
1049
  this._document = _document;
937
1050
  this._location = _location;
1051
+ this._outsideClickDispatcher = _outsideClickDispatcher;
938
1052
  this._backdropElement = null;
939
1053
  this._backdropClick = new rxjs.Subject();
940
1054
  this._attachments = new rxjs.Subject();
@@ -943,6 +1057,8 @@
943
1057
  this._backdropClickHandler = function (event) { return _this._backdropClick.next(event); };
944
1058
  /** Stream of keydown events dispatched to this overlay. */
945
1059
  this._keydownEvents = new rxjs.Subject();
1060
+ /** Stream of mouse outside events dispatched to this overlay. */
1061
+ this._outsidePointerEvents = new rxjs.Subject();
946
1062
  if (_config.scrollStrategy) {
947
1063
  this._scrollStrategy = _config.scrollStrategy;
948
1064
  this._scrollStrategy.attach(this);
@@ -1029,6 +1145,10 @@
1029
1145
  if (this._config.disposeOnNavigation && this._location) {
1030
1146
  this._locationChanges = this._location.subscribe(function () { return _this.dispose(); });
1031
1147
  }
1148
+ // @breaking-change 9.0.0 remove the null check for `_mouseClickDispatcher`
1149
+ if (this._outsideClickDispatcher) {
1150
+ this._outsideClickDispatcher.add(this);
1151
+ }
1032
1152
  return attachResult;
1033
1153
  };
1034
1154
  /**
@@ -1060,6 +1180,10 @@
1060
1180
  this._detachContentWhenStable();
1061
1181
  // Stop listening for location changes.
1062
1182
  this._locationChanges.unsubscribe();
1183
+ // @breaking-change 9.0.0 remove the null check for `_outsideClickDispatcher`
1184
+ if (this._outsideClickDispatcher) {
1185
+ this._outsideClickDispatcher.remove(this);
1186
+ }
1063
1187
  return detachmentResult;
1064
1188
  };
1065
1189
  /** Cleans up the overlay from the DOM. */
@@ -1076,6 +1200,11 @@
1076
1200
  this._attachments.complete();
1077
1201
  this._backdropClick.complete();
1078
1202
  this._keydownEvents.complete();
1203
+ this._outsidePointerEvents.complete();
1204
+ // @breaking-change 9.0.0 remove the null check for `_outsideClickDispatcher`
1205
+ if (this._outsideClickDispatcher) {
1206
+ this._outsideClickDispatcher.remove(this);
1207
+ }
1079
1208
  if (this._host && this._host.parentNode) {
1080
1209
  this._host.parentNode.removeChild(this._host);
1081
1210
  this._host = null;
@@ -1106,6 +1235,10 @@
1106
1235
  OverlayRef.prototype.keydownEvents = function () {
1107
1236
  return this._keydownEvents.asObservable();
1108
1237
  };
1238
+ /** Gets an observable of pointer events targeted outside this overlay. */
1239
+ OverlayRef.prototype.outsidePointerEvents = function () {
1240
+ return this._outsidePointerEvents.asObservable();
1241
+ };
1109
1242
  /** Gets the current overlay configuration, which is immutable. */
1110
1243
  OverlayRef.prototype.getConfig = function () {
1111
1244
  return this._config;
@@ -2746,7 +2879,9 @@
2746
2879
  /** Scrolling strategies that can be used when creating an overlay. */
2747
2880
  scrollStrategies, _overlayContainer, _componentFactoryResolver, _positionBuilder, _keyboardDispatcher, _injector, _ngZone, _document, _directionality,
2748
2881
  // @breaking-change 8.0.0 `_location` parameter to be made required.
2749
- _location) {
2882
+ _location,
2883
+ // @breaking-change 9.0.0 `_outsideClickDispatcher` parameter to be made required.
2884
+ _outsideClickDispatcher) {
2750
2885
  this.scrollStrategies = scrollStrategies;
2751
2886
  this._overlayContainer = _overlayContainer;
2752
2887
  this._componentFactoryResolver = _componentFactoryResolver;
@@ -2757,6 +2892,7 @@
2757
2892
  this._document = _document;
2758
2893
  this._directionality = _directionality;
2759
2894
  this._location = _location;
2895
+ this._outsideClickDispatcher = _outsideClickDispatcher;
2760
2896
  }
2761
2897
  /**
2762
2898
  * Creates an overlay.
@@ -2769,7 +2905,7 @@
2769
2905
  var portalOutlet = this._createPortalOutlet(pane);
2770
2906
  var overlayConfig = new OverlayConfig(config);
2771
2907
  overlayConfig.direction = overlayConfig.direction || this._directionality.value;
2772
- return new OverlayRef(portalOutlet, host, pane, overlayConfig, this._ngZone, this._keyboardDispatcher, this._document, this._location);
2908
+ return new OverlayRef(portalOutlet, host, pane, overlayConfig, this._ngZone, this._keyboardDispatcher, this._document, this._location, this._outsideClickDispatcher);
2773
2909
  };
2774
2910
  /**
2775
2911
  * Gets a position builder that can be used, via fluent API,
@@ -2826,7 +2962,8 @@
2826
2962
  { type: i0.NgZone },
2827
2963
  { type: undefined, decorators: [{ type: i0.Inject, args: [i1$1.DOCUMENT,] }] },
2828
2964
  { type: bidi.Directionality },
2829
- { type: i1$1.Location, decorators: [{ type: i0.Optional }] }
2965
+ { type: i1$1.Location, decorators: [{ type: i0.Optional }] },
2966
+ { type: OverlayOutsideClickDispatcher, decorators: [{ type: i0.Optional }] }
2830
2967
  ]; };
2831
2968
  return Overlay;
2832
2969
  }());
@@ -2907,6 +3044,8 @@
2907
3044
  this._flexibleDimensions = false;
2908
3045
  this._push = false;
2909
3046
  this._backdropSubscription = rxjs.Subscription.EMPTY;
3047
+ this._attachSubscription = rxjs.Subscription.EMPTY;
3048
+ this._detachSubscription = rxjs.Subscription.EMPTY;
2910
3049
  /** Margin between the overlay and the viewport edges. */
2911
3050
  this.viewportMargin = 0;
2912
3051
  /** Whether the overlay is open. */
@@ -2921,6 +3060,8 @@
2921
3060
  this.detach = new i0.EventEmitter();
2922
3061
  /** Emits when there are keyboard events that are targeted at the overlay. */
2923
3062
  this.overlayKeydown = new i0.EventEmitter();
3063
+ /** Emits when there are mouse outside click events that are targeted at the overlay. */
3064
+ this.overlayOutsideClick = new i0.EventEmitter();
2924
3065
  this._templatePortal = new portal.TemplatePortal(templateRef, viewContainerRef);
2925
3066
  this._scrollStrategyFactory = scrollStrategyFactory;
2926
3067
  this.scrollStrategy = this._scrollStrategyFactory();
@@ -3003,10 +3144,12 @@
3003
3144
  configurable: true
3004
3145
  });
3005
3146
  CdkConnectedOverlay.prototype.ngOnDestroy = function () {
3147
+ this._attachSubscription.unsubscribe();
3148
+ this._detachSubscription.unsubscribe();
3149
+ this._backdropSubscription.unsubscribe();
3006
3150
  if (this._overlayRef) {
3007
3151
  this._overlayRef.dispose();
3008
3152
  }
3009
- this._backdropSubscription.unsubscribe();
3010
3153
  };
3011
3154
  CdkConnectedOverlay.prototype.ngOnChanges = function (changes) {
3012
3155
  if (this._position) {
@@ -3031,14 +3174,19 @@
3031
3174
  if (!this.positions || !this.positions.length) {
3032
3175
  this.positions = defaultPositionList;
3033
3176
  }
3034
- this._overlayRef = this._overlay.create(this._buildConfig());
3035
- this._overlayRef.keydownEvents().subscribe(function (event) {
3177
+ var overlayRef = this._overlayRef = this._overlay.create(this._buildConfig());
3178
+ this._attachSubscription = overlayRef.attachments().subscribe(function () { return _this.attach.emit(); });
3179
+ this._detachSubscription = overlayRef.detachments().subscribe(function () { return _this.detach.emit(); });
3180
+ overlayRef.keydownEvents().subscribe(function (event) {
3036
3181
  _this.overlayKeydown.next(event);
3037
3182
  if (event.keyCode === keycodes.ESCAPE && !keycodes.hasModifierKey(event)) {
3038
3183
  event.preventDefault();
3039
3184
  _this._detachOverlay();
3040
3185
  }
3041
3186
  });
3187
+ this._overlayRef.outsidePointerEvents().subscribe(function (event) {
3188
+ _this.overlayOutsideClick.next(event);
3189
+ });
3042
3190
  };
3043
3191
  /** Builds the overlay config based on the directive's inputs */
3044
3192
  CdkConnectedOverlay.prototype._buildConfig = function () {
@@ -3112,7 +3260,6 @@
3112
3260
  }
3113
3261
  if (!this._overlayRef.hasAttached()) {
3114
3262
  this._overlayRef.attach(this._templatePortal);
3115
- this.attach.emit();
3116
3263
  }
3117
3264
  if (this.hasBackdrop) {
3118
3265
  this._backdropSubscription = this._overlayRef.backdropClick().subscribe(function (event) {
@@ -3127,7 +3274,6 @@
3127
3274
  CdkConnectedOverlay.prototype._detachOverlay = function () {
3128
3275
  if (this._overlayRef) {
3129
3276
  this._overlayRef.detach();
3130
- this.detach.emit();
3131
3277
  }
3132
3278
  this._backdropSubscription.unsubscribe();
3133
3279
  };
@@ -3169,7 +3315,8 @@
3169
3315
  positionChange: [{ type: i0.Output }],
3170
3316
  attach: [{ type: i0.Output }],
3171
3317
  detach: [{ type: i0.Output }],
3172
- overlayKeydown: [{ type: i0.Output }]
3318
+ overlayKeydown: [{ type: i0.Output }],
3319
+ overlayOutsideClick: [{ type: i0.Output }]
3173
3320
  };
3174
3321
  return CdkConnectedOverlay;
3175
3322
  }());
@@ -3220,6 +3367,14 @@
3220
3367
  CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER,
3221
3368
  ];
3222
3369
 
3370
+ /**
3371
+ * @license
3372
+ * Copyright Google LLC All Rights Reserved.
3373
+ *
3374
+ * Use of this source code is governed by an MIT-style license that can be
3375
+ * found in the LICENSE file at https://angular.io/license
3376
+ */
3377
+
3223
3378
  /**
3224
3379
  * Alternative to OverlayContainer that supports correct displaying of overlay elements in
3225
3380
  * Fullscreen mode
@@ -3355,6 +3510,7 @@
3355
3510
  exports.OverlayContainer = OverlayContainer;
3356
3511
  exports.OverlayKeyboardDispatcher = OverlayKeyboardDispatcher;
3357
3512
  exports.OverlayModule = OverlayModule;
3513
+ exports.OverlayOutsideClickDispatcher = OverlayOutsideClickDispatcher;
3358
3514
  exports.OverlayPositionBuilder = OverlayPositionBuilder;
3359
3515
  exports.OverlayRef = OverlayRef;
3360
3516
  exports.RepositionScrollStrategy = RepositionScrollStrategy;
@@ -3362,13 +3518,14 @@
3362
3518
  exports.ScrollingVisibility = ScrollingVisibility;
3363
3519
  exports.validateHorizontalPosition = validateHorizontalPosition;
3364
3520
  exports.validateVerticalPosition = validateVerticalPosition;
3365
- exports.ɵangular_material_src_cdk_overlay_overlay_a = OVERLAY_CONTAINER_PROVIDER_FACTORY;
3366
- exports.ɵangular_material_src_cdk_overlay_overlay_b = OVERLAY_CONTAINER_PROVIDER;
3367
- exports.ɵangular_material_src_cdk_overlay_overlay_c = CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY;
3368
- exports.ɵangular_material_src_cdk_overlay_overlay_d = CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER_FACTORY;
3369
- exports.ɵangular_material_src_cdk_overlay_overlay_e = CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER;
3370
- exports.ɵangular_material_src_cdk_overlay_overlay_f = OVERLAY_KEYBOARD_DISPATCHER_PROVIDER_FACTORY;
3371
- exports.ɵangular_material_src_cdk_overlay_overlay_g = OVERLAY_KEYBOARD_DISPATCHER_PROVIDER;
3521
+ exports.ɵangular_material_src_cdk_overlay_overlay_a = OVERLAY_KEYBOARD_DISPATCHER_PROVIDER_FACTORY;
3522
+ exports.ɵangular_material_src_cdk_overlay_overlay_b = OVERLAY_KEYBOARD_DISPATCHER_PROVIDER;
3523
+ exports.ɵangular_material_src_cdk_overlay_overlay_c = OVERLAY_CONTAINER_PROVIDER_FACTORY;
3524
+ exports.ɵangular_material_src_cdk_overlay_overlay_d = OVERLAY_CONTAINER_PROVIDER;
3525
+ exports.ɵangular_material_src_cdk_overlay_overlay_e = CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY;
3526
+ exports.ɵangular_material_src_cdk_overlay_overlay_f = CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER_FACTORY;
3527
+ exports.ɵangular_material_src_cdk_overlay_overlay_g = CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER;
3528
+ exports.ɵangular_material_src_cdk_overlay_overlay_h = BaseOverlayDispatcher;
3372
3529
 
3373
3530
  Object.defineProperty(exports, '__esModule', { value: true });
3374
3531