@theseam/ui-common 0.3.4 → 0.3.5

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 (36) hide show
  1. package/breadcrumbs/_breadcrumbs-theme.scss +3 -3
  2. package/breadcrumbs/breadcrumbs/breadcrumbs.component.scss +10 -10
  3. package/bundles/theseam-ui-common-dynamic.umd.js +1 -1
  4. package/bundles/theseam-ui-common-dynamic.umd.js.map +1 -1
  5. package/bundles/theseam-ui-common-google-maps.umd.js +1 -1
  6. package/bundles/theseam-ui-common-google-maps.umd.js.map +1 -1
  7. package/bundles/theseam-ui-common-modal.umd.js +59 -30
  8. package/bundles/theseam-ui-common-modal.umd.js.map +1 -1
  9. package/bundles/theseam-ui-common-utils.umd.js.map +1 -1
  10. package/esm2015/dynamic/evaluators/jexl-evaluator/jexl-evaluator.js +2 -2
  11. package/esm2015/google-maps/google-maps-places-autocomplete/google-maps-places-autocomplete.component.js +2 -2
  12. package/esm2015/google-maps/google-maps-places-autocomplete/google-maps-places-autocomplete.directive.js +1 -1
  13. package/esm2015/modal/modal-container/modal-container.component.js +4 -1
  14. package/esm2015/modal/modal-ref.js +56 -31
  15. package/esm2015/utils/geo-json/coerce-feature-collection.js +1 -1
  16. package/esm2015/utils/geo-json/geo-json-to-area.js +1 -1
  17. package/esm2015/utils/geo-json/is-feature-collection.validator.js +1 -1
  18. package/esm2015/utils/geo-json/is-only-geometry-types.js +1 -1
  19. package/esm2015/utils/geo-json/is-only-geometry-types.validator.js +1 -1
  20. package/esm2015/utils/geo-json/merge-polygons.js +1 -1
  21. package/esm2015/utils/geo-json/no-inner-rings.validator.js +1 -1
  22. package/esm2015/utils/geo-json/no-kinks.validator.js +1 -1
  23. package/esm2015/utils/geo-json/split-multi-polygons.js +1 -1
  24. package/fesm2015/theseam-ui-common-dynamic.js +1 -1
  25. package/fesm2015/theseam-ui-common-dynamic.js.map +1 -1
  26. package/fesm2015/theseam-ui-common-google-maps.js +1 -1
  27. package/fesm2015/theseam-ui-common-google-maps.js.map +1 -1
  28. package/fesm2015/theseam-ui-common-modal.js +58 -30
  29. package/fesm2015/theseam-ui-common-modal.js.map +1 -1
  30. package/fesm2015/theseam-ui-common-utils.js.map +1 -1
  31. package/framework/top-bar/_top-bar-theme.scss +5 -5
  32. package/google-maps/theseam-ui-common-google-maps.metadata.json +1 -1
  33. package/modal/modal-container/modal-container.component.d.ts +1 -0
  34. package/modal/modal-ref.d.ts +2 -1
  35. package/modal/theseam-ui-common-modal.metadata.json +1 -1
  36. package/package.json +1 -1
