@lanaco/lnc-react-ui 3.0.2 → 3.0.4
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.
- package/README.md +1 -1
- package/lib/index.esm.js +185 -126
- package/lib/index.js +185 -126
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Lanaco ReactJS UI components library
|
|
2
2
|
|
|
3
|
-
[Deployment](https://lanaco.github.io/lnc-react-ui/?path=/docs/intro--
|
|
3
|
+
[Deployment](https://lanaco.github.io/lnc-react-ui/?path=/docs/intro--page)
|
|
4
4
|
|
|
5
5
|
This library includes basic and advanced UI components used with ReactJS frontend framework
|
|
6
6
|
|
package/lib/index.esm.js
CHANGED
|
@@ -64651,9 +64651,9 @@ var AnimatePresence = function (_a) {
|
|
|
64651
64651
|
: childrenToRender.map(function (child) { return cloneElement(child); })));
|
|
64652
64652
|
};
|
|
64653
64653
|
|
|
64654
|
-
var _excluded$N = ["anchorElement", "borderRadius", "vertical", "horizontal", "offset", "zIndex", "popoverContainer", "closeOnClickOutside", "onOpen", "onClose", "className", "style", "children"];
|
|
64654
|
+
var _excluded$N = ["anchorElement", "borderRadius", "vertical", "horizontal", "offset", "zIndex", "popoverContainer", "portalTarget", "closeOnClickOutside", "closeOnScroll", "onOpen", "onClose", "className", "style", "children"];
|
|
64655
64655
|
var _templateObject$L;
|
|
64656
|
-
var StyledPopover = newStyled(motion.div)(_templateObject$L || (_templateObject$L = _taggedTemplateLiteral(["\n box-sizing: border-box;\n font-family: ", ";\n display: ", ";\n opacity: 0;\n opacity: ", ";\n animation: fadeIn 0.4s;\n\n position: absolute;\n
|
|
64656
|
+
var StyledPopover = newStyled(motion.div)(_templateObject$L || (_templateObject$L = _taggedTemplateLiteral(["\n color: black;\n box-sizing: border-box;\n font-family: ", ";\n display: ", ";\n opacity: 0;\n opacity: ", ";\n animation: fadeIn 0.4s;\n\n position: absolute;\n max-height: ", ";\n max-width: ", ";\n ", "\n ", "\n ", "\n ", "\n\n overflow: auto;\n box-shadow: ", ";\n border-radius: ", ";\n border-top: 1px solid rgba(0, 0, 0, 0.04);\n box-sizing: border-box;\n padding: 12px;\n background-color: ", ";\n\n z-index: ", ";\n\n @keyframes fadeIn {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n }\n\n @-moz-keyframes fadeIn {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n }\n\n @-webkit-keyframes fadeIn {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n }\n\n @-o-keyframes fadeIn {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n }\n\n @-ms-keyframes fadeIn {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n }\n"])), function (props) {
|
|
64657
64657
|
var _props$theme, _props$theme$typograp;
|
|
64658
64658
|
return (_props$theme = props.theme) === null || _props$theme === void 0 ? void 0 : (_props$theme$typograp = _props$theme.typography) === null || _props$theme$typograp === void 0 ? void 0 : _props$theme$typograp.fontFamily;
|
|
64659
64659
|
}, function (props) {
|
|
@@ -64661,26 +64661,21 @@ var StyledPopover = newStyled(motion.div)(_templateObject$L || (_templateObject$
|
|
|
64661
64661
|
}, function (props) {
|
|
64662
64662
|
return props.show ? "1" : "0";
|
|
64663
64663
|
}, function (props) {
|
|
64664
|
-
|
|
64665
|
-
return props.position ? "".concat(((_props$position = props.position) === null || _props$position === void 0 ? void 0 : _props$position.top) + ((_props$position2 = props.position) === null || _props$position2 === void 0 ? void 0 : _props$position2.height)) : "0";
|
|
64664
|
+
return props.position.maxHeight + "px";
|
|
64666
64665
|
}, function (props) {
|
|
64667
|
-
return props.position
|
|
64666
|
+
return props.position.maxWidth + "px";
|
|
64668
64667
|
}, function (props) {
|
|
64669
|
-
|
|
64670
|
-
return (_props$position3 = props.position) === null || _props$position3 === void 0 ? void 0 : _props$position3.horizontalPosition;
|
|
64668
|
+
return props.position.top !== null && "top: ".concat(props.position.top, "px;");
|
|
64671
64669
|
}, function (props) {
|
|
64672
|
-
|
|
64673
|
-
return (_props$position4 = props.position) === null || _props$position4 === void 0 ? void 0 : _props$position4.verticalPosition;
|
|
64670
|
+
return props.position.bottom !== null && "bottom: ".concat(props.position.bottom, "px;");
|
|
64674
64671
|
}, function (props) {
|
|
64675
|
-
return
|
|
64672
|
+
return props.position.left !== null && "left: ".concat(props.position.left, "px;");
|
|
64676
64673
|
}, function (props) {
|
|
64677
|
-
return
|
|
64674
|
+
return props.position.right !== null && "right: ".concat(props.position.right, "px;");
|
|
64678
64675
|
}, function (props) {
|
|
64679
|
-
|
|
64680
|
-
return (_props$position5 = props.position) !== null && _props$position5 !== void 0 && _props$position5.maxWidth ? props.position.maxWidth != "100vw" ? props.position.maxWidth + "px" : "100vw" : "100vw";
|
|
64676
|
+
return getComponentPropValue(props.theme, "Popover", props.color, "enabled", "boxShadow");
|
|
64681
64677
|
}, function (props) {
|
|
64682
|
-
|
|
64683
|
-
return (_props$position6 = props.position) !== null && _props$position6 !== void 0 && _props$position6.maxHeight ? props.position.maxHeight != "100vh" ? props.position.maxHeight + "px" : "100vh" : "100vh";
|
|
64678
|
+
return getBorderRadiusValueWithUnits(props.theme, props.borderRadius);
|
|
64684
64679
|
}, function (props) {
|
|
64685
64680
|
return getColorRgbaValue(props.theme, "Popover", "default", "enabled", "bg");
|
|
64686
64681
|
}, function (props) {
|
|
@@ -64692,25 +64687,38 @@ var Popover$1 = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
64692
64687
|
vertical = props.vertical,
|
|
64693
64688
|
horizontal = props.horizontal,
|
|
64694
64689
|
offset = props.offset,
|
|
64695
|
-
zIndex = props.zIndex
|
|
64696
|
-
|
|
64690
|
+
zIndex = props.zIndex;
|
|
64691
|
+
props.popoverContainer;
|
|
64692
|
+
var portalTarget = props.portalTarget,
|
|
64697
64693
|
closeOnClickOutside = props.closeOnClickOutside,
|
|
64694
|
+
closeOnScroll = props.closeOnScroll,
|
|
64698
64695
|
onOpen = props.onOpen,
|
|
64699
64696
|
onClose = props.onClose,
|
|
64700
64697
|
className = props.className,
|
|
64701
64698
|
style = props.style,
|
|
64702
64699
|
children = props.children,
|
|
64703
64700
|
rest = _objectWithoutProperties$b(props, _excluded$N);
|
|
64701
|
+
var _useState = useState(document.body),
|
|
64702
|
+
_useState2 = _slicedToArray$2(_useState, 2),
|
|
64703
|
+
portal = _useState2[0],
|
|
64704
|
+
setPortal = _useState2[1];
|
|
64704
64705
|
var theme = useTheme$1();
|
|
64705
64706
|
var popoverRef = useRef(ref);
|
|
64706
|
-
var
|
|
64707
|
-
_useState2 = _slicedToArray$2(_useState, 2),
|
|
64708
|
-
show = _useState2[0],
|
|
64709
|
-
setShow = _useState2[1];
|
|
64710
|
-
var _useState3 = useState(),
|
|
64707
|
+
var _useState3 = useState(false),
|
|
64711
64708
|
_useState4 = _slicedToArray$2(_useState3, 2),
|
|
64712
|
-
|
|
64713
|
-
|
|
64709
|
+
show = _useState4[0],
|
|
64710
|
+
setShow = _useState4[1];
|
|
64711
|
+
var _useState5 = useState({
|
|
64712
|
+
top: null,
|
|
64713
|
+
bottom: null,
|
|
64714
|
+
left: null,
|
|
64715
|
+
right: null,
|
|
64716
|
+
maxHeight: null,
|
|
64717
|
+
width: null
|
|
64718
|
+
}),
|
|
64719
|
+
_useState6 = _slicedToArray$2(_useState5, 2),
|
|
64720
|
+
popoverPosition = _useState6[0],
|
|
64721
|
+
setPopoverPosition = _useState6[1];
|
|
64714
64722
|
|
|
64715
64723
|
//Expose functions through ref
|
|
64716
64724
|
useImperativeHandle(ref, function () {
|
|
@@ -64735,115 +64743,145 @@ var Popover$1 = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
64735
64743
|
onClose(event);
|
|
64736
64744
|
};
|
|
64737
64745
|
useEffect(function () {
|
|
64738
|
-
if (anchorElement && show
|
|
64739
|
-
|
|
64740
|
-
|
|
64741
|
-
|
|
64742
|
-
|
|
64743
|
-
|
|
64744
|
-
|
|
64745
|
-
var findPopoverPosition = function findPopoverPosition(anchorElPosition, anchorViewPortPosition) {
|
|
64746
|
-
var _document$body = document.body;
|
|
64747
|
-
_document$body.clientHeight;
|
|
64748
|
-
var windowWidth = _document$body.clientWidth;
|
|
64749
|
-
var _window = window,
|
|
64750
|
-
windowInnerHeight = _window.innerHeight,
|
|
64751
|
-
windowInnerWidth = _window.innerWidth;
|
|
64752
|
-
var popoverMeasures = getElementPosition(popoverRef.current);
|
|
64753
|
-
if (popoverMeasures && anchorElPosition) {
|
|
64754
|
-
var _ref = horizontal ? findHorizontalPosition(horizontal, anchorElPosition, popoverMeasures, anchorViewPortPosition, windowInnerWidth) : {
|
|
64755
|
-
horizontalPosition: "",
|
|
64756
|
-
maxWidth: "100vw"
|
|
64757
|
-
},
|
|
64758
|
-
horizontalPosition = _ref.horizontalPosition,
|
|
64759
|
-
maxWidth = _ref.maxWidth;
|
|
64760
|
-
var _ref2 = vertical ? findVerticalPosition(vertical, anchorElPosition, popoverMeasures, anchorViewPortPosition, windowInnerHeight) : {
|
|
64761
|
-
verticalPosition: "",
|
|
64762
|
-
maxHeight: "100vh"
|
|
64763
|
-
},
|
|
64764
|
-
verticalPosition = _ref2.verticalPosition,
|
|
64765
|
-
maxHeight = _ref2.maxHeight;
|
|
64766
|
-
if (!horizontal) {
|
|
64767
|
-
maxWidth = "100vw";
|
|
64768
|
-
//horizontal
|
|
64769
|
-
if (popoverMeasures.width / 2 <= anchorElPosition.left + anchorElPosition.width / 2 && popoverMeasures.width / 2 <= windowWidth - anchorElPosition.right + anchorElPosition.width / 2) {
|
|
64770
|
-
horizontalPosition = "left: ".concat(anchorElPosition.left + anchorElPosition.width / 2 - popoverMeasures.width / 2, "px");
|
|
64771
|
-
} else if (popoverMeasures.width / 2 > anchorElPosition.left + anchorElPosition.width / 2) {
|
|
64772
|
-
horizontalPosition = "left: 0";
|
|
64746
|
+
if (anchorElement && show === true) {
|
|
64747
|
+
if (portalTarget) {
|
|
64748
|
+
setPortal(portalTarget !== null && portalTarget !== void 0 && portalTarget.current ? portalTarget.current : portalTarget);
|
|
64749
|
+
} else {
|
|
64750
|
+
//todo set relative implicitly to anchor
|
|
64751
|
+
if (anchorElement !== null && anchorElement !== void 0 && anchorElement.current) {
|
|
64752
|
+
anchorElement.current.style.position = "relative";
|
|
64773
64753
|
} else {
|
|
64774
|
-
|
|
64754
|
+
anchorElement.style.position = "relative";
|
|
64775
64755
|
}
|
|
64756
|
+
setPortal(anchorElement !== null && anchorElement !== void 0 && anchorElement.current ? anchorElement.current : anchorElement);
|
|
64757
|
+
}
|
|
64758
|
+
}
|
|
64759
|
+
}, [anchorElement, show]);
|
|
64760
|
+
useEffect(function () {
|
|
64761
|
+
if (anchorElement && show == true) {
|
|
64762
|
+
var anchorElPosition = getElementPositionInContainer(anchorElement !== null && anchorElement !== void 0 && anchorElement.current ? anchorElement.current : anchorElement, portalTarget);
|
|
64763
|
+
var popoverMeasures = getElementMeasures(popoverRef.current);
|
|
64764
|
+
var container = portalTarget ? portalTarget.current ? portalTarget.current : portalTarget : document.body;
|
|
64765
|
+
var containerMeasures = getElementMeasures(container);
|
|
64766
|
+
var resultPosition = getPopoverPosition(anchorElPosition, popoverMeasures, containerMeasures, offset, portalTarget);
|
|
64767
|
+
setPopoverPosition(resultPosition);
|
|
64768
|
+
}
|
|
64769
|
+
}, [anchorElement, vertical, horizontal, show, portal]);
|
|
64770
|
+
var getPopoverPosition = function getPopoverPosition(anchorPosition, popoverMeasures, containerMeasures, offset, portalTarget) {
|
|
64771
|
+
var freeSpaceTop = getFreeSpaceFromTheTop(anchorPosition, offset);
|
|
64772
|
+
var freeSpaceBottom = getFreeSpaceFromTheBottom(anchorPosition, offset, containerMeasures);
|
|
64773
|
+
var freeSpaceLeft = getFreeSpaceToTheLeft(anchorPosition);
|
|
64774
|
+
var position = {
|
|
64775
|
+
top: null,
|
|
64776
|
+
bottom: null,
|
|
64777
|
+
left: null,
|
|
64778
|
+
right: null,
|
|
64779
|
+
maxHeight: null,
|
|
64780
|
+
maxWidth: null
|
|
64781
|
+
};
|
|
64782
|
+
var anchMeas = getElementMeasures(portal);
|
|
64783
|
+
|
|
64784
|
+
// getting vertical position and max height boundaries
|
|
64785
|
+
if (freeSpaceTop > freeSpaceBottom) {
|
|
64786
|
+
if (portalTarget) {
|
|
64787
|
+
position.top = anchorPosition.top - offset - popoverMeasures.height > 0 ? anchorPosition.top - offset - popoverMeasures.height : 0;
|
|
64788
|
+
} else {
|
|
64789
|
+
position.top = anchorPosition.top - offset - popoverMeasures.height > 0 ? 0 - popoverMeasures.height : 0 - freeSpaceTop - offset;
|
|
64790
|
+
}
|
|
64791
|
+
position.maxHeight = freeSpaceTop;
|
|
64792
|
+
} else {
|
|
64793
|
+
if (portalTarget) {
|
|
64794
|
+
position.top = anchorPosition.bottom + offset;
|
|
64795
|
+
} else {
|
|
64796
|
+
position.top = anchMeas.height + offset;
|
|
64797
|
+
}
|
|
64798
|
+
position.maxHeight = freeSpaceBottom;
|
|
64799
|
+
}
|
|
64800
|
+
|
|
64801
|
+
// getting horizontal positio and max width boundaries
|
|
64802
|
+
if (horizontal === "left") {
|
|
64803
|
+
position.maxWidth = containerMeasures.width - anchorPosition.left;
|
|
64804
|
+
if (portalTarget) {
|
|
64805
|
+
position.left = anchorPosition.left;
|
|
64806
|
+
} else {
|
|
64807
|
+
position.left = 0;
|
|
64808
|
+
}
|
|
64809
|
+
} else if (horizontal === "right") {
|
|
64810
|
+
position.maxWidth = anchorPosition.right;
|
|
64811
|
+
if (portalTarget) {
|
|
64812
|
+
position.left = anchorPosition.right - popoverMeasures.width > 0 ? anchorPosition.right - popoverMeasures.width : 0;
|
|
64813
|
+
} else {
|
|
64814
|
+
position.right = 0;
|
|
64776
64815
|
}
|
|
64777
|
-
|
|
64778
|
-
|
|
64779
|
-
|
|
64780
|
-
|
|
64781
|
-
|
|
64782
|
-
|
|
64816
|
+
} else {
|
|
64817
|
+
position.maxWidth = containerMeasures.width;
|
|
64818
|
+
if (anchorPosition.horizontalCenter >= popoverMeasures.width / 2) {
|
|
64819
|
+
if (portalTarget) {
|
|
64820
|
+
position.left = anchorPosition.horizontalCenter - popoverMeasures.width / 2;
|
|
64821
|
+
} else {
|
|
64822
|
+
position.left = anchMeas.width / 2 - popoverMeasures.width / 2;
|
|
64823
|
+
}
|
|
64824
|
+
} else {
|
|
64825
|
+
if (portalTarget) {
|
|
64826
|
+
position.left = 0;
|
|
64783
64827
|
} else {
|
|
64784
|
-
|
|
64785
|
-
maxHeight = "".concat(windowInnerHeight - anchorViewPortPosition.bottom - offset);
|
|
64786
|
-
verticalPosition = "top: ".concat(anchorElPosition.bottom + offset, "px");
|
|
64828
|
+
position.left = 0 - freeSpaceLeft;
|
|
64787
64829
|
}
|
|
64788
64830
|
}
|
|
64789
|
-
return {
|
|
64790
|
-
horizontalPosition: horizontalPosition,
|
|
64791
|
-
verticalPosition: verticalPosition,
|
|
64792
|
-
maxHeight: maxHeight,
|
|
64793
|
-
maxWidth: maxWidth
|
|
64794
|
-
};
|
|
64795
64831
|
}
|
|
64796
|
-
return
|
|
64832
|
+
return position;
|
|
64797
64833
|
};
|
|
64798
|
-
var
|
|
64799
|
-
|
|
64800
|
-
|
|
64801
|
-
|
|
64802
|
-
|
|
64803
|
-
|
|
64804
|
-
|
|
64805
|
-
|
|
64806
|
-
horizontalResult = "left: ".concat(anchorElPosition.left, "px");
|
|
64807
|
-
} else if (horizontalPosition == "center") {
|
|
64808
|
-
maxWidth = "100vw";
|
|
64809
|
-
horizontalResult = "left: ".concat(anchorElPosition.left + anchorElPosition.width / 2 - popoverMeasures.width / 2, "px");
|
|
64810
|
-
}
|
|
64811
|
-
return {
|
|
64812
|
-
horizontalPosition: horizontalResult,
|
|
64813
|
-
maxWidth: maxWidth
|
|
64814
|
-
};
|
|
64834
|
+
var getFreeSpaceToTheLeft = function getFreeSpaceToTheLeft(anchorPosition) {
|
|
64835
|
+
return anchorPosition.left;
|
|
64836
|
+
};
|
|
64837
|
+
|
|
64838
|
+
// Vertical offset can exist
|
|
64839
|
+
var getFreeSpaceFromTheTop = function getFreeSpaceFromTheTop(anchorPosition, offset) {
|
|
64840
|
+
if (vertical === "bottom") return 0;
|
|
64841
|
+
return anchorPosition.top - offset;
|
|
64815
64842
|
};
|
|
64816
|
-
|
|
64817
|
-
|
|
64818
|
-
|
|
64819
|
-
if (
|
|
64820
|
-
|
|
64821
|
-
|
|
64822
|
-
|
|
64823
|
-
|
|
64824
|
-
|
|
64843
|
+
|
|
64844
|
+
// Vertical offset can exist
|
|
64845
|
+
var getFreeSpaceFromTheBottom = function getFreeSpaceFromTheBottom(anchorPosition, offset, containerMeasures) {
|
|
64846
|
+
if (vertical === "top") return 0;
|
|
64847
|
+
return containerMeasures.height - anchorPosition.bottom - offset;
|
|
64848
|
+
};
|
|
64849
|
+
var getElementPositionInContainer = function getElementPositionInContainer(element, portalTarget) {
|
|
64850
|
+
//if there is no portal target get position relative to document.body
|
|
64851
|
+
if (!portalTarget || portalTarget == document.body) {
|
|
64852
|
+
var clientRect = element.getBoundingClientRect();
|
|
64853
|
+
var scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
|
|
64854
|
+
var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
|
|
64855
|
+
return {
|
|
64856
|
+
left: clientRect.left + scrollLeft,
|
|
64857
|
+
top: clientRect.top + scrollTop,
|
|
64858
|
+
right: clientRect.right + scrollLeft,
|
|
64859
|
+
bottom: clientRect.bottom + scrollTop,
|
|
64860
|
+
height: clientRect.height,
|
|
64861
|
+
width: clientRect.width,
|
|
64862
|
+
horizontalCenter: clientRect.left + scrollLeft + clientRect.width / 2
|
|
64863
|
+
};
|
|
64825
64864
|
}
|
|
64865
|
+
|
|
64866
|
+
//else find relative to portal target
|
|
64867
|
+
scrollLeft = portalTarget.offsetLeft;
|
|
64868
|
+
scrollTop = portalTarget.offsetTop;
|
|
64826
64869
|
return {
|
|
64827
|
-
|
|
64828
|
-
|
|
64870
|
+
left: element.offsetLeft,
|
|
64871
|
+
top: element.offsetTop,
|
|
64872
|
+
right: element.offsetLeft + element.offsetWidth,
|
|
64873
|
+
bottom: element.offsetTop + element.offsetHeight,
|
|
64874
|
+
height: element.offsetHeight,
|
|
64875
|
+
width: element.offsetWidth,
|
|
64876
|
+
horizontalCenter: element.offsetLeft + element.offsetWidth / 2
|
|
64829
64877
|
};
|
|
64830
64878
|
};
|
|
64831
|
-
var
|
|
64832
|
-
var clientRect = element.getBoundingClientRect();
|
|
64833
|
-
var scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
|
|
64834
|
-
var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
|
|
64879
|
+
var getElementMeasures = function getElementMeasures(element) {
|
|
64835
64880
|
return {
|
|
64836
|
-
|
|
64837
|
-
|
|
64838
|
-
right: clientRect.right + scrollLeft,
|
|
64839
|
-
bottom: clientRect.bottom + scrollTop,
|
|
64840
|
-
height: clientRect.height,
|
|
64841
|
-
width: clientRect.width
|
|
64881
|
+
height: element.offsetHeight,
|
|
64882
|
+
width: element.offsetWidth
|
|
64842
64883
|
};
|
|
64843
64884
|
};
|
|
64844
|
-
var getElementViewPortPosition = function getElementViewPortPosition(element) {
|
|
64845
|
-
return element.getBoundingClientRect();
|
|
64846
|
-
};
|
|
64847
64885
|
|
|
64848
64886
|
//Outside click handling
|
|
64849
64887
|
useEffect(function () {
|
|
@@ -64852,11 +64890,18 @@ var Popover$1 = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
64852
64890
|
if (closeOnClickOutside == true) _close();
|
|
64853
64891
|
}
|
|
64854
64892
|
};
|
|
64893
|
+
var handleScroll = function handleScroll(event) {
|
|
64894
|
+
if (popoverRef !== null && popoverRef !== void 0 && popoverRef.current && !(popoverRef !== null && popoverRef !== void 0 && popoverRef.current.contains(event.target))) {
|
|
64895
|
+
if (closeOnScroll == true) _close();
|
|
64896
|
+
}
|
|
64897
|
+
};
|
|
64855
64898
|
//Fired on component mount
|
|
64856
|
-
document.addEventListener(
|
|
64899
|
+
document.addEventListener("click", handleClickOutside, true);
|
|
64900
|
+
document.addEventListener("scroll", handleScroll, true);
|
|
64857
64901
|
return function () {
|
|
64858
64902
|
//Fired on component unmount
|
|
64859
|
-
document.removeEventListener(
|
|
64903
|
+
document.removeEventListener("click", handleClickOutside, true);
|
|
64904
|
+
document.removeEventListener("scroll", handleScroll, true);
|
|
64860
64905
|
};
|
|
64861
64906
|
}, []);
|
|
64862
64907
|
return /*#__PURE__*/createPortal( /*#__PURE__*/React__default.createElement(StyledPopover, _extends$g({
|
|
@@ -64867,8 +64912,11 @@ var Popover$1 = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
64867
64912
|
show: show,
|
|
64868
64913
|
borderRadius: borderRadius,
|
|
64869
64914
|
className: className,
|
|
64870
|
-
style: style
|
|
64871
|
-
|
|
64915
|
+
style: style,
|
|
64916
|
+
onBlur: _close
|
|
64917
|
+
}, rest), children),
|
|
64918
|
+
// parentContainer
|
|
64919
|
+
portal);
|
|
64872
64920
|
});
|
|
64873
64921
|
Popover$1.defaultProps = {
|
|
64874
64922
|
className: "",
|
|
@@ -64876,8 +64924,8 @@ Popover$1.defaultProps = {
|
|
|
64876
64924
|
borderRadius: "regular",
|
|
64877
64925
|
horizontal: null,
|
|
64878
64926
|
offset: 0,
|
|
64879
|
-
|
|
64880
|
-
|
|
64927
|
+
closeOnClickOutside: false,
|
|
64928
|
+
closeOnScroll: false,
|
|
64881
64929
|
onOpen: function onOpen() {},
|
|
64882
64930
|
onClose: function onClose() {}
|
|
64883
64931
|
};
|
|
@@ -64888,18 +64936,23 @@ Popover$1.propTypes = {
|
|
|
64888
64936
|
*/
|
|
64889
64937
|
anchorElement: PropTypes.object,
|
|
64890
64938
|
borderRadius: PropTypes.oneOf(["regular", "curved"]),
|
|
64891
|
-
horizontal: PropTypes.oneOf(["left", "right", "center"]),
|
|
64939
|
+
horizontal: PropTypes.oneOf(["left", "right", "center", null]),
|
|
64892
64940
|
vertical: PropTypes.oneOf(["top", "bottom", null]),
|
|
64893
64941
|
/**
|
|
64894
64942
|
* popoverContainer is DOM element, popover won't be mounted into the DOM as a child of the nearest parent node, it will be inserted as a child of popoverContainer location in the DOM
|
|
64895
64943
|
*/
|
|
64896
64944
|
popoverContainer: PropTypes.any,
|
|
64945
|
+
/**
|
|
64946
|
+
* portalTarget can be DOM element or a ref to an element, possible value is `document.body`
|
|
64947
|
+
*/
|
|
64948
|
+
portalTarget: PropTypes.any,
|
|
64897
64949
|
/**
|
|
64898
64950
|
* Offset from anchor element in pixels
|
|
64899
64951
|
*/
|
|
64900
64952
|
offset: PropTypes.number,
|
|
64901
64953
|
zIndex: PropTypes.number,
|
|
64902
64954
|
closeOnClickOutside: PropTypes.bool,
|
|
64955
|
+
closeOnScroll: PropTypes.bool,
|
|
64903
64956
|
//--------------------------
|
|
64904
64957
|
onOpen: PropTypes.func,
|
|
64905
64958
|
onClose: PropTypes.func,
|
|
@@ -65907,7 +65960,7 @@ ThemeProvider.propTypes = {
|
|
|
65907
65960
|
theme: PropTypes.oneOfType([PropTypes.string, PropTypes.object])
|
|
65908
65961
|
};
|
|
65909
65962
|
|
|
65910
|
-
var _excluded$M = ["control", "openOnClick", "openOnHover", "offset", "verticalAlignment", "horizontalAlignment", "widthFitContent", "closeOnItemSelect", "onFocus", "onBlur", "onClick", "onKeyDown", "onMouseEnter", "onMouseLeave", "onItemSelected", "animation", "className", "style", "color", "size", "popoverProps", "children"];
|
|
65963
|
+
var _excluded$M = ["control", "openOnClick", "openOnHover", "offset", "verticalAlignment", "horizontalAlignment", "widthFitContent", "closeOnItemSelect", "portalTarget", "onFocus", "onBlur", "onClick", "onKeyDown", "onMouseEnter", "onMouseLeave", "onItemSelected", "animation", "className", "style", "color", "size", "popoverProps", "children"];
|
|
65911
65964
|
var _templateObject$J, _templateObject2$f;
|
|
65912
65965
|
var StyledDropDown = newStyled.div(_templateObject$J || (_templateObject$J = _taggedTemplateLiteral([""])));
|
|
65913
65966
|
var PopoverContent = newStyled(motion.div)(_templateObject2$f || (_templateObject2$f = _taggedTemplateLiteral(["\n padding: 0.25rem;\n gap: 0.25rem;\n display: flex;\n flex-direction: column;\n ", ";\n background-color: ", ";\n"])), function (props) {
|
|
@@ -65924,6 +65977,7 @@ var DropdownMenu = /*#__PURE__*/React__default.forwardRef(function (props, ref)
|
|
|
65924
65977
|
horizontalAlignment = props.horizontalAlignment,
|
|
65925
65978
|
widthFitContent = props.widthFitContent,
|
|
65926
65979
|
closeOnItemSelect = props.closeOnItemSelect,
|
|
65980
|
+
portalTarget = props.portalTarget,
|
|
65927
65981
|
onFocus = props.onFocus,
|
|
65928
65982
|
onBlur = props.onBlur,
|
|
65929
65983
|
onClick = props.onClick,
|
|
@@ -66057,6 +66111,8 @@ var DropdownMenu = /*#__PURE__*/React__default.forwardRef(function (props, ref)
|
|
|
66057
66111
|
maxHeight: "unset"
|
|
66058
66112
|
},
|
|
66059
66113
|
closeOnClickOutside: false //dropdown has it's own outside click handler which includes control (element that opens dropdown)
|
|
66114
|
+
,
|
|
66115
|
+
portalTarget: portalTarget
|
|
66060
66116
|
}, popoverProps), /*#__PURE__*/React__default.createElement(PopoverContent, {
|
|
66061
66117
|
ref: menuContentRef,
|
|
66062
66118
|
widthFitContent: widthFitContent,
|
|
@@ -66132,6 +66188,10 @@ DropdownMenu.propTypes = {
|
|
|
66132
66188
|
* Close menu when item is selected
|
|
66133
66189
|
*/
|
|
66134
66190
|
closeOnItemSelect: PropTypes.bool,
|
|
66191
|
+
/**
|
|
66192
|
+
* portalTarget can be DOM element or a ref to an element, possible value is `document.body`
|
|
66193
|
+
*/
|
|
66194
|
+
portalTarget: PropTypes.any,
|
|
66135
66195
|
//---------------------------------------------------------------
|
|
66136
66196
|
onBlur: PropTypes.func,
|
|
66137
66197
|
onFocus: PropTypes.func,
|
|
@@ -72327,7 +72387,6 @@ DragAndDropFile.defaultProps = {
|
|
|
72327
72387
|
id: "",
|
|
72328
72388
|
disabled: false,
|
|
72329
72389
|
acceptDropzone: {},
|
|
72330
|
-
acceptInput: acceptInput,
|
|
72331
72390
|
multiple: false,
|
|
72332
72391
|
selectFileText: "Select file",
|
|
72333
72392
|
dndFileText: "Drag and drop file here or",
|
package/lib/index.js
CHANGED
|
@@ -64700,9 +64700,9 @@ var AnimatePresence = function (_a) {
|
|
|
64700
64700
|
: childrenToRender.map(function (child) { return React.cloneElement(child); })));
|
|
64701
64701
|
};
|
|
64702
64702
|
|
|
64703
|
-
var _excluded$N = ["anchorElement", "borderRadius", "vertical", "horizontal", "offset", "zIndex", "popoverContainer", "closeOnClickOutside", "onOpen", "onClose", "className", "style", "children"];
|
|
64703
|
+
var _excluded$N = ["anchorElement", "borderRadius", "vertical", "horizontal", "offset", "zIndex", "popoverContainer", "portalTarget", "closeOnClickOutside", "closeOnScroll", "onOpen", "onClose", "className", "style", "children"];
|
|
64704
64704
|
var _templateObject$L;
|
|
64705
|
-
var StyledPopover = newStyled(motion.div)(_templateObject$L || (_templateObject$L = _taggedTemplateLiteral__default["default"](["\n box-sizing: border-box;\n font-family: ", ";\n display: ", ";\n opacity: 0;\n opacity: ", ";\n animation: fadeIn 0.4s;\n\n position: absolute;\n
|
|
64705
|
+
var StyledPopover = newStyled(motion.div)(_templateObject$L || (_templateObject$L = _taggedTemplateLiteral__default["default"](["\n color: black;\n box-sizing: border-box;\n font-family: ", ";\n display: ", ";\n opacity: 0;\n opacity: ", ";\n animation: fadeIn 0.4s;\n\n position: absolute;\n max-height: ", ";\n max-width: ", ";\n ", "\n ", "\n ", "\n ", "\n\n overflow: auto;\n box-shadow: ", ";\n border-radius: ", ";\n border-top: 1px solid rgba(0, 0, 0, 0.04);\n box-sizing: border-box;\n padding: 12px;\n background-color: ", ";\n\n z-index: ", ";\n\n @keyframes fadeIn {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n }\n\n @-moz-keyframes fadeIn {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n }\n\n @-webkit-keyframes fadeIn {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n }\n\n @-o-keyframes fadeIn {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n }\n\n @-ms-keyframes fadeIn {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n }\n"])), function (props) {
|
|
64706
64706
|
var _props$theme, _props$theme$typograp;
|
|
64707
64707
|
return (_props$theme = props.theme) === null || _props$theme === void 0 ? void 0 : (_props$theme$typograp = _props$theme.typography) === null || _props$theme$typograp === void 0 ? void 0 : _props$theme$typograp.fontFamily;
|
|
64708
64708
|
}, function (props) {
|
|
@@ -64710,26 +64710,21 @@ var StyledPopover = newStyled(motion.div)(_templateObject$L || (_templateObject$
|
|
|
64710
64710
|
}, function (props) {
|
|
64711
64711
|
return props.show ? "1" : "0";
|
|
64712
64712
|
}, function (props) {
|
|
64713
|
-
|
|
64714
|
-
return props.position ? "".concat(((_props$position = props.position) === null || _props$position === void 0 ? void 0 : _props$position.top) + ((_props$position2 = props.position) === null || _props$position2 === void 0 ? void 0 : _props$position2.height)) : "0";
|
|
64713
|
+
return props.position.maxHeight + "px";
|
|
64715
64714
|
}, function (props) {
|
|
64716
|
-
return props.position
|
|
64715
|
+
return props.position.maxWidth + "px";
|
|
64717
64716
|
}, function (props) {
|
|
64718
|
-
|
|
64719
|
-
return (_props$position3 = props.position) === null || _props$position3 === void 0 ? void 0 : _props$position3.horizontalPosition;
|
|
64717
|
+
return props.position.top !== null && "top: ".concat(props.position.top, "px;");
|
|
64720
64718
|
}, function (props) {
|
|
64721
|
-
|
|
64722
|
-
return (_props$position4 = props.position) === null || _props$position4 === void 0 ? void 0 : _props$position4.verticalPosition;
|
|
64719
|
+
return props.position.bottom !== null && "bottom: ".concat(props.position.bottom, "px;");
|
|
64723
64720
|
}, function (props) {
|
|
64724
|
-
return
|
|
64721
|
+
return props.position.left !== null && "left: ".concat(props.position.left, "px;");
|
|
64725
64722
|
}, function (props) {
|
|
64726
|
-
return
|
|
64723
|
+
return props.position.right !== null && "right: ".concat(props.position.right, "px;");
|
|
64727
64724
|
}, function (props) {
|
|
64728
|
-
|
|
64729
|
-
return (_props$position5 = props.position) !== null && _props$position5 !== void 0 && _props$position5.maxWidth ? props.position.maxWidth != "100vw" ? props.position.maxWidth + "px" : "100vw" : "100vw";
|
|
64725
|
+
return getComponentPropValue(props.theme, "Popover", props.color, "enabled", "boxShadow");
|
|
64730
64726
|
}, function (props) {
|
|
64731
|
-
|
|
64732
|
-
return (_props$position6 = props.position) !== null && _props$position6 !== void 0 && _props$position6.maxHeight ? props.position.maxHeight != "100vh" ? props.position.maxHeight + "px" : "100vh" : "100vh";
|
|
64727
|
+
return getBorderRadiusValueWithUnits(props.theme, props.borderRadius);
|
|
64733
64728
|
}, function (props) {
|
|
64734
64729
|
return getColorRgbaValue(props.theme, "Popover", "default", "enabled", "bg");
|
|
64735
64730
|
}, function (props) {
|
|
@@ -64741,25 +64736,38 @@ var Popover$1 = /*#__PURE__*/React__default["default"].forwardRef(function (prop
|
|
|
64741
64736
|
vertical = props.vertical,
|
|
64742
64737
|
horizontal = props.horizontal,
|
|
64743
64738
|
offset = props.offset,
|
|
64744
|
-
zIndex = props.zIndex
|
|
64745
|
-
|
|
64739
|
+
zIndex = props.zIndex;
|
|
64740
|
+
props.popoverContainer;
|
|
64741
|
+
var portalTarget = props.portalTarget,
|
|
64746
64742
|
closeOnClickOutside = props.closeOnClickOutside,
|
|
64743
|
+
closeOnScroll = props.closeOnScroll,
|
|
64747
64744
|
onOpen = props.onOpen,
|
|
64748
64745
|
onClose = props.onClose,
|
|
64749
64746
|
className = props.className,
|
|
64750
64747
|
style = props.style,
|
|
64751
64748
|
children = props.children,
|
|
64752
64749
|
rest = _objectWithoutProperties__default["default"](props, _excluded$N);
|
|
64750
|
+
var _useState = React.useState(document.body),
|
|
64751
|
+
_useState2 = _slicedToArray__default["default"](_useState, 2),
|
|
64752
|
+
portal = _useState2[0],
|
|
64753
|
+
setPortal = _useState2[1];
|
|
64753
64754
|
var theme = useTheme$1();
|
|
64754
64755
|
var popoverRef = React.useRef(ref);
|
|
64755
|
-
var
|
|
64756
|
-
_useState2 = _slicedToArray__default["default"](_useState, 2),
|
|
64757
|
-
show = _useState2[0],
|
|
64758
|
-
setShow = _useState2[1];
|
|
64759
|
-
var _useState3 = React.useState(),
|
|
64756
|
+
var _useState3 = React.useState(false),
|
|
64760
64757
|
_useState4 = _slicedToArray__default["default"](_useState3, 2),
|
|
64761
|
-
|
|
64762
|
-
|
|
64758
|
+
show = _useState4[0],
|
|
64759
|
+
setShow = _useState4[1];
|
|
64760
|
+
var _useState5 = React.useState({
|
|
64761
|
+
top: null,
|
|
64762
|
+
bottom: null,
|
|
64763
|
+
left: null,
|
|
64764
|
+
right: null,
|
|
64765
|
+
maxHeight: null,
|
|
64766
|
+
width: null
|
|
64767
|
+
}),
|
|
64768
|
+
_useState6 = _slicedToArray__default["default"](_useState5, 2),
|
|
64769
|
+
popoverPosition = _useState6[0],
|
|
64770
|
+
setPopoverPosition = _useState6[1];
|
|
64763
64771
|
|
|
64764
64772
|
//Expose functions through ref
|
|
64765
64773
|
React.useImperativeHandle(ref, function () {
|
|
@@ -64784,115 +64792,145 @@ var Popover$1 = /*#__PURE__*/React__default["default"].forwardRef(function (prop
|
|
|
64784
64792
|
onClose(event);
|
|
64785
64793
|
};
|
|
64786
64794
|
React.useEffect(function () {
|
|
64787
|
-
if (anchorElement && show
|
|
64788
|
-
|
|
64789
|
-
|
|
64790
|
-
|
|
64791
|
-
|
|
64792
|
-
|
|
64793
|
-
|
|
64794
|
-
var findPopoverPosition = function findPopoverPosition(anchorElPosition, anchorViewPortPosition) {
|
|
64795
|
-
var _document$body = document.body;
|
|
64796
|
-
_document$body.clientHeight;
|
|
64797
|
-
var windowWidth = _document$body.clientWidth;
|
|
64798
|
-
var _window = window,
|
|
64799
|
-
windowInnerHeight = _window.innerHeight,
|
|
64800
|
-
windowInnerWidth = _window.innerWidth;
|
|
64801
|
-
var popoverMeasures = getElementPosition(popoverRef.current);
|
|
64802
|
-
if (popoverMeasures && anchorElPosition) {
|
|
64803
|
-
var _ref = horizontal ? findHorizontalPosition(horizontal, anchorElPosition, popoverMeasures, anchorViewPortPosition, windowInnerWidth) : {
|
|
64804
|
-
horizontalPosition: "",
|
|
64805
|
-
maxWidth: "100vw"
|
|
64806
|
-
},
|
|
64807
|
-
horizontalPosition = _ref.horizontalPosition,
|
|
64808
|
-
maxWidth = _ref.maxWidth;
|
|
64809
|
-
var _ref2 = vertical ? findVerticalPosition(vertical, anchorElPosition, popoverMeasures, anchorViewPortPosition, windowInnerHeight) : {
|
|
64810
|
-
verticalPosition: "",
|
|
64811
|
-
maxHeight: "100vh"
|
|
64812
|
-
},
|
|
64813
|
-
verticalPosition = _ref2.verticalPosition,
|
|
64814
|
-
maxHeight = _ref2.maxHeight;
|
|
64815
|
-
if (!horizontal) {
|
|
64816
|
-
maxWidth = "100vw";
|
|
64817
|
-
//horizontal
|
|
64818
|
-
if (popoverMeasures.width / 2 <= anchorElPosition.left + anchorElPosition.width / 2 && popoverMeasures.width / 2 <= windowWidth - anchorElPosition.right + anchorElPosition.width / 2) {
|
|
64819
|
-
horizontalPosition = "left: ".concat(anchorElPosition.left + anchorElPosition.width / 2 - popoverMeasures.width / 2, "px");
|
|
64820
|
-
} else if (popoverMeasures.width / 2 > anchorElPosition.left + anchorElPosition.width / 2) {
|
|
64821
|
-
horizontalPosition = "left: 0";
|
|
64795
|
+
if (anchorElement && show === true) {
|
|
64796
|
+
if (portalTarget) {
|
|
64797
|
+
setPortal(portalTarget !== null && portalTarget !== void 0 && portalTarget.current ? portalTarget.current : portalTarget);
|
|
64798
|
+
} else {
|
|
64799
|
+
//todo set relative implicitly to anchor
|
|
64800
|
+
if (anchorElement !== null && anchorElement !== void 0 && anchorElement.current) {
|
|
64801
|
+
anchorElement.current.style.position = "relative";
|
|
64822
64802
|
} else {
|
|
64823
|
-
|
|
64803
|
+
anchorElement.style.position = "relative";
|
|
64824
64804
|
}
|
|
64805
|
+
setPortal(anchorElement !== null && anchorElement !== void 0 && anchorElement.current ? anchorElement.current : anchorElement);
|
|
64806
|
+
}
|
|
64807
|
+
}
|
|
64808
|
+
}, [anchorElement, show]);
|
|
64809
|
+
React.useEffect(function () {
|
|
64810
|
+
if (anchorElement && show == true) {
|
|
64811
|
+
var anchorElPosition = getElementPositionInContainer(anchorElement !== null && anchorElement !== void 0 && anchorElement.current ? anchorElement.current : anchorElement, portalTarget);
|
|
64812
|
+
var popoverMeasures = getElementMeasures(popoverRef.current);
|
|
64813
|
+
var container = portalTarget ? portalTarget.current ? portalTarget.current : portalTarget : document.body;
|
|
64814
|
+
var containerMeasures = getElementMeasures(container);
|
|
64815
|
+
var resultPosition = getPopoverPosition(anchorElPosition, popoverMeasures, containerMeasures, offset, portalTarget);
|
|
64816
|
+
setPopoverPosition(resultPosition);
|
|
64817
|
+
}
|
|
64818
|
+
}, [anchorElement, vertical, horizontal, show, portal]);
|
|
64819
|
+
var getPopoverPosition = function getPopoverPosition(anchorPosition, popoverMeasures, containerMeasures, offset, portalTarget) {
|
|
64820
|
+
var freeSpaceTop = getFreeSpaceFromTheTop(anchorPosition, offset);
|
|
64821
|
+
var freeSpaceBottom = getFreeSpaceFromTheBottom(anchorPosition, offset, containerMeasures);
|
|
64822
|
+
var freeSpaceLeft = getFreeSpaceToTheLeft(anchorPosition);
|
|
64823
|
+
var position = {
|
|
64824
|
+
top: null,
|
|
64825
|
+
bottom: null,
|
|
64826
|
+
left: null,
|
|
64827
|
+
right: null,
|
|
64828
|
+
maxHeight: null,
|
|
64829
|
+
maxWidth: null
|
|
64830
|
+
};
|
|
64831
|
+
var anchMeas = getElementMeasures(portal);
|
|
64832
|
+
|
|
64833
|
+
// getting vertical position and max height boundaries
|
|
64834
|
+
if (freeSpaceTop > freeSpaceBottom) {
|
|
64835
|
+
if (portalTarget) {
|
|
64836
|
+
position.top = anchorPosition.top - offset - popoverMeasures.height > 0 ? anchorPosition.top - offset - popoverMeasures.height : 0;
|
|
64837
|
+
} else {
|
|
64838
|
+
position.top = anchorPosition.top - offset - popoverMeasures.height > 0 ? 0 - popoverMeasures.height : 0 - freeSpaceTop - offset;
|
|
64839
|
+
}
|
|
64840
|
+
position.maxHeight = freeSpaceTop;
|
|
64841
|
+
} else {
|
|
64842
|
+
if (portalTarget) {
|
|
64843
|
+
position.top = anchorPosition.bottom + offset;
|
|
64844
|
+
} else {
|
|
64845
|
+
position.top = anchMeas.height + offset;
|
|
64846
|
+
}
|
|
64847
|
+
position.maxHeight = freeSpaceBottom;
|
|
64848
|
+
}
|
|
64849
|
+
|
|
64850
|
+
// getting horizontal positio and max width boundaries
|
|
64851
|
+
if (horizontal === "left") {
|
|
64852
|
+
position.maxWidth = containerMeasures.width - anchorPosition.left;
|
|
64853
|
+
if (portalTarget) {
|
|
64854
|
+
position.left = anchorPosition.left;
|
|
64855
|
+
} else {
|
|
64856
|
+
position.left = 0;
|
|
64857
|
+
}
|
|
64858
|
+
} else if (horizontal === "right") {
|
|
64859
|
+
position.maxWidth = anchorPosition.right;
|
|
64860
|
+
if (portalTarget) {
|
|
64861
|
+
position.left = anchorPosition.right - popoverMeasures.width > 0 ? anchorPosition.right - popoverMeasures.width : 0;
|
|
64862
|
+
} else {
|
|
64863
|
+
position.right = 0;
|
|
64825
64864
|
}
|
|
64826
|
-
|
|
64827
|
-
|
|
64828
|
-
|
|
64829
|
-
|
|
64830
|
-
|
|
64831
|
-
|
|
64865
|
+
} else {
|
|
64866
|
+
position.maxWidth = containerMeasures.width;
|
|
64867
|
+
if (anchorPosition.horizontalCenter >= popoverMeasures.width / 2) {
|
|
64868
|
+
if (portalTarget) {
|
|
64869
|
+
position.left = anchorPosition.horizontalCenter - popoverMeasures.width / 2;
|
|
64870
|
+
} else {
|
|
64871
|
+
position.left = anchMeas.width / 2 - popoverMeasures.width / 2;
|
|
64872
|
+
}
|
|
64873
|
+
} else {
|
|
64874
|
+
if (portalTarget) {
|
|
64875
|
+
position.left = 0;
|
|
64832
64876
|
} else {
|
|
64833
|
-
|
|
64834
|
-
maxHeight = "".concat(windowInnerHeight - anchorViewPortPosition.bottom - offset);
|
|
64835
|
-
verticalPosition = "top: ".concat(anchorElPosition.bottom + offset, "px");
|
|
64877
|
+
position.left = 0 - freeSpaceLeft;
|
|
64836
64878
|
}
|
|
64837
64879
|
}
|
|
64838
|
-
return {
|
|
64839
|
-
horizontalPosition: horizontalPosition,
|
|
64840
|
-
verticalPosition: verticalPosition,
|
|
64841
|
-
maxHeight: maxHeight,
|
|
64842
|
-
maxWidth: maxWidth
|
|
64843
|
-
};
|
|
64844
64880
|
}
|
|
64845
|
-
return
|
|
64881
|
+
return position;
|
|
64846
64882
|
};
|
|
64847
|
-
var
|
|
64848
|
-
|
|
64849
|
-
|
|
64850
|
-
|
|
64851
|
-
|
|
64852
|
-
|
|
64853
|
-
|
|
64854
|
-
|
|
64855
|
-
horizontalResult = "left: ".concat(anchorElPosition.left, "px");
|
|
64856
|
-
} else if (horizontalPosition == "center") {
|
|
64857
|
-
maxWidth = "100vw";
|
|
64858
|
-
horizontalResult = "left: ".concat(anchorElPosition.left + anchorElPosition.width / 2 - popoverMeasures.width / 2, "px");
|
|
64859
|
-
}
|
|
64860
|
-
return {
|
|
64861
|
-
horizontalPosition: horizontalResult,
|
|
64862
|
-
maxWidth: maxWidth
|
|
64863
|
-
};
|
|
64883
|
+
var getFreeSpaceToTheLeft = function getFreeSpaceToTheLeft(anchorPosition) {
|
|
64884
|
+
return anchorPosition.left;
|
|
64885
|
+
};
|
|
64886
|
+
|
|
64887
|
+
// Vertical offset can exist
|
|
64888
|
+
var getFreeSpaceFromTheTop = function getFreeSpaceFromTheTop(anchorPosition, offset) {
|
|
64889
|
+
if (vertical === "bottom") return 0;
|
|
64890
|
+
return anchorPosition.top - offset;
|
|
64864
64891
|
};
|
|
64865
|
-
|
|
64866
|
-
|
|
64867
|
-
|
|
64868
|
-
if (
|
|
64869
|
-
|
|
64870
|
-
|
|
64871
|
-
|
|
64872
|
-
|
|
64873
|
-
|
|
64892
|
+
|
|
64893
|
+
// Vertical offset can exist
|
|
64894
|
+
var getFreeSpaceFromTheBottom = function getFreeSpaceFromTheBottom(anchorPosition, offset, containerMeasures) {
|
|
64895
|
+
if (vertical === "top") return 0;
|
|
64896
|
+
return containerMeasures.height - anchorPosition.bottom - offset;
|
|
64897
|
+
};
|
|
64898
|
+
var getElementPositionInContainer = function getElementPositionInContainer(element, portalTarget) {
|
|
64899
|
+
//if there is no portal target get position relative to document.body
|
|
64900
|
+
if (!portalTarget || portalTarget == document.body) {
|
|
64901
|
+
var clientRect = element.getBoundingClientRect();
|
|
64902
|
+
var scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
|
|
64903
|
+
var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
|
|
64904
|
+
return {
|
|
64905
|
+
left: clientRect.left + scrollLeft,
|
|
64906
|
+
top: clientRect.top + scrollTop,
|
|
64907
|
+
right: clientRect.right + scrollLeft,
|
|
64908
|
+
bottom: clientRect.bottom + scrollTop,
|
|
64909
|
+
height: clientRect.height,
|
|
64910
|
+
width: clientRect.width,
|
|
64911
|
+
horizontalCenter: clientRect.left + scrollLeft + clientRect.width / 2
|
|
64912
|
+
};
|
|
64874
64913
|
}
|
|
64914
|
+
|
|
64915
|
+
//else find relative to portal target
|
|
64916
|
+
scrollLeft = portalTarget.offsetLeft;
|
|
64917
|
+
scrollTop = portalTarget.offsetTop;
|
|
64875
64918
|
return {
|
|
64876
|
-
|
|
64877
|
-
|
|
64919
|
+
left: element.offsetLeft,
|
|
64920
|
+
top: element.offsetTop,
|
|
64921
|
+
right: element.offsetLeft + element.offsetWidth,
|
|
64922
|
+
bottom: element.offsetTop + element.offsetHeight,
|
|
64923
|
+
height: element.offsetHeight,
|
|
64924
|
+
width: element.offsetWidth,
|
|
64925
|
+
horizontalCenter: element.offsetLeft + element.offsetWidth / 2
|
|
64878
64926
|
};
|
|
64879
64927
|
};
|
|
64880
|
-
var
|
|
64881
|
-
var clientRect = element.getBoundingClientRect();
|
|
64882
|
-
var scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
|
|
64883
|
-
var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
|
|
64928
|
+
var getElementMeasures = function getElementMeasures(element) {
|
|
64884
64929
|
return {
|
|
64885
|
-
|
|
64886
|
-
|
|
64887
|
-
right: clientRect.right + scrollLeft,
|
|
64888
|
-
bottom: clientRect.bottom + scrollTop,
|
|
64889
|
-
height: clientRect.height,
|
|
64890
|
-
width: clientRect.width
|
|
64930
|
+
height: element.offsetHeight,
|
|
64931
|
+
width: element.offsetWidth
|
|
64891
64932
|
};
|
|
64892
64933
|
};
|
|
64893
|
-
var getElementViewPortPosition = function getElementViewPortPosition(element) {
|
|
64894
|
-
return element.getBoundingClientRect();
|
|
64895
|
-
};
|
|
64896
64934
|
|
|
64897
64935
|
//Outside click handling
|
|
64898
64936
|
React.useEffect(function () {
|
|
@@ -64901,11 +64939,18 @@ var Popover$1 = /*#__PURE__*/React__default["default"].forwardRef(function (prop
|
|
|
64901
64939
|
if (closeOnClickOutside == true) _close();
|
|
64902
64940
|
}
|
|
64903
64941
|
};
|
|
64942
|
+
var handleScroll = function handleScroll(event) {
|
|
64943
|
+
if (popoverRef !== null && popoverRef !== void 0 && popoverRef.current && !(popoverRef !== null && popoverRef !== void 0 && popoverRef.current.contains(event.target))) {
|
|
64944
|
+
if (closeOnScroll == true) _close();
|
|
64945
|
+
}
|
|
64946
|
+
};
|
|
64904
64947
|
//Fired on component mount
|
|
64905
|
-
document.addEventListener(
|
|
64948
|
+
document.addEventListener("click", handleClickOutside, true);
|
|
64949
|
+
document.addEventListener("scroll", handleScroll, true);
|
|
64906
64950
|
return function () {
|
|
64907
64951
|
//Fired on component unmount
|
|
64908
|
-
document.removeEventListener(
|
|
64952
|
+
document.removeEventListener("click", handleClickOutside, true);
|
|
64953
|
+
document.removeEventListener("scroll", handleScroll, true);
|
|
64909
64954
|
};
|
|
64910
64955
|
}, []);
|
|
64911
64956
|
return /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React__default["default"].createElement(StyledPopover, _extends__default$1["default"]({
|
|
@@ -64916,8 +64961,11 @@ var Popover$1 = /*#__PURE__*/React__default["default"].forwardRef(function (prop
|
|
|
64916
64961
|
show: show,
|
|
64917
64962
|
borderRadius: borderRadius,
|
|
64918
64963
|
className: className,
|
|
64919
|
-
style: style
|
|
64920
|
-
|
|
64964
|
+
style: style,
|
|
64965
|
+
onBlur: _close
|
|
64966
|
+
}, rest), children),
|
|
64967
|
+
// parentContainer
|
|
64968
|
+
portal);
|
|
64921
64969
|
});
|
|
64922
64970
|
Popover$1.defaultProps = {
|
|
64923
64971
|
className: "",
|
|
@@ -64925,8 +64973,8 @@ Popover$1.defaultProps = {
|
|
|
64925
64973
|
borderRadius: "regular",
|
|
64926
64974
|
horizontal: null,
|
|
64927
64975
|
offset: 0,
|
|
64928
|
-
|
|
64929
|
-
|
|
64976
|
+
closeOnClickOutside: false,
|
|
64977
|
+
closeOnScroll: false,
|
|
64930
64978
|
onOpen: function onOpen() {},
|
|
64931
64979
|
onClose: function onClose() {}
|
|
64932
64980
|
};
|
|
@@ -64937,18 +64985,23 @@ Popover$1.propTypes = {
|
|
|
64937
64985
|
*/
|
|
64938
64986
|
anchorElement: PropTypes__default["default"].object,
|
|
64939
64987
|
borderRadius: PropTypes__default["default"].oneOf(["regular", "curved"]),
|
|
64940
|
-
horizontal: PropTypes__default["default"].oneOf(["left", "right", "center"]),
|
|
64988
|
+
horizontal: PropTypes__default["default"].oneOf(["left", "right", "center", null]),
|
|
64941
64989
|
vertical: PropTypes__default["default"].oneOf(["top", "bottom", null]),
|
|
64942
64990
|
/**
|
|
64943
64991
|
* popoverContainer is DOM element, popover won't be mounted into the DOM as a child of the nearest parent node, it will be inserted as a child of popoverContainer location in the DOM
|
|
64944
64992
|
*/
|
|
64945
64993
|
popoverContainer: PropTypes__default["default"].any,
|
|
64994
|
+
/**
|
|
64995
|
+
* portalTarget can be DOM element or a ref to an element, possible value is `document.body`
|
|
64996
|
+
*/
|
|
64997
|
+
portalTarget: PropTypes__default["default"].any,
|
|
64946
64998
|
/**
|
|
64947
64999
|
* Offset from anchor element in pixels
|
|
64948
65000
|
*/
|
|
64949
65001
|
offset: PropTypes__default["default"].number,
|
|
64950
65002
|
zIndex: PropTypes__default["default"].number,
|
|
64951
65003
|
closeOnClickOutside: PropTypes__default["default"].bool,
|
|
65004
|
+
closeOnScroll: PropTypes__default["default"].bool,
|
|
64952
65005
|
//--------------------------
|
|
64953
65006
|
onOpen: PropTypes__default["default"].func,
|
|
64954
65007
|
onClose: PropTypes__default["default"].func,
|
|
@@ -65956,7 +66009,7 @@ ThemeProvider.propTypes = {
|
|
|
65956
66009
|
theme: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].object])
|
|
65957
66010
|
};
|
|
65958
66011
|
|
|
65959
|
-
var _excluded$M = ["control", "openOnClick", "openOnHover", "offset", "verticalAlignment", "horizontalAlignment", "widthFitContent", "closeOnItemSelect", "onFocus", "onBlur", "onClick", "onKeyDown", "onMouseEnter", "onMouseLeave", "onItemSelected", "animation", "className", "style", "color", "size", "popoverProps", "children"];
|
|
66012
|
+
var _excluded$M = ["control", "openOnClick", "openOnHover", "offset", "verticalAlignment", "horizontalAlignment", "widthFitContent", "closeOnItemSelect", "portalTarget", "onFocus", "onBlur", "onClick", "onKeyDown", "onMouseEnter", "onMouseLeave", "onItemSelected", "animation", "className", "style", "color", "size", "popoverProps", "children"];
|
|
65960
66013
|
var _templateObject$J, _templateObject2$f;
|
|
65961
66014
|
var StyledDropDown = newStyled.div(_templateObject$J || (_templateObject$J = _taggedTemplateLiteral__default["default"]([""])));
|
|
65962
66015
|
var PopoverContent = newStyled(motion.div)(_templateObject2$f || (_templateObject2$f = _taggedTemplateLiteral__default["default"](["\n padding: 0.25rem;\n gap: 0.25rem;\n display: flex;\n flex-direction: column;\n ", ";\n background-color: ", ";\n"])), function (props) {
|
|
@@ -65973,6 +66026,7 @@ var DropdownMenu = /*#__PURE__*/React__default["default"].forwardRef(function (p
|
|
|
65973
66026
|
horizontalAlignment = props.horizontalAlignment,
|
|
65974
66027
|
widthFitContent = props.widthFitContent,
|
|
65975
66028
|
closeOnItemSelect = props.closeOnItemSelect,
|
|
66029
|
+
portalTarget = props.portalTarget,
|
|
65976
66030
|
onFocus = props.onFocus,
|
|
65977
66031
|
onBlur = props.onBlur,
|
|
65978
66032
|
onClick = props.onClick,
|
|
@@ -66106,6 +66160,8 @@ var DropdownMenu = /*#__PURE__*/React__default["default"].forwardRef(function (p
|
|
|
66106
66160
|
maxHeight: "unset"
|
|
66107
66161
|
},
|
|
66108
66162
|
closeOnClickOutside: false //dropdown has it's own outside click handler which includes control (element that opens dropdown)
|
|
66163
|
+
,
|
|
66164
|
+
portalTarget: portalTarget
|
|
66109
66165
|
}, popoverProps), /*#__PURE__*/React__default["default"].createElement(PopoverContent, {
|
|
66110
66166
|
ref: menuContentRef,
|
|
66111
66167
|
widthFitContent: widthFitContent,
|
|
@@ -66181,6 +66237,10 @@ DropdownMenu.propTypes = {
|
|
|
66181
66237
|
* Close menu when item is selected
|
|
66182
66238
|
*/
|
|
66183
66239
|
closeOnItemSelect: PropTypes__default["default"].bool,
|
|
66240
|
+
/**
|
|
66241
|
+
* portalTarget can be DOM element or a ref to an element, possible value is `document.body`
|
|
66242
|
+
*/
|
|
66243
|
+
portalTarget: PropTypes__default["default"].any,
|
|
66184
66244
|
//---------------------------------------------------------------
|
|
66185
66245
|
onBlur: PropTypes__default["default"].func,
|
|
66186
66246
|
onFocus: PropTypes__default["default"].func,
|
|
@@ -72376,7 +72436,6 @@ DragAndDropFile.defaultProps = {
|
|
|
72376
72436
|
id: "",
|
|
72377
72437
|
disabled: false,
|
|
72378
72438
|
acceptDropzone: {},
|
|
72379
|
-
acceptInput: acceptInput,
|
|
72380
72439
|
multiple: false,
|
|
72381
72440
|
selectFileText: "Select file",
|
|
72382
72441
|
dndFileText: "Drag and drop file here or",
|