@mw-kit/mw-ui 1.7.75 → 1.7.76

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.
@@ -1,5 +1,5 @@
1
1
  import 'semantic-ui-css/semantic.min.css';
2
- import React__default, { useState, useEffect, useImperativeHandle, createElement, useCallback } from 'react';
2
+ import React__default, { useState, useEffect, useCallback, useImperativeHandle, createElement } from 'react';
3
3
  import styled, { css, keyframes, createGlobalStyle, ThemeProvider as ThemeProvider$1 } from 'styled-components';
4
4
  import { Icon as Icon$1, Popup } from 'semantic-ui-react';
5
5
  export * from 'semantic-ui-react';
@@ -640,7 +640,8 @@ var Container = styled.div(_templateObject17 || (_templateObject17 = _taggedTemp
640
640
  });
641
641
 
642
642
  var AbsoluteContainer = React__default.forwardRef(function (props, fowardedRef) {
643
- var open = props.open;
643
+ var open = props.open,
644
+ boundRef = props.boundRef;
644
645
  var center = props.center || {
645
646
  x: 50,
646
647
  y: 75
@@ -651,15 +652,28 @@ var AbsoluteContainer = React__default.forwardRef(function (props, fowardedRef)
651
652
  ref = _useState[0],
652
653
  setRef = _useState[1];
653
654
 
654
- var getPosition = function getPosition() {
655
+ var getPosition = useCallback(function () {
655
656
  if (!ref) return null;
656
- var width = window.innerWidth;
657
- var height = window.innerHeight;
658
-
659
- var _ref$getBoundingClien = ref.getBoundingClientRect(),
660
- top = _ref$getBoundingClien.top,
661
- left = _ref$getBoundingClien.left;
662
657
 
658
+ var _ref = boundRef ? {
659
+ offsetTop: boundRef.offsetTop,
660
+ offsetLeft: boundRef.offsetLeft,
661
+ width: boundRef.offsetWidth,
662
+ height: boundRef.offsetHeight
663
+ } : {
664
+ offsetTop: 0,
665
+ offsetLeft: 0,
666
+ width: window.innerWidth,
667
+ height: window.innerHeight
668
+ },
669
+ width = _ref.width,
670
+ height = _ref.height,
671
+ offsetTop = _ref.offsetTop,
672
+ offsetLeft = _ref.offsetLeft;
673
+
674
+ var rect = ref.getBoundingClientRect();
675
+ var top = rect.top - offsetTop;
676
+ var left = rect.left - offsetLeft;
663
677
  var x = left * 100 / width;
664
678
  var y = top * 100 / height;
665
679
 
@@ -677,7 +691,7 @@ var AbsoluteContainer = React__default.forwardRef(function (props, fowardedRef)
677
691
 
678
692
  return _newPosition;
679
693
  }
680
- };
694
+ }, [ref, boundRef]);
681
695
 
682
696
  var _useState2 = useState(props.position || getPosition),
683
697
  position = _useState2[0],
@@ -689,7 +703,7 @@ var AbsoluteContainer = React__default.forwardRef(function (props, fowardedRef)
689
703
  useEffect(function () {
690
704
  if (props.position) return;
691
705
  setPosition(getPosition);
692
- }, [ref]);
706
+ }, [getPosition]);
693
707
  var htmlProps = filterObject(props, ['center', 'position', 'children', 'content']);
694
708
  var cssKeys = {
695
709
  width: 'width',