@@ -4,6 +4,7 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.theseam = global.theseam || {}, global.theseam["ui-common"] = global.theseam["ui-common"] || {}, global.theseam["ui-common"].modal = {}), global.ng.cdk.a11y, global.ng.cdk.overlay, global.ng.cdk.portal, global.ng.common, global.ng.core, global.ng.forms, global.ng.router, global.angularFontawesome, global.ng.cdk.keycodes, global.rxjs.operators, global.ng.cdk.bidi, global.rxjs, global.theseam["ui-common"]["dynamic-component-loader"], global.theseam["ui-common"].scrollbar, global.ng.animations, global.theseam["ui-common"].core));
5
5
  })(this, (function (exports, a11y, overlay, portal, common, core, forms, router, angularFontawesome, keycodes, operators, bidi, rxjs, dynamicComponentLoader, scrollbar, animations, core$1) { 'use strict';
6
6
 
7
+ var DRAG_CLOSE_THRESHOLD = 5;
7
8
  /** Unique id for the created dialog. */
8
9
  var uniqueId = 0;
9
10
  /**
@@ -18,13 +19,9 @@
18
19
  this.id = id;
19
20
  /** The instance of the component in the dialog. */
20
21
  this.componentInstance = null;
22
+ this._clickOutsideCleanup = null;
21
23
  // Pass the id along to the container.
22
24
  _containerInstance._id = id;
23
- var _bootstrapBackdropClickListener = function () {
24
- if (!_this.disableClose) {
25
- _this.close();
26
- }
27
- };
28
25
  // If the dialog has a backdrop, handle clicks from the backdrop.
29
26
  if (_containerInstance._config.hasBackdrop) {
30
27
  _overlayRef.backdropClick().subscribe(function () {
@@ -32,32 +29,12 @@
32
29
  _this.close();
33
30
  }
34
31
  });
35
- // NOTE: For current bootstrap style modal
36
- // Replaced click event because it was easy to accidentally close
37
- // the dialog by mousing down inside the modal and mousing up outside
38
- // (like when dragging a map, selecting text, etc)
39
- var clickStarted_1 = false;
40
- _overlayRef.overlayElement.addEventListener('mousedown', function (event) {
41
- // @ts-ignore
42
- if (!_this._isModalMouseEvent(event.path)) {
43
- clickStarted_1 = true;
44
- }
45
- });
46
- _overlayRef.overlayElement.addEventListener('mouseup', function (event) {
47
- // @ts-ignore
48
- if (clickStarted_1 && !_this._isModalMouseEvent(event.path)) {
49
- clickStarted_1 = false;
50
- _bootstrapBackdropClickListener();
51
- }
52
- }, {});
32
+ this._clickOutsideCleanup = this._initCloseOnClickOutside();
53
33
  }
54
34
  this.beforeClosed().subscribe(function () {
55
35
  _this._overlayRef.detachBackdrop();
56
36
  });
57
37
  this.afterClosed().subscribe(function () {
58
- if (_this._containerInstance._config.hasBackdrop) {
59
- _this._overlayRef.overlayElement.removeEventListener('click', _bootstrapBackdropClickListener);
60
- }
61
38
  _this._overlayRef.detach();
62
39
  _this._overlayRef.dispose();
63
40
  _this.componentInstance = null;
@@ -68,6 +45,56 @@
68
45
  .pipe(operators.filter(function (event) { return event.keyCode === keycodes.ESCAPE && !_this.disableClose; }))
69
46
  .subscribe(function () { return _this.close(); });
70
47
  }
48
+ ModalRef.prototype._initCloseOnClickOutside = function () {
49
+ var _this = this;
50
+ var close = function () {
51
+ if (!_this.disableClose) {
52
+ _this.close();
53
+ }
54
+ };
55
+ var isInContainer = function (target) {
56
+ return _this._containerInstance.getNativeElement().contains(target);
57
+ };
58
+ var getPosition = function (event) {
59
+ return { x: event.clientX, y: event.clientY };
60
+ };
61
+ var dist = function (x1, y1, x2, y2) {
62
+ return Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2));
63
+ };
64
+ var pressed = false;
65
+ var pressedPosition = null;
66
+ var _handlePressDown = function (event) {
67
+ pressed = true;
68
+ pressedPosition = getPosition(event);
69
+ };
70
+ var _handlePressUp = function (event) {
71
+ if (pressedPosition) {
72
+ var target = event.target;
73
+ if (target && !isInContainer(target)) {
74
+ var currentPosition = getPosition(event);
75
+ var d = dist(currentPosition.x, currentPosition.y, pressedPosition.x, pressedPosition.y);
76
+ if (d < DRAG_CLOSE_THRESHOLD) {
77
+ close();
78
+ }
79
+ }
80
+ pressedPosition = null;
81
+ }
82
+ else if (pressed) {
83
+ close();
84
+ }
85
+ pressed = false;
86
+ };
87
+ this._overlayRef.overlayElement.addEventListener('mousedown', _handlePressDown);
88
+ this._overlayRef.overlayElement.addEventListener('pointerdown', _handlePressDown);
89
+ this._overlayRef.overlayElement.addEventListener('mouseup', _handlePressUp);
90
+ this._overlayRef.overlayElement.addEventListener('pointerup', _handlePressUp);
91
+ return function () {
92
+ _this._overlayRef.overlayElement.removeEventListener('mousedown', _handlePressDown);
93
+ _this._overlayRef.overlayElement.removeEventListener('pointerdown', _handlePressDown);
94
+ _this._overlayRef.overlayElement.removeEventListener('mouseup', _handlePressUp);
95
+ _this._overlayRef.overlayElement.removeEventListener('pointerup', _handlePressUp);
96
+ };
97
+ };
71
98
  /** Gets an observable that emits when the overlay's backdrop has been clicked. */
72
99
  ModalRef.prototype.backdropClick = function () {
73
100
  return this._overlayRef.backdropClick();
@@ -79,6 +106,9 @@
79
106
  ModalRef.prototype.close = function (dialogResult) {
80
107
  this._result = dialogResult;
81
108
  this._containerInstance._startExiting();
109
+ if (this._clickOutsideCleanup) {
110
+ this._clickOutsideCleanup();
111
+ }
82
112
  };
83
113
  /**
84
114
  * Updates the dialog's position.
@@ -146,10 +176,6 @@
146
176
  var _this = this;
147
177
  return this._containerInstance._afterExit.pipe(operators.map(function () { return _this._result; }));
148
178
  };
149
- // TODO: pull container name in from element, to protect against changes
150
- ModalRef.prototype._isModalMouseEvent = function (path) {
151
- return path.findIndex(function (p) { return p.localName === 'seam-modal-container'; }) !== -1;
152
- };
153
179
  return ModalRef;
154
180
  }());
155
181
 
@@ -1274,6 +1300,9 @@
1274
1300
  toFocus.focus();
1275
1301
  }
1276
1302
  };
1303
+ ModalContainerComponent.prototype.getNativeElement = function () {
1304
+ return this._elementRef.nativeElement;
1305
+ };
1277
1306
  return ModalContainerComponent;
1278
1307
  }(portal.BasePortalOutlet));
1279
1308
  ModalContainerComponent.decorators = [