@targetprocess/popover 12.7.4 → 12.19.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.
@@ -8,46 +8,41 @@ function _classCallCheck(instance, Constructor) {
8
8
  throw new TypeError("Cannot call a class as a function");
9
9
  }
10
10
  }
11
-
12
11
  function _defineProperties(target, props) {
13
12
  for (var i = 0; i < props.length; i++) {
14
13
  var descriptor = props[i];
15
14
  descriptor.enumerable = descriptor.enumerable || false;
16
15
  descriptor.configurable = true;
17
16
  if ("value" in descriptor) descriptor.writable = true;
18
- Object.defineProperty(target, descriptor.key, descriptor);
17
+ Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
19
18
  }
20
19
  }
21
-
22
20
  function _createClass(Constructor, protoProps, staticProps) {
23
21
  if (protoProps) _defineProperties(Constructor.prototype, protoProps);
24
22
  if (staticProps) _defineProperties(Constructor, staticProps);
23
+ Object.defineProperty(Constructor, "prototype", {
24
+ writable: false
25
+ });
25
26
  return Constructor;
26
27
  }
27
-
28
28
  function _extends() {
29
- _extends = Object.assign || function (target) {
29
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
30
30
  for (var i = 1; i < arguments.length; i++) {
31
31
  var source = arguments[i];
32
-
33
32
  for (var key in source) {
34
33
  if (Object.prototype.hasOwnProperty.call(source, key)) {
35
34
  target[key] = source[key];
36
35
  }
37
36
  }
38
37
  }
39
-
40
38
  return target;
41
39
  };
42
-
43
40
  return _extends.apply(this, arguments);
44
41
  }
45
-
46
42
  function _inherits(subClass, superClass) {
47
43
  if (typeof superClass !== "function" && superClass !== null) {
48
44
  throw new TypeError("Super expression must either be null or a function");
49
45
  }
50
-
51
46
  subClass.prototype = Object.create(superClass && superClass.prototype, {
52
47
  constructor: {
53
48
  value: subClass,
@@ -55,40 +50,52 @@ function _inherits(subClass, superClass) {
55
50
  configurable: true
56
51
  }
57
52
  });
53
+ Object.defineProperty(subClass, "prototype", {
54
+ writable: false
55
+ });
58
56
  if (superClass) _setPrototypeOf(subClass, superClass);
59
57
  }
60
-
61
58
  function _getPrototypeOf(o) {
62
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
59
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
63
60
  return o.__proto__ || Object.getPrototypeOf(o);
64
61
  };
65
62
  return _getPrototypeOf(o);
66
63
  }
67
-
68
64
  function _setPrototypeOf(o, p) {
69
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
65
+ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
70
66
  o.__proto__ = p;
71
67
  return o;
72
68
  };
73
-
74
69
  return _setPrototypeOf(o, p);
75
70
  }
76
-
77
71
  function _assertThisInitialized(self) {
78
72
  if (self === void 0) {
79
73
  throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
80
74
  }
81
-
82
75
  return self;
83
76
  }
84
-
85
77
  function _possibleConstructorReturn(self, call) {
86
78
  if (call && (typeof call === "object" || typeof call === "function")) {
87
79
  return call;
80
+ } else if (call !== void 0) {
81
+ throw new TypeError("Derived constructors may only return object or undefined");
88
82
  }
89
-
90
83
  return _assertThisInitialized(self);
91
84
  }
85
+ function _toPrimitive(input, hint) {
86
+ if (typeof input !== "object" || input === null) return input;
87
+ var prim = input[Symbol.toPrimitive];
88
+ if (prim !== undefined) {
89
+ var res = prim.call(input, hint || "default");
90
+ if (typeof res !== "object") return res;
91
+ throw new TypeError("@@toPrimitive must return a primitive value.");
92
+ }
93
+ return (hint === "string" ? String : Number)(input);
94
+ }
95
+ function _toPropertyKey(arg) {
96
+ var key = _toPrimitive(arg, "string");
97
+ return typeof key === "symbol" ? key : String(key);
98
+ }
92
99
 
