@mw-kit/mw-ui 1.7.75 → 1.7.77

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,32 @@ 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 () {
656
+ if (props.position) return props.position;
655
657
  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
658
 
659
+ var _ref = boundRef ? function () {
660
+ var rect = boundRef.getBoundingClientRect();
661
+ return {
662
+ offsetTop: rect.top,
663
+ offsetLeft: rect.left,
664
+ width: boundRef.offsetWidth,
665
+ height: boundRef.offsetHeight
666
+ };
667
+ }() : {
668
+ offsetTop: 0,
669
+ offsetLeft: 0,
670
+ width: window.innerWidth,
671
+ height: window.innerHeight
672
+ },
673
+ width = _ref.width,
674
+ height = _ref.height,
675
+ offsetTop = _ref.offsetTop,
676
+ offsetLeft = _ref.offsetLeft;
677
+
678
+ var rect = ref.getBoundingClientRect();
679
+ var top = rect.top - offsetTop;
680
+ var left = rect.left - offsetLeft;
663
681
  var x = left * 100 / width;
664
682
  var y = top * 100 / height;
665
683
 
@@ -677,9 +695,9 @@ var AbsoluteContainer = React__default.forwardRef(function (props, fowardedRef)
677
695
 
678
696
  return _newPosition;
679
697
  }
680
- };
698
+ }, [ref, boundRef, props.position]);
681
699
 
682
- var _useState2 = useState(props.position || getPosition),
700
+ var _useState2 = useState(getPosition),
683
701
  position = _useState2[0],
684
702
  setPosition = _useState2[1];
685
703
 
@@ -687,9 +705,8 @@ var AbsoluteContainer = React__default.forwardRef(function (props, fowardedRef)
687
705
  return ref;
688
706
  });
689
707
  useEffect(function () {
690
- if (props.position) return;
691
708
  setPosition(getPosition);
692
- }, [ref]);
709
+ }, [getPosition]);
693
710
  var htmlProps = filterObject(props, ['center', 'position', 'children', 'content']);
694
711
  var cssKeys = {
695
712
  width: 'width',