93
100
  var PopoverPosition = {
94
101
  bottomLeft: function bottomLeft(hostRect, popoverRect, containerScroll) {
@@ -198,15 +205,15 @@ function styleInject(css, ref) {
198
205
  }
199
206
  }
200
207
 
201
- var css = ".popover-body-container__popover__12-7-4 {\r\n -webkit-box-shadow: var(--BoxShadowL, 0 4px 16px 0 rgba(0, 0, 0, 0.12));\r\n box-shadow: var(--BoxShadowL, 0 4px 16px 0 rgba(0, 0, 0, 0.12));\r\n border-radius: var(--BorderRadiusL, 4px);\r\n border: 1px solid var(--HighlightBlockBorderColor, rgba(64, 66, 73, 0.1));\r\n background: var(--BackgroundDefault, #FFFFFF);\r\n z-index: var(--ZIndexModal, 10001);\r\n -webkit-box-sizing: border-box;\r\n box-sizing: border-box;\r\n}\r\n\r\n.popover-body__popover__12-7-4 {\r\n -webkit-box-sizing: border-box;\r\n box-sizing: border-box;\r\n padding: var(--SpaceSM, 12px);\r\n font-size: var(--FontSizeDefault, 13px);\r\n color: var(--FontColorDefault, #000000);\r\n}\r\n\r\n.popover-body--no-padding__popover__12-7-4 {\r\n padding: 0;\r\n }\r\n\r\n.popover-tip__popover__12-7-4 {\r\n position: absolute;\r\n pointer-events: none;\r\n z-index: calc(var(--ZIndexModal, 10001) + 1);\r\n overflow: hidden;\r\n display: -webkit-box;\r\n display: -ms-flexbox;\r\n display: flex;\r\n -webkit-box-align: center;\r\n -ms-flex-align: center;\r\n align-items: center;\r\n -webkit-box-pack: center;\r\n -ms-flex-pack: center;\r\n justify-content: center;\r\n}\r\n\r\n.popover-tip__popover__12-7-4:before {\r\n content: '';\r\n position: absolute;\r\n display: block;\r\n -webkit-box-sizing: border-box;\r\n box-sizing: border-box;\r\n background-color: var(--BackgroundDefault, #FFFFFF);\r\n border: 1px solid var(--HighlightBlockBorderColor, rgba(64, 66, 73, 0.1));\r\n /*\r\n geometry FTW\r\n\r\n 2*$popoverTipSize\r\n _______ _______\r\n | /|\\ |\r\n | / | \\ | $popoverTipSize\r\n | / | \\ |\r\n |/______|______\\|\r\n since tip is rotated 45 degrees, its width and height is a\r\n diagonal of a square with side=$popoverTipSize, thus diagonal\r\n is sqrt(2) * $popoverTipSize.\r\n sqrt(2) ~= 1.414, 1.4 used here to prevent too much rounding\r\n */\r\n width: 11.2px;\r\n height: 11.2px;\r\n -webkit-transform: rotate(45deg);\r\n transform: rotate(45deg);\r\n }\r\n\r\n.popover-tip--bottom__popover__12-7-4,\r\n .popover-tip--top__popover__12-7-4 {\r\n width: 100%;\r\n border-top: 1px var(--BackgroundDefault, #FFFFFF);\r\n border-bottom: 1px var(--BackgroundDefault, #FFFFFF);\r\n height: 9px;\r\n }\r\n\r\n.popover-tip--left__popover__12-7-4,\r\n .popover-tip--right__popover__12-7-4 {\r\n border-left: 1px var(--BackgroundDefault, #FFFFFF);\r\n border-right: 1px var(--BackgroundDefault, #FFFFFF);\r\n height: 100%;\r\n width: 9px;\r\n }\r\n\r\n/*\r\n To determine tip position, we need to rotate it\r\n along the \"tip\" point, after that, the \"tip\" point\r\n can be placed with exactly 50% offset from the origin\r\n so that it is centered.\r\n */\r\n\r\n.popover-tip--bottom__popover__12-7-4:before {\r\n -webkit-transform-origin: left top;\r\n transform-origin: left top;\r\n left: 50%;\r\n top: 0;\r\n }\r\n\r\n.popover-tip--top__popover__12-7-4:before {\r\n -webkit-transform-origin: right bottom;\r\n transform-origin: right bottom;\r\n right: 50%;\r\n bottom: 0;\r\n }\r\n\r\n.popover-tip--left__popover__12-7-4:before {\r\n -webkit-transform-origin: right top;\r\n transform-origin: right top;\r\n right: 0;\r\n top: 50%;\r\n }\r\n\r\n.popover-tip--right__popover__12-7-4:before {\r\n -webkit-transform-origin: left bottom;\r\n transform-origin: left bottom;\r\n left: 0;\r\n bottom: 50%;\r\n }\r\n";
202
- var styles = {"popover-body-container":"popover-body-container__popover__12-7-4","popover-body":"popover-body__popover__12-7-4","popover-body--no-padding":"popover-body--no-padding__popover__12-7-4","popover-tip":"popover-tip__popover__12-7-4","popover-tip--bottom":"popover-tip--bottom__popover__12-7-4","popover-tip--top":"popover-tip--top__popover__12-7-4","popover-tip--left":"popover-tip--left__popover__12-7-4","popover-tip--right":"popover-tip--right__popover__12-7-4"};
208
+ var css = ".popover-body-container__popover__12-19-0 {\r\n -webkit-box-shadow: var(--BoxShadowL, 0 4px 16px 0 rgba(0, 0, 0, 0.12));\r\n box-shadow: var(--BoxShadowL, 0 4px 16px 0 rgba(0, 0, 0, 0.12));\r\n border-radius: var(--BorderRadiusL, 4px);\r\n border: 1px solid var(--HighlightBlockBorderColor, rgba(64, 66, 73, 0.1));\r\n background: var(--BackgroundDefault, #FFFFFF);\r\n z-index: var(--ZIndexModal, 10001);\r\n -webkit-box-sizing: border-box;\r\n box-sizing: border-box;\r\n}\r\n\r\n.popover-body__popover__12-19-0 {\r\n -webkit-box-sizing: border-box;\r\n box-sizing: border-box;\r\n padding: var(--SpaceSM, 12px);\r\n font-size: var(--FontSizeDefault, 13px);\r\n color: var(--FontColorDefault, #000000);\r\n}\r\n\r\n.popover-body--no-padding__popover__12-19-0 {\r\n padding: 0;\r\n }\r\n\r\n.popover-tip__popover__12-19-0 {\r\n position: absolute;\r\n pointer-events: none;\r\n z-index: calc(var(--ZIndexModal, 10001) + 1);\r\n overflow: hidden;\r\n display: -webkit-box;\r\n display: -ms-flexbox;\r\n display: flex;\r\n -webkit-box-align: center;\r\n -ms-flex-align: center;\r\n align-items: center;\r\n -webkit-box-pack: center;\r\n -ms-flex-pack: center;\r\n justify-content: center;\r\n}\r\n\r\n.popover-tip__popover__12-19-0:before {\r\n content: '';\r\n position: absolute;\r\n display: block;\r\n -webkit-box-sizing: border-box;\r\n box-sizing: border-box;\r\n background-color: var(--BackgroundDefault, #FFFFFF);\r\n border: 1px solid var(--HighlightBlockBorderColor, rgba(64, 66, 73, 0.1));\r\n /*\r\n geometry FTW\r\n\r\n 2*$popoverTipSize\r\n _______ _______\r\n | /|\\ |\r\n | / | \\ | $popoverTipSize\r\n | / | \\ |\r\n |/______|______\\|\r\n since tip is rotated 45 degrees, its width and height is a\r\n diagonal of a square with side=$popoverTipSize, thus diagonal\r\n is sqrt(2) * $popoverTipSize.\r\n sqrt(2) ~= 1.414, 1.4 used here to prevent too much rounding\r\n */\r\n width: 11.2px;\r\n height: 11.2px;\r\n -webkit-transform: rotate(45deg);\r\n transform: rotate(45deg);\r\n }\r\n\r\n.popover-tip--bottom__popover__12-19-0,\r\n .popover-tip--top__popover__12-19-0 {\r\n width: 100%;\r\n border-top: 1px var(--BackgroundDefault, #FFFFFF);\r\n border-bottom: 1px var(--BackgroundDefault, #FFFFFF);\r\n height: 9px;\r\n }\r\n\r\n.popover-tip--left__popover__12-19-0,\r\n .popover-tip--right__popover__12-19-0 {\r\n border-left: 1px var(--BackgroundDefault, #FFFFFF);\r\n border-right: 1px var(--BackgroundDefault, #FFFFFF);\r\n height: 100%;\r\n width: 9px;\r\n }\r\n\r\n/*\r\n To determine tip position, we need to rotate it\r\n along the \"tip\" point, after that, the \"tip\" point\r\n can be placed with exactly 50% offset from the origin\r\n so that it is centered.\r\n */\r\n\r\n.popover-tip--bottom__popover__12-19-0:before {\r\n -webkit-transform-origin: left top;\r\n transform-origin: left top;\r\n left: 50%;\r\n top: 0;\r\n }\r\n\r\n.popover-tip--top__popover__12-19-0:before {\r\n -webkit-transform-origin: right bottom;\r\n transform-origin: right bottom;\r\n right: 50%;\r\n bottom: 0;\r\n }\r\n\r\n.popover-tip--left__popover__12-19-0:before {\r\n -webkit-transform-origin: right top;\r\n transform-origin: right top;\r\n right: 0;\r\n top: 50%;\r\n }\r\n\r\n.popover-tip--right__popover__12-19-0:before {\r\n -webkit-transform-origin: left bottom;\r\n transform-origin: left bottom;\r\n left: 0;\r\n bottom: 50%;\r\n }\r\n";
209
+ var styles = {"popover-body-container":"popover-body-container__popover__12-19-0","popover-body":"popover-body__popover__12-19-0","popover-body--no-padding":"popover-body--no-padding__popover__12-19-0","popover-tip":"popover-tip__popover__12-19-0","popover-tip--bottom":"popover-tip--bottom__popover__12-19-0","popover-tip--top":"popover-tip--top__popover__12-19-0","popover-tip--left":"popover-tip--left__popover__12-19-0","popover-tip--right":"popover-tip--right__popover__12-19-0"};
203
210
  styleInject(css);
204
211
 
205
212
  var PopoverBody = function PopoverBody(_ref) {
206
213
  var children = _ref.children,
207
- className = _ref.className,
208
- classNameBody = _ref.classNameBody,
209
- noPadding = _ref.noPadding;
214
+ className = _ref.className,
215
+ classNameBody = _ref.classNameBody,
216
+ noPadding = _ref.noPadding;
210
217
  return React.createElement("div", {
211
218
  className: classNames(className, styles['popover-body-container'])
212
219
  }, React.createElement("div", {
@@ -221,7 +228,6 @@ var throttle = function throttle(func, limit) {
221
228
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
222
229
  args[_key] = arguments[_key];
223
230
  }
224
-
225
231
  if (lastRan) {
226
232
  clearTimeout(lastFunc);
227
233
  lastFunc = setTimeout(function () {
@@ -240,17 +246,14 @@ var throttle = function throttle(func, limit) {
240
246
  var isScrollParent = function isScrollParent(element) {
241
247
  // Firefox wants us to check `-x` and `-y` variations as well
242
248
  var _getComputedStyle = getComputedStyle(element),
243
- overflow = _getComputedStyle.overflow,
244
- overflowX = _getComputedStyle.overflowX,
245
- overflowY = _getComputedStyle.overflowY;
246
-
249
+ overflow = _getComputedStyle.overflow,
250
+ overflowX = _getComputedStyle.overflowX,
251
+ overflowY = _getComputedStyle.overflowY;
247
252
  return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
248
253
  };
249
-
250
254
  function getNodeName(element) {
251
255
  return element ? (element.nodeName || '').toLowerCase() : null;
252
256
  }
253
-
254
257
  function getNodeScroll(node) {
255
258
  if (node === window) {
256
259
  return {
@@ -258,25 +261,22 @@ function getNodeScroll(node) {
258
261
  scrollTop: window.pageYOffset
259
262
  };
260
263
  }
261
-
262
264
  return {
263
265
  scrollLeft: node.scrollLeft,
264
266
  scrollTop: node.scrollTop
265
267
  };
266
268
  }
267
-
268
269
  var getCompositeRect = function getCompositeRect(elementOrVirtualElement, offsetParent) {
269
270
  var rect = elementOrVirtualElement.getBoundingClientRect();
270
271
  var scroll = {
271
272
  scrollLeft: 0,
272
273
  scrollTop: 0
273
274
  };
274
-
275
- if ( // https://github.com/popperjs/popper-core/issues/1078
275
+ if (
276
+ // https://github.com/popperjs/popper-core/issues/1078
276
277
  getNodeName(offsetParent) !== 'body' || isScrollParent(document.documentElement)) {
277
278
  scroll = getNodeScroll(offsetParent);
278
279
  }
279
-
280
280
  var offsets = offsetParent.getBoundingClientRect();
281
281
  offsets.x += offsetParent.clientLeft;
282
282
  offsets.y += offsetParent.clientTop;
@@ -289,15 +289,11 @@ var getCompositeRect = function getCompositeRect(elementOrVirtualElement, offset
289
289
  height: rect.height
290
290
  };
291
291
  };
292
-
293
292
  var PopoverContainer = /*#__PURE__*/function (_React$Component) {
294
293
  _inherits(PopoverContainer, _React$Component);
295
-
296
294
  function PopoverContainer() {
297
295
  var _this;
298
-
299
296
  _classCallCheck(this, PopoverContainer);
300
-
301
297
  _this = _possibleConstructorReturn(this, _getPrototypeOf(PopoverContainer).apply(this, arguments));
302
298
  _this.mounted = false;
303
299
  _this.popoverContentRef = React.createRef();
@@ -306,47 +302,36 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
306
302
  positionX: 0,
307
303
  positionY: 0
308
304
  };
309
-
310
305
  _this.onResize = function () {
311
306
  return _this.adjustPosition();
312
307
  };
313
-
314
308
  _this.onScroll = throttle(function () {
315
309
  _this.adjustPosition();
316
310
  }, _this.props.scrollThrottleIntervalMs || 200);
317
-
318
311
  _this.getPopoverTipPosition = function (popoverPosition, containerPosition) {
319
312
  if (popoverPosition.bottom && popoverPosition.bottom >= containerPosition.height) {
320
313
  return 'top';
321
314
  }
322
-
323
315
  if (popoverPosition.top && popoverPosition.top >= containerPosition.height) {
324
316
  return 'bottom';
325
317
  }
326
-
327
318
  if (popoverPosition.left && popoverPosition.left >= containerPosition.width) {
328
319
  return 'right';
329
320
  }
330
-
331
321
  if (popoverPosition.right && popoverPosition.right >= containerPosition.width) {
332
322
  return 'left';
333
323
  }
334
-
335
324
  return null;
336
325
  };
337
-
338
326
  return _this;
339
327
  }
340
-
341
328
  _createClass(PopoverContainer, [{
342
329
  key: "adjustPosition",
343
330
  value: function adjustPosition() {
344
331
  var _this2 = this;
345
-
346
332
  if (!this.mounted) {
347
333
  return;
348
334
  }
349
-
350
335
  var containerElement = this.props.containerElement || document.body;
351
336
  var positioningBoundingRect = getCompositeRect(this.props.positioningTarget, this.props.containerElement);
352
337
  this.setState({
@@ -380,11 +365,9 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
380
365
  value: function componentDidMount() {
381
366
  this.mounted = true;
382
367
  this.adjustPosition();
383
-
384
368
  if (this.props.trackScroll) {
385
369
  document.addEventListener('scroll', this.onScroll);
386
370
  window.addEventListener('resize', this.onResize);
387
-
388
371
  if (this.props.containerElement && this.props.containerElement !== document.body) {
389
372
  this.props.containerElement.addEventListener('scroll', this.onScroll);
390
373
  }
@@ -401,11 +384,9 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
401
384
  key: "componentWillUnmount",
402
385
  value: function componentWillUnmount() {
403
386
  this.mounted = false;
404
-
405
387
  if (this.onScroll && this.props.trackScroll) {
406
388
  document.body.removeEventListener('scroll', this.onScroll);
407
389
  window.removeEventListener('resize', this.onResize);
408
-
409
390
  if (this.props.containerElement && this.props.containerElement !== document.body) {
410
391
  this.props.containerElement.removeEventListener('scroll', this.onScroll);
411
392
  }
@@ -422,8 +403,8 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
422
403
  width: this.state.hostRect && this.state.hostRect.width,
423
404
  height: this.state.hostRect && this.state.hostRect.height
424
405
  };
425
- var tipPosition = this.getPopoverTipPosition(position, containerPosition); // FIXME: position.top cast to number, because value may be not a number
426
-
406
+ var tipPosition = this.getPopoverTipPosition(position, containerPosition);
407
+ // FIXME: position.top cast to number, because value may be not a number
427
408
  return React.createElement("div", {
428
409
  style: _extends({
429
410
  position: 'absolute'
@@ -452,7 +433,6 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
452
433
  }, this.props.children));
453
434
  }
454
435
  }]);
455
-
456
436
  return PopoverContainer;
457
437
  }(React.Component);
458
438
  PopoverContainer.defaultProps = {
@@ -461,12 +441,9 @@ PopoverContainer.defaultProps = {
461
441
 
462
442
  var PositioningTarget = /*#__PURE__*/function (_React$Component) {
463
443
  _inherits(PositioningTarget, _React$Component);
464
-
465
444
  function PositioningTarget() {
466
445
  var _this;
467
-
468
446
  _classCallCheck(this, PositioningTarget);
469
-
470
447
  _this = _possibleConstructorReturn(this, _getPrototypeOf(PositioningTarget).apply(this, arguments));
471
448
  _this.state = {
472
449
  target: null
@@ -474,7 +451,6 @@ var PositioningTarget = /*#__PURE__*/function (_React$Component) {
474
451
  _this.targetRef = React.createRef();
475
452
  return _this;
476
453
  }
477
-
478
454
  _createClass(PositioningTarget, [{
479
455
  key: "componentDidMount",
480
456
  value: function componentDidMount() {
@@ -490,29 +466,23 @@ var PositioningTarget = /*#__PURE__*/function (_React$Component) {
490
466
  }, this.props.children(this.state.target));
491
467
  }
492
468
  }]);
493
-
494
469
  return PositioningTarget;
495
470
  }(React.Component);
496
471
 
497
472
  var BodyDomNode = /*#__PURE__*/function (_React$Component) {
498
473
  _inherits(BodyDomNode, _React$Component);
499
-
500
474
  function BodyDomNode() {
501
475
  var _this;
502
-
503
476
  _classCallCheck(this, BodyDomNode);
504
-
505
477
  _this = _possibleConstructorReturn(this, _getPrototypeOf(BodyDomNode).apply(this, arguments));
506
478
  _this.state = {
507
479
  node: null
508
480
  };
509
-
510
481
  _this._onEvent = function (event) {
511
482
  if (!_this.state.node.contains(event.target) && !_this.props.positioningTarget.contains(event.target)) {
512
483
  _this.props.onOuterAction(event);
513
484
  }
514
485
  };
515
-
516
486
  _this._addDocumentEventListeners = function () {
517
487
  if (_this.props.outerActionEvents && _this.props.onOuterAction) {
518
488
  _this.props.outerActionEvents.forEach(function (event) {
@@ -520,20 +490,16 @@ var BodyDomNode = /*#__PURE__*/function (_React$Component) {
520
490
  });
521
491
  }
522
492
  };
523
-
524
493
  _this._removeDocumentEventListeners = function () {
525
494
  var outerActionEvents = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.props.outerActionEvents;
526
-
527
495
  if (outerActionEvents) {
528
496
  outerActionEvents.forEach(function (event) {
529
497
  return document.removeEventListener(event, _this._onEvent);
530
498
  });
531
499
  }
532
500
  };
533
-
534
501
  return _this;
535
502
  }
536
-
537
503
  _createClass(BodyDomNode, [{
538
504
  key: "componentDidMount",
539
505
  value: function componentDidMount() {
@@ -548,7 +514,6 @@ var BodyDomNode = /*#__PURE__*/function (_React$Component) {
548
514
  value: function componentDidUpdate(prevProps) {
549
515
  if (prevProps.outerActionEvents !== this.props.outerActionEvents || prevProps.onOuterAction !== this.props.onOuterAction) {
550
516
  this._removeDocumentEventListeners(prevProps.outerActionEvents);
551
-
552
517
  this._addDocumentEventListeners();
553
518
  }
554
519
  }
@@ -557,7 +522,6 @@ var BodyDomNode = /*#__PURE__*/function (_React$Component) {
557
522
  value: function componentWillUnmount() {
558
523
  if (this.state.node) {
559
524
  this.props.containerElement.removeChild(this.state.node);
560
-
561
525
  this._removeDocumentEventListeners();
562
526
  }
563
527
  }
@@ -567,7 +531,6 @@ var BodyDomNode = /*#__PURE__*/function (_React$Component) {
567
531
  return this.props.children(this.state.node);
568
532
  }
569
533
  }]);
570
-
571
534
  return BodyDomNode;
572
535
  }(React.Component);
573
536
  BodyDomNode.defaultProps = {
@@ -576,27 +539,21 @@ BodyDomNode.defaultProps = {
576
539
 
577
540
  var StatelessPopover = /*#__PURE__*/function (_React$Component) {
578
541
  _inherits(StatelessPopover, _React$Component);
579
-
580
542
  function StatelessPopover() {
581
543
  var _this;
582
-
583
544
  _classCallCheck(this, StatelessPopover);
584
-
585
545
  _this = _possibleConstructorReturn(this, _getPrototypeOf(StatelessPopover).apply(this, arguments));
586
-
587
546
  _this.getContainer = function () {
588
547
  return _this.props.getContainerElement && _this.props.getContainerElement() || document.body;
589
548
  };
590
-
591
549
  return _this;
592
550
  }
593
-
594
551
  _createClass(StatelessPopover, [{
595
552
  key: "renderPortalContent",
596
553
  value: function renderPortalContent(_ref) {
597
554
  var props = _ref.props,
598
- container = _ref.container,
599
- positioningTarget = _ref.positioningTarget;
555
+ container = _ref.container,
556
+ positioningTarget = _ref.positioningTarget;
600
557
  var popoverContent = React.createElement(PopoverContainer, {
601
558
  key: "popover-portal",
602
559
  getPopoverPosition: this.props.getPopoverPosition,
@@ -608,22 +565,18 @@ var StatelessPopover = /*#__PURE__*/function (_React$Component) {
608
565
  zIndex: props.zIndex,
609
566
  trackScroll: props.trackScroll
610
567
  }, props.body);
611
-
612
568
  if (!props.inline) {
613
569
  return ReactDOM.createPortal(popoverContent, container);
614
570
  }
615
-
616
571
  return popoverContent;
617
572
  }
618
573
  }, {
619
574
  key: "renderPortal",
620
575
  value: function renderPortal(positioningTarget) {
621
576
  var _this2 = this;
622
-
623
577
  if (!this.props.isOpen) {
624
578
  return null;
625
579
  }
626
-
627
580
  return this.props.inline ? this.renderPortalContent({
628
581
  props: this.props,
629
582
  positioningTarget: positioningTarget
@@ -644,48 +597,38 @@ var StatelessPopover = /*#__PURE__*/function (_React$Component) {
644
597
  key: "render",
645
598
  value: function render() {
646
599
  var _this3 = this;
647
-
648
600
  return React.createElement(PositioningTarget, null, function (positioningTarget) {
649
601
  return positioningTarget ? React.createElement(React.Fragment, null, _this3.props.children, _this3.renderPortal(positioningTarget)) : null;
650
602
  });
651
603
  }
652
604
  }]);
653
-
654
605
  return StatelessPopover;
655
606
  }(React.Component);
656
607
 
657
608
  var Popover = /*#__PURE__*/function (_React$Component) {
658
609
  _inherits(Popover, _React$Component);
659
-
660
610
  function Popover() {
661
611
  var _this;
662
-
663
612
  _classCallCheck(this, Popover);
664
-
665
613
  _this = _possibleConstructorReturn(this, _getPrototypeOf(Popover).apply(this, arguments));
666
614
  _this.state = {
667
615
  isOpen: false
668
616
  };
669
-
670
617
  _this.setOpened = function (isOpen) {
671
618
  _this.setState({
672
619
  isOpen: isOpen
673
620
  });
674
621
  };
675
-
676
622
  _this.onOuterAction = function (event) {
677
623
  if (_this.props.closeOnOuterAction) {
678
624
  _this.setOpened(false);
679
625
  }
680
-
681
626
  if (_this.props.onOuterAction) {
682
627
  _this.props.onOuterAction(event);
683
628
  }
684
629
  };
685
-
686
630
  return _this;
687
631
  }
688
-
689
632
  _createClass(Popover, [{
690
633
  key: "render",
691
634
  value: function render() {
@@ -700,7 +643,6 @@ var Popover = /*#__PURE__*/function (_React$Component) {
700
643
  }), children);
701
644
  }
702
645
  }]);
703
-
704
646
  return Popover;
705
647
  }(React.Component);
706
648
  Popover.Body = PopoverBody;
package/dist/popover.js CHANGED
@@ -14,46 +14,41 @@ function _classCallCheck(instance, Constructor) {
14
14
  throw new TypeError("Cannot call a class as a function");
15
15
  }
16
16
  }
17
-
18
17
  function _defineProperties(target, props) {
19
18
  for (var i = 0; i < props.length; i++) {
20
19
  var descriptor = props[i];
21
20
  descriptor.enumerable = descriptor.enumerable || false;
22
21
  descriptor.configurable = true;
23
22
  if ("value" in descriptor) descriptor.writable = true;
24
- Object.defineProperty(target, descriptor.key, descriptor);
23
+ Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
25
24
  }
26
25
  }
27
-
28
26
  function _createClass(Constructor, protoProps, staticProps) {
29
27
  if (protoProps) _defineProperties(Constructor.prototype, protoProps);
30
28
  if (staticProps) _defineProperties(Constructor, staticProps);
29
+ Object.defineProperty(Constructor, "prototype", {
30
+ writable: false
31
+ });
31
32
  return Constructor;
32
33
  }
33
-
34
34
  function _extends() {
35
- _extends = Object.assign || function (target) {
35
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
36
36
  for (var i = 1; i < arguments.length; i++) {
37
37
  var source = arguments[i];
38
-
39
38
  for (var key in source) {
40
39
  if (Object.prototype.hasOwnProperty.call(source, key)) {
41
40
  target[key] = source[key];
42
41
  }
43
42
  }
44
43
  }
45
-
46
44
  return target;
47
45
  };
48
-
49
46
  return _extends.apply(this, arguments);
50
47
  }
51
-
52
48
  function _inherits(subClass, superClass) {
53
49
  if (typeof superClass !== "function" && superClass !== null) {
54
50
  throw new TypeError("Super expression must either be null or a function");
55
51
  }
56
-
57
52
  subClass.prototype = Object.create(superClass && superClass.prototype, {
58
53
  constructor: {
59
54
  value: subClass,
@@ -61,40 +56,52 @@ function _inherits(subClass, superClass) {
61
56
  configurable: true
62
57
  }
63
58
  });
59
+ Object.defineProperty(subClass, "prototype", {
60
+ writable: false
61
+ });
64
62
  if (superClass) _setPrototypeOf(subClass, superClass);
65
63
  }
66
-
67
64
  function _getPrototypeOf(o) {
68
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
65
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
69
66
  return o.__proto__ || Object.getPrototypeOf(o);
70
67
  };
71
68
  return _getPrototypeOf(o);
72
69
  }
73
-
74
70
  function _setPrototypeOf(o, p) {
75
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
71
+ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
76
72
  o.__proto__ = p;
77
73
  return o;
78
74
  };
79
-
80
75
  return _setPrototypeOf(o, p);
81
76
  }
82
-
83
77
  function _assertThisInitialized(self) {
84
78
  if (self === void 0) {
85
79
  throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
86
80
  }
87
-
88
81
  return self;
89
82
  }
90
-
91
83
  function _possibleConstructorReturn(self, call) {
92
84
  if (call && (typeof call === "object" || typeof call === "function")) {
93
85
  return call;
86
+ } else if (call !== void 0) {
87
+ throw new TypeError("Derived constructors may only return object or undefined");
94
88
  }
95
-
96
89
  return _assertThisInitialized(self);
97
90
  }
91
+ function _toPrimitive(input, hint) {
92
+ if (typeof input !== "object" || input === null) return input;
93
+ var prim = input[Symbol.toPrimitive];
94
+ if (prim !== undefined) {
95
+ var res = prim.call(input, hint || "default");
96
+ if (typeof res !== "object") return res;
97
+ throw new TypeError("@@toPrimitive must return a primitive value.");
98
+ }
99
+ return (hint === "string" ? String : Number)(input);
100
+ }
101
+ function _toPropertyKey(arg) {
102
+ var key = _toPrimitive(arg, "string");
103
+ return typeof key === "symbol" ? key : String(key);
104
+ }
98
105
 
99
106
  var PopoverPosition = {
100
107
  bottomLeft: function bottomLeft(hostRect, popoverRect, containerScroll) {
@@ -204,15 +211,15 @@ function styleInject(css, ref) {
204
211
  }
205
212
  }
206
213
 
207
- var css = ".popover-body-container__popover__12-7-4 {\r\n -webkit-box-shadow: var(--BoxShadowL, 0 4px 16px 0 rgba(0, 0, 0, 0.12));\r\n box-shadow: var(--BoxShadowL, 0 4px 16px 0 rgba(0, 0, 0, 0.12));\r\n border-radius: var(--BorderRadiusL, 4px);\r\n border: 1px solid var(--HighlightBlockBorderColor, rgba(64, 66, 73, 0.1));\r\n background: var(--BackgroundDefault, #FFFFFF);\r\n z-index: var(--ZIndexModal, 10001);\r\n -webkit-box-sizing: border-box;\r\n box-sizing: border-box;\r\n}\r\n\r\n.popover-body__popover__12-7-4 {\r\n -webkit-box-sizing: border-box;\r\n box-sizing: border-box;\r\n padding: var(--SpaceSM, 12px);\r\n font-size: var(--FontSizeDefault, 13px);\r\n color: var(--FontColorDefault, #000000);\r\n}\r\n\r\n.popover-body--no-padding__popover__12-7-4 {\r\n padding: 0;\r\n }\r\n\r\n.popover-tip__popover__12-7-4 {\r\n position: absolute;\r\n pointer-events: none;\r\n z-index: calc(var(--ZIndexModal, 10001) + 1);\r\n overflow: hidden;\r\n display: -webkit-box;\r\n display: -ms-flexbox;\r\n display: flex;\r\n -webkit-box-align: center;\r\n -ms-flex-align: center;\r\n align-items: center;\r\n -webkit-box-pack: center;\r\n -ms-flex-pack: center;\r\n justify-content: center;\r\n}\r\n\r\n.popover-tip__popover__12-7-4:before {\r\n content: '';\r\n position: absolute;\r\n display: block;\r\n -webkit-box-sizing: border-box;\r\n box-sizing: border-box;\r\n background-color: var(--BackgroundDefault, #FFFFFF);\r\n border: 1px solid var(--HighlightBlockBorderColor, rgba(64, 66, 73, 0.1));\r\n /*\r\n geometry FTW\r\n\r\n 2*$popoverTipSize\r\n _______ _______\r\n | /|\\ |\r\n | / | \\ | $popoverTipSize\r\n | / | \\ |\r\n |/______|______\\|\r\n since tip is rotated 45 degrees, its width and height is a\r\n diagonal of a square with side=$popoverTipSize, thus diagonal\r\n is sqrt(2) * $popoverTipSize.\r\n sqrt(2) ~= 1.414, 1.4 used here to prevent too much rounding\r\n */\r\n width: 11.2px;\r\n height: 11.2px;\r\n -webkit-transform: rotate(45deg);\r\n transform: rotate(45deg);\r\n }\r\n\r\n.popover-tip--bottom__popover__12-7-4,\r\n .popover-tip--top__popover__12-7-4 {\r\n width: 100%;\r\n border-top: 1px var(--BackgroundDefault, #FFFFFF);\r\n border-bottom: 1px var(--BackgroundDefault, #FFFFFF);\r\n height: 9px;\r\n }\r\n\r\n.popover-tip--left__popover__12-7-4,\r\n .popover-tip--right__popover__12-7-4 {\r\n border-left: 1px var(--BackgroundDefault, #FFFFFF);\r\n border-right: 1px var(--BackgroundDefault, #FFFFFF);\r\n height: 100%;\r\n width: 9px;\r\n }\r\n\r\n/*\r\n To determine tip position, we need to rotate it\r\n along the \"tip\" point, after that, the \"tip\" point\r\n can be placed with exactly 50% offset from the origin\r\n so that it is centered.\r\n */\r\n\r\n.popover-tip--bottom__popover__12-7-4:before {\r\n -webkit-transform-origin: left top;\r\n transform-origin: left top;\r\n left: 50%;\r\n top: 0;\r\n }\r\n\r\n.popover-tip--top__popover__12-7-4:before {\r\n -webkit-transform-origin: right bottom;\r\n transform-origin: right bottom;\r\n right: 50%;\r\n bottom: 0;\r\n }\r\n\r\n.popover-tip--left__popover__12-7-4:before {\r\n -webkit-transform-origin: right top;\r\n transform-origin: right top;\r\n right: 0;\r\n top: 50%;\r\n }\r\n\r\n.popover-tip--right__popover__12-7-4:before {\r\n -webkit-transform-origin: left bottom;\r\n transform-origin: left bottom;\r\n left: 0;\r\n bottom: 50%;\r\n }\r\n";
208
- var styles = {"popover-body-container":"popover-body-container__popover__12-7-4","popover-body":"popover-body__popover__12-7-4","popover-body--no-padding":"popover-body--no-padding__popover__12-7-4","popover-tip":"popover-tip__popover__12-7-4","popover-tip--bottom":"popover-tip--bottom__popover__12-7-4","popover-tip--top":"popover-tip--top__popover__12-7-4","popover-tip--left":"popover-tip--left__popover__12-7-4","popover-tip--right":"popover-tip--right__popover__12-7-4"};
214
+ var css = ".popover-body-container__popover__12-19-0 {\r\n -webkit-box-shadow: var(--BoxShadowL, 0 4px 16px 0 rgba(0, 0, 0, 0.12));\r\n box-shadow: var(--BoxShadowL, 0 4px 16px 0 rgba(0, 0, 0, 0.12));\r\n border-radius: var(--BorderRadiusL, 4px);\r\n border: 1px solid var(--HighlightBlockBorderColor, rgba(64, 66, 73, 0.1));\r\n background: var(--BackgroundDefault, #FFFFFF);\r\n z-index: var(--ZIndexModal, 10001);\r\n -webkit-box-sizing: border-box;\r\n box-sizing: border-box;\r\n}\r\n\r\n.popover-body__popover__12-19-0 {\r\n -webkit-box-sizing: border-box;\r\n box-sizing: border-box;\r\n padding: var(--SpaceSM, 12px);\r\n font-size: var(--FontSizeDefault, 13px);\r\n color: var(--FontColorDefault, #000000);\r\n}\r\n\r\n.popover-body--no-padding__popover__12-19-0 {\r\n padding: 0;\r\n }\r\n\r\n.popover-tip__popover__12-19-0 {\r\n position: absolute;\r\n pointer-events: none;\r\n z-index: calc(var(--ZIndexModal, 10001) + 1);\r\n overflow: hidden;\r\n display: -webkit-box;\r\n display: -ms-flexbox;\r\n display: flex;\r\n -webkit-box-align: center;\r\n -ms-flex-align: center;\r\n align-items: center;\r\n -webkit-box-pack: center;\r\n -ms-flex-pack: center;\r\n justify-content: center;\r\n}\r\n\r\n.popover-tip__popover__12-19-0:before {\r\n content: '';\r\n position: absolute;\r\n display: block;\r\n -webkit-box-sizing: border-box;\r\n box-sizing: border-box;\r\n background-color: var(--BackgroundDefault, #FFFFFF);\r\n border: 1px solid var(--HighlightBlockBorderColor, rgba(64, 66, 73, 0.1));\r\n /*\r\n geometry FTW\r\n\r\n 2*$popoverTipSize\r\n _______ _______\r\n | /|\\ |\r\n | / | \\ | $popoverTipSize\r\n | / | \\ |\r\n |/______|______\\|\r\n since tip is rotated 45 degrees, its width and height is a\r\n diagonal of a square with side=$popoverTipSize, thus diagonal\r\n is sqrt(2) * $popoverTipSize.\r\n sqrt(2) ~= 1.414, 1.4 used here to prevent too much rounding\r\n */\r\n width: 11.2px;\r\n height: 11.2px;\r\n -webkit-transform: rotate(45deg);\r\n transform: rotate(45deg);\r\n }\r\n\r\n.popover-tip--bottom__popover__12-19-0,\r\n .popover-tip--top__popover__12-19-0 {\r\n width: 100%;\r\n border-top: 1px var(--BackgroundDefault, #FFFFFF);\r\n border-bottom: 1px var(--BackgroundDefault, #FFFFFF);\r\n height: 9px;\r\n }\r\n\r\n.popover-tip--left__popover__12-19-0,\r\n .popover-tip--right__popover__12-19-0 {\r\n border-left: 1px var(--BackgroundDefault, #FFFFFF);\r\n border-right: 1px var(--BackgroundDefault, #FFFFFF);\r\n height: 100%;\r\n width: 9px;\r\n }\r\n\r\n/*\r\n To determine tip position, we need to rotate it\r\n along the \"tip\" point, after that, the \"tip\" point\r\n can be placed with exactly 50% offset from the origin\r\n so that it is centered.\r\n */\r\n\r\n.popover-tip--bottom__popover__12-19-0:before {\r\n -webkit-transform-origin: left top;\r\n transform-origin: left top;\r\n left: 50%;\r\n top: 0;\r\n }\r\n\r\n.popover-tip--top__popover__12-19-0:before {\r\n -webkit-transform-origin: right bottom;\r\n transform-origin: right bottom;\r\n right: 50%;\r\n bottom: 0;\r\n }\r\n\r\n.popover-tip--left__popover__12-19-0:before {\r\n -webkit-transform-origin: right top;\r\n transform-origin: right top;\r\n right: 0;\r\n top: 50%;\r\n }\r\n\r\n.popover-tip--right__popover__12-19-0:before {\r\n -webkit-transform-origin: left bottom;\r\n transform-origin: left bottom;\r\n left: 0;\r\n bottom: 50%;\r\n }\r\n";
215
+ var styles = {"popover-body-container":"popover-body-container__popover__12-19-0","popover-body":"popover-body__popover__12-19-0","popover-body--no-padding":"popover-body--no-padding__popover__12-19-0","popover-tip":"popover-tip__popover__12-19-0","popover-tip--bottom":"popover-tip--bottom__popover__12-19-0","popover-tip--top":"popover-tip--top__popover__12-19-0","popover-tip--left":"popover-tip--left__popover__12-19-0","popover-tip--right":"popover-tip--right__popover__12-19-0"};
209
216
  styleInject(css);
210
217
 
211
218
  var PopoverBody = function PopoverBody(_ref) {
212
219
  var children = _ref.children,
213
- className = _ref.className,
214
- classNameBody = _ref.classNameBody,
215
- noPadding = _ref.noPadding;
220
+ className = _ref.className,
221
+ classNameBody = _ref.classNameBody,
222
+ noPadding = _ref.noPadding;
216
223
  return React.createElement("div", {
217
224
  className: classNames(className, styles['popover-body-container'])
218
225
  }, React.createElement("div", {
@@ -227,7 +234,6 @@ var throttle = function throttle(func, limit) {
227
234
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
228
235
  args[_key] = arguments[_key];
229
236
  }
230
-
231
237
  if (lastRan) {
232
238
  clearTimeout(lastFunc);
233
239
  lastFunc = setTimeout(function () {
@@ -246,17 +252,14 @@ var throttle = function throttle(func, limit) {
246
252
  var isScrollParent = function isScrollParent(element) {
247
253
  // Firefox wants us to check `-x` and `-y` variations as well
248
254
  var _getComputedStyle = getComputedStyle(element),
249
- overflow = _getComputedStyle.overflow,
250
- overflowX = _getComputedStyle.overflowX,
251
- overflowY = _getComputedStyle.overflowY;
252
-
255
+ overflow = _getComputedStyle.overflow,
256
+ overflowX = _getComputedStyle.overflowX,
257
+ overflowY = _getComputedStyle.overflowY;
253
258
  return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
254
259
  };
255
-
256
260
  function getNodeName(element) {
257
261
  return element ? (element.nodeName || '').toLowerCase() : null;
258
262
  }
259
-
260
263
  function getNodeScroll(node) {
261
264
  if (node === window) {
262
265
  return {
@@ -264,25 +267,22 @@ function getNodeScroll(node) {
264
267
  scrollTop: window.pageYOffset
265
268
  };
266
269
  }
267
-
268
270
  return {
269
271
  scrollLeft: node.scrollLeft,
270
272
  scrollTop: node.scrollTop
271
273
  };
272
274
  }
273
-
274
275
  var getCompositeRect = function getCompositeRect(elementOrVirtualElement, offsetParent) {
275
276
  var rect = elementOrVirtualElement.getBoundingClientRect();
276
277
  var scroll = {
277
278
  scrollLeft: 0,
278
279
  scrollTop: 0
279
280
  };
280
-
281
- if ( // https://github.com/popperjs/popper-core/issues/1078
281
+ if (
282
+ // https://github.com/popperjs/popper-core/issues/1078
282
283
  getNodeName(offsetParent) !== 'body' || isScrollParent(document.documentElement)) {
283
284
  scroll = getNodeScroll(offsetParent);
284
285
  }
285
-
286
286
  var offsets = offsetParent.getBoundingClientRect();
287
287
  offsets.x += offsetParent.clientLeft;
288
288
  offsets.y += offsetParent.clientTop;
@@ -295,15 +295,11 @@ var getCompositeRect = function getCompositeRect(elementOrVirtualElement, offset
295
295
  height: rect.height
296
296
  };
297
297
  };
298
-
299
298
  var PopoverContainer = /*#__PURE__*/function (_React$Component) {
300
299
  _inherits(PopoverContainer, _React$Component);
301
-
302
300
  function PopoverContainer() {
303
301
  var _this;
304
-
305
302
  _classCallCheck(this, PopoverContainer);
306
-
307
303
  _this = _possibleConstructorReturn(this, _getPrototypeOf(PopoverContainer).apply(this, arguments));
308
304
  _this.mounted = false;
309
305
  _this.popoverContentRef = React.createRef();
@@ -312,47 +308,36 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
312
308
  positionX: 0,
313
309
  positionY: 0
314
310
  };
315
-
316
311
  _this.onResize = function () {
317
312
  return _this.adjustPosition();
318
313
  };
319
-
320
314
  _this.onScroll = throttle(function () {
321
315
  _this.adjustPosition();
322
316
  }, _this.props.scrollThrottleIntervalMs || 200);
323
-
324
317
  _this.getPopoverTipPosition = function (popoverPosition, containerPosition) {
325
318
  if (popoverPosition.bottom && popoverPosition.bottom >= containerPosition.height) {
326
319
  return 'top';
327
320
  }
328
-
329
321
  if (popoverPosition.top && popoverPosition.top >= containerPosition.height) {
330
322
  return 'bottom';
331
323
  }
332
-
333
324
  if (popoverPosition.left && popoverPosition.left >= containerPosition.width) {
334
325
  return 'right';
335
326
  }
336
-
337
327
  if (popoverPosition.right && popoverPosition.right >= containerPosition.width) {
338
328
  return 'left';
339
329
  }
340
-
341
330
  return null;
342
331
  };
343
-
344
332
  return _this;
345
333
  }
346
-
347
334
  _createClass(PopoverContainer, [{
348
335
  key: "adjustPosition",
349
336
  value: function adjustPosition() {
350
337
  var _this2 = this;
351
-
352
338
  if (!this.mounted) {
353
339
  return;
354
340
  }
355
-
356
341
  var containerElement = this.props.containerElement || document.body;
357
342
  var positioningBoundingRect = getCompositeRect(this.props.positioningTarget, this.props.containerElement);
358
343
  this.setState({
@@ -386,11 +371,9 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
386
371
  value: function componentDidMount() {
387
372
  this.mounted = true;
388
373
  this.adjustPosition();
389
-
390
374
  if (this.props.trackScroll) {
391
375
  document.addEventListener('scroll', this.onScroll);
392
376
  window.addEventListener('resize', this.onResize);
393
-
394
377
  if (this.props.containerElement && this.props.containerElement !== document.body) {
395
378
  this.props.containerElement.addEventListener('scroll', this.onScroll);
396
379
  }
@@ -407,11 +390,9 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
407
390
  key: "componentWillUnmount",
408
391
  value: function componentWillUnmount() {
409
392
  this.mounted = false;
410
-
411
393
  if (this.onScroll && this.props.trackScroll) {
412
394
  document.body.removeEventListener('scroll', this.onScroll);
413
395
  window.removeEventListener('resize', this.onResize);
414
-
415
396
  if (this.props.containerElement && this.props.containerElement !== document.body) {
416
397
  this.props.containerElement.removeEventListener('scroll', this.onScroll);
417
398
  }
@@ -428,8 +409,8 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
428
409
  width: this.state.hostRect && this.state.hostRect.width,
429
410
  height: this.state.hostRect && this.state.hostRect.height
430
411
  };
431
- var tipPosition = this.getPopoverTipPosition(position, containerPosition); // FIXME: position.top cast to number, because value may be not a number
432
-
412
+ var tipPosition = this.getPopoverTipPosition(position, containerPosition);
413
+ // FIXME: position.top cast to number, because value may be not a number
433
414
  return React.createElement("div", {
434
415
  style: _extends({
435
416
  position: 'absolute'
@@ -458,7 +439,6 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
458
439
  }, this.props.children));
459
440
  }
460
441
  }]);
461
-
462
442
  return PopoverContainer;
463
443
  }(React.Component);
464
444
  PopoverContainer.defaultProps = {
@@ -467,12 +447,9 @@ PopoverContainer.defaultProps = {
467
447
 
468
448
  var PositioningTarget = /*#__PURE__*/function (_React$Component) {
469
449
  _inherits(PositioningTarget, _React$Component);
470
-
471
450
  function PositioningTarget() {
472
451
  var _this;
473
-
474
452
  _classCallCheck(this, PositioningTarget);
475
-
476
453
  _this = _possibleConstructorReturn(this, _getPrototypeOf(PositioningTarget).apply(this, arguments));
477
454
  _this.state = {
478
455
  target: null
@@ -480,7 +457,6 @@ var PositioningTarget = /*#__PURE__*/function (_React$Component) {
480
457
  _this.targetRef = React.createRef();
481
458
  return _this;
482
459
  }
483
-
484
460
  _createClass(PositioningTarget, [{
485
461
  key: "componentDidMount",
486
462
  value: function componentDidMount() {
@@ -496,29 +472,23 @@ var PositioningTarget = /*#__PURE__*/function (_React$Component) {
496
472
  }, this.props.children(this.state.target));
497
473
  }
498
474
  }]);
499
-
500
475
  return PositioningTarget;
501
476
  }(React.Component);
502
477
 
503
478
  var BodyDomNode = /*#__PURE__*/function (_React$Component) {
504
479
  _inherits(BodyDomNode, _React$Component);
505
-
506
480
  function BodyDomNode() {
507
481
  var _this;
508
-
509
482
  _classCallCheck(this, BodyDomNode);
510
-
511
483
  _this = _possibleConstructorReturn(this, _getPrototypeOf(BodyDomNode).apply(this, arguments));
512
484
  _this.state = {
513
485
  node: null
514
486
  };
515
-
516
487
  _this._onEvent = function (event) {
517
488
  if (!_this.state.node.contains(event.target) && !_this.props.positioningTarget.contains(event.target)) {
518
489
  _this.props.onOuterAction(event);
519
490
  }
520
491
  };
521
-
522
492
  _this._addDocumentEventListeners = function () {
523
493
  if (_this.props.outerActionEvents && _this.props.onOuterAction) {
524
494
  _this.props.outerActionEvents.forEach(function (event) {
@@ -526,20 +496,16 @@ var BodyDomNode = /*#__PURE__*/function (_React$Component) {
526
496
  });
527
497
  }
528
498
  };
529
-
530
499
  _this._removeDocumentEventListeners = function () {
531
500
  var outerActionEvents = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.props.outerActionEvents;
532
-
533
501
  if (outerActionEvents) {
534
502
  outerActionEvents.forEach(function (event) {
535
503
  return document.removeEventListener(event, _this._onEvent);
536
504
  });
537
505
  }
538
506
  };
539
-
540
507
  return _this;
541
508
  }
542
-
543
509
  _createClass(BodyDomNode, [{
544
510
  key: "componentDidMount",
545
511
  value: function componentDidMount() {
@@ -554,7 +520,6 @@ var BodyDomNode = /*#__PURE__*/function (_React$Component) {
554
520
  value: function componentDidUpdate(prevProps) {
555
521
  if (prevProps.outerActionEvents !== this.props.outerActionEvents || prevProps.onOuterAction !== this.props.onOuterAction) {
556
522
  this._removeDocumentEventListeners(prevProps.outerActionEvents);
557
-
558
523
  this._addDocumentEventListeners();
559
524
  }
560
525
  }
@@ -563,7 +528,6 @@ var BodyDomNode = /*#__PURE__*/function (_React$Component) {
563
528
  value: function componentWillUnmount() {
564
529
  if (this.state.node) {
565
530
  this.props.containerElement.removeChild(this.state.node);
566
-
567
531
  this._removeDocumentEventListeners();
568
532
  }
569
533
  }
@@ -573,7 +537,6 @@ var BodyDomNode = /*#__PURE__*/function (_React$Component) {
573
537
  return this.props.children(this.state.node);
574
538
  }
575
539
  }]);
576
-
577
540
  return BodyDomNode;
578
541
  }(React.Component);
579
542
  BodyDomNode.defaultProps = {
@@ -582,27 +545,21 @@ BodyDomNode.defaultProps = {
582
545
 
583
546
  var StatelessPopover = /*#__PURE__*/function (_React$Component) {
584
547
  _inherits(StatelessPopover, _React$Component);
585
-
586
548
  function StatelessPopover() {
587
549
  var _this;
588
-
589
550
  _classCallCheck(this, StatelessPopover);
590
-
591
551
  _this = _possibleConstructorReturn(this, _getPrototypeOf(StatelessPopover).apply(this, arguments));
592
-
593
552
  _this.getContainer = function () {
594
553
  return _this.props.getContainerElement && _this.props.getContainerElement() || document.body;
595
554
  };
596
-
597
555
  return _this;
598
556
  }
599
-
600
557
  _createClass(StatelessPopover, [{
601
558
  key: "renderPortalContent",
602
559
  value: function renderPortalContent(_ref) {
603
560
  var props = _ref.props,
604
- container = _ref.container,
605
- positioningTarget = _ref.positioningTarget;
561
+ container = _ref.container,
562
+ positioningTarget = _ref.positioningTarget;
606
563
  var popoverContent = React.createElement(PopoverContainer, {
607
564
  key: "popover-portal",
608
565
  getPopoverPosition: this.props.getPopoverPosition,
@@ -614,22 +571,18 @@ var StatelessPopover = /*#__PURE__*/function (_React$Component) {
614
571
  zIndex: props.zIndex,
615
572
  trackScroll: props.trackScroll
616
573
  }, props.body);
617
-
618
574
  if (!props.inline) {
619
575
  return ReactDOM.createPortal(popoverContent, container);
620
576
  }
621
-
622
577
  return popoverContent;
623
578
  }
624
579
  }, {
625
580
  key: "renderPortal",
626
581
  value: function renderPortal(positioningTarget) {
627
582
  var _this2 = this;
628
-
629
583
  if (!this.props.isOpen) {
630
584
  return null;
631
585
  }
632
-
633
586
  return this.props.inline ? this.renderPortalContent({
634
587
  props: this.props,
635
588
  positioningTarget: positioningTarget
@@ -650,48 +603,38 @@ var StatelessPopover = /*#__PURE__*/function (_React$Component) {
650
603
  key: "render",
651
604
  value: function render() {
652
605
  var _this3 = this;
653
-
654
606
  return React.createElement(PositioningTarget, null, function (positioningTarget) {
655
607
  return positioningTarget ? React.createElement(React.Fragment, null, _this3.props.children, _this3.renderPortal(positioningTarget)) : null;
656
608
  });
657
609
  }
658
610
  }]);
659
-
660
611
  return StatelessPopover;
661
612
  }(React.Component);
662
613
 
663
614
  var Popover = /*#__PURE__*/function (_React$Component) {
664
615
  _inherits(Popover, _React$Component);
665
-
666
616
  function Popover() {
667
617
  var _this;
668
-
669
618
  _classCallCheck(this, Popover);
670
-
671
619
  _this = _possibleConstructorReturn(this, _getPrototypeOf(Popover).apply(this, arguments));
672
620
  _this.state = {
673
621
  isOpen: false
674
622
  };
675
-
676
623
  _this.setOpened = function (isOpen) {
677
624
  _this.setState({
678
625
  isOpen: isOpen
679
626
  });
680
627
  };
681
-
682
628
  _this.onOuterAction = function (event) {
683
629
  if (_this.props.closeOnOuterAction) {
684
630
  _this.setOpened(false);
685
631
  }
686
-
687
632
  if (_this.props.onOuterAction) {
688
633
  _this.props.onOuterAction(event);
689
634
  }
690
635
  };
691
-
692
636
  return _this;
693
637
  }
694
-
695
638
  _createClass(Popover, [{
696
639
  key: "render",
697
640
  value: function render() {
@@ -706,7 +649,6 @@ var Popover = /*#__PURE__*/function (_React$Component) {
706
649
  }), children);
707
650
  }
708
651
  }]);
709
-
710
652
  return Popover;
711
653
  }(React.Component);
712
654
  Popover.Body = PopoverBody;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@targetprocess/popover",
3
- "version": "12.7.4",
3
+ "version": "12.19.0",
4
4
  "description": "",
5
5
  "main": "dist/popover.js",
6
6
  "module": "dist/popover.es.js",
@@ -21,5 +21,5 @@
21
21
  "publishConfig": {
22
22
  "access": "public"
23
23
  },
24
- "gitHead": "5b5fe47a0487c63dd7cafca4f7735106b09e8926"
24
+ "gitHead": "398770e98f6d4ef649bdc3d30af043ada615e6f0"
25
25
  }