@kdcloudjs/kdesign 1.5.5 → 1.5.6
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/CHANGELOG.md +20 -0
- package/dist/kdesign.css +1 -1
- package/dist/kdesign.css.map +1 -1
- package/dist/kdesign.js +63 -39
- package/dist/kdesign.js.map +1 -1
- package/dist/kdesign.min.css +1 -1
- package/dist/kdesign.min.js +3 -3
- package/dist/kdesign.min.js.map +1 -1
- package/es/_utils/usePopper.js +62 -38
- package/lib/_utils/usePopper.js +62 -38
- package/package.json +1 -1
package/dist/kdesign.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
*
|
|
3
|
-
* @kdcloudjs/kdesign v1.5.
|
|
3
|
+
* @kdcloudjs/kdesign v1.5.5
|
|
4
4
|
*
|
|
5
5
|
* Copyright 2020-present, Kingdee, Inc.
|
|
6
6
|
* All rights reserved.
|
|
@@ -1567,6 +1567,11 @@ function usePopper(locatorElement, popperElement, props) {
|
|
|
1567
1567
|
visible = _useState10[0],
|
|
1568
1568
|
setVisible = _useState10[1];
|
|
1569
1569
|
|
|
1570
|
+
var _useState11 = Object(react__WEBPACK_IMPORTED_MODULE_19__["useState"])(false),
|
|
1571
|
+
_useState12 = _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_6___default()(_useState11, 2),
|
|
1572
|
+
active = _useState12[0],
|
|
1573
|
+
setActive = _useState12[1];
|
|
1574
|
+
|
|
1570
1575
|
Object(react__WEBPACK_IMPORTED_MODULE_19__["useEffect"])(function () {
|
|
1571
1576
|
if (props.visible) {
|
|
1572
1577
|
!exist && setExist(true);
|
|
@@ -1577,20 +1582,20 @@ function usePopper(locatorElement, popperElement, props) {
|
|
|
1577
1582
|
}
|
|
1578
1583
|
}, [exist, props.visible]);
|
|
1579
1584
|
|
|
1580
|
-
var
|
|
1581
|
-
_useState12 = _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_6___default()(_useState11, 2),
|
|
1582
|
-
evType = _useState12[0],
|
|
1583
|
-
setEvType = _useState12[1];
|
|
1584
|
-
|
|
1585
|
-
var _useState13 = Object(react__WEBPACK_IMPORTED_MODULE_19__["useState"])(),
|
|
1585
|
+
var _useState13 = Object(react__WEBPACK_IMPORTED_MODULE_19__["useState"])(''),
|
|
1586
1586
|
_useState14 = _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_6___default()(_useState13, 2),
|
|
1587
|
-
|
|
1588
|
-
|
|
1587
|
+
evType = _useState14[0],
|
|
1588
|
+
setEvType = _useState14[1];
|
|
1589
1589
|
|
|
1590
|
-
var _useState15 = Object(react__WEBPACK_IMPORTED_MODULE_19__["useState"])(
|
|
1590
|
+
var _useState15 = Object(react__WEBPACK_IMPORTED_MODULE_19__["useState"])(),
|
|
1591
1591
|
_useState16 = _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_6___default()(_useState15, 2),
|
|
1592
|
-
|
|
1593
|
-
|
|
1592
|
+
align = _useState16[0],
|
|
1593
|
+
setAlign = _useState16[1];
|
|
1594
|
+
|
|
1595
|
+
var _useState17 = Object(react__WEBPACK_IMPORTED_MODULE_19__["useState"])(placement),
|
|
1596
|
+
_useState18 = _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_6___default()(_useState17, 2),
|
|
1597
|
+
nextPlacement = _useState18[0],
|
|
1598
|
+
setNextPlacement = _useState18[1];
|
|
1594
1599
|
|
|
1595
1600
|
var alignPopper = Object(react__WEBPACK_IMPORTED_MODULE_19__["useCallback"])(function () {
|
|
1596
1601
|
if (locatorRef !== null && locatorRef !== void 0 && locatorRef.current && popperRef !== null && popperRef !== void 0 && popperRef.current) {
|
|
@@ -1635,39 +1640,47 @@ function usePopper(locatorElement, popperElement, props) {
|
|
|
1635
1640
|
bottom: locatorTop + borderTop + translateTop + height - containerTop - scrollTop
|
|
1636
1641
|
};
|
|
1637
1642
|
var currentPos = trigger === 'contextMenu' ? mousePos : locatorPos;
|
|
1638
|
-
var
|
|
1643
|
+
var currentPlacement = nextPlacement;
|
|
1639
1644
|
|
|
1640
1645
|
if (autoPlacement) {
|
|
1641
1646
|
if (top - gap - popperHeight <= 5 && bottom + gap + popperHeight < document.body.clientHeight - 5) {
|
|
1642
|
-
|
|
1647
|
+
currentPlacement = currentPlacement.replace('top', 'bottom');
|
|
1643
1648
|
}
|
|
1644
1649
|
|
|
1645
1650
|
if (bottom + gap + popperHeight >= document.body.clientHeight - 5 && top - gap - popperHeight > 5) {
|
|
1646
|
-
|
|
1651
|
+
currentPlacement = currentPlacement.replace('bottom', 'top');
|
|
1647
1652
|
}
|
|
1648
1653
|
|
|
1649
1654
|
if (left + popperWidth >= document.body.clientWidth - 5 && right - popperWidth > 5) {
|
|
1650
|
-
|
|
1655
|
+
currentPlacement = currentPlacement.replace('Left', 'Right');
|
|
1651
1656
|
}
|
|
1652
1657
|
|
|
1653
1658
|
if (right - popperWidth <= 5 && left + popperWidth < document.body.clientWidth - 5) {
|
|
1654
|
-
|
|
1659
|
+
currentPlacement = currentPlacement.replace('Right', 'Left');
|
|
1655
1660
|
}
|
|
1656
1661
|
|
|
1657
1662
|
if (top + popperHeight >= document.body.clientHeight - 5 && bottom - popperHeight > 5) {
|
|
1658
|
-
|
|
1663
|
+
currentPlacement = currentPlacement.replace('Top', 'Bottom');
|
|
1659
1664
|
}
|
|
1660
1665
|
|
|
1661
1666
|
if (bottom - popperHeight <= 5 && top + popperHeight < document.body.clientHeight - 5) {
|
|
1662
|
-
|
|
1667
|
+
currentPlacement = currentPlacement.replace('Bottom', 'Top');
|
|
1663
1668
|
}
|
|
1664
1669
|
|
|
1665
1670
|
if (left - gap - popperWidth <= 5 && right + gap + popperWidth < document.body.clientWidth - 5) {
|
|
1666
|
-
|
|
1671
|
+
currentPlacement = currentPlacement.replace('left', 'right');
|
|
1667
1672
|
}
|
|
1668
1673
|
|
|
1669
1674
|
if (right + gap + popperWidth >= document.body.clientWidth - 5 && left - gap - popperWidth > 5) {
|
|
1670
|
-
|
|
1675
|
+
currentPlacement = currentPlacement.replace('right', 'left');
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1678
|
+
if (right - width / 2 + popperWidth / 2 >= document.body.clientWidth - 5 && right - popperWidth > 5) {
|
|
1679
|
+
currentPlacement += 'Right';
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1682
|
+
if (left - width / 2 - popperWidth / 2 <= 5 && left + popperWidth < document.body.clientWidth - 5) {
|
|
1683
|
+
currentPlacement += 'Left';
|
|
1671
1684
|
}
|
|
1672
1685
|
}
|
|
1673
1686
|
|
|
@@ -1729,16 +1742,16 @@ function usePopper(locatorElement, popperElement, props) {
|
|
|
1729
1742
|
top: topBottom
|
|
1730
1743
|
}
|
|
1731
1744
|
};
|
|
1732
|
-
var alignPos = mapAlign[
|
|
1745
|
+
var alignPos = mapAlign[currentPlacement];
|
|
1733
1746
|
var _arrowPos = {
|
|
1734
1747
|
top: 0,
|
|
1735
1748
|
left: 0
|
|
1736
1749
|
};
|
|
1737
1750
|
|
|
1738
|
-
if (/left/.test(
|
|
1739
|
-
if (/Top/.test(
|
|
1751
|
+
if (/left/.test(currentPlacement) || /right/.test(currentPlacement)) {
|
|
1752
|
+
if (/Top/.test(currentPlacement)) {
|
|
1740
1753
|
_arrowPos.top = arrowOffset;
|
|
1741
|
-
} else if (/Bottom/.test(
|
|
1754
|
+
} else if (/Bottom/.test(currentPlacement)) {
|
|
1742
1755
|
_arrowPos.top = popperHeight - arrowOffset - 2 * arrowSize;
|
|
1743
1756
|
} else {
|
|
1744
1757
|
_arrowPos.top = (popperHeight - arrowWidth) / 2 - 1;
|
|
@@ -1765,29 +1778,40 @@ function usePopper(locatorElement, popperElement, props) {
|
|
|
1765
1778
|
_arrowPos.top += scrollBottom - document.body.clientHeight;
|
|
1766
1779
|
}
|
|
1767
1780
|
}
|
|
1768
|
-
}
|
|
1769
|
-
|
|
1770
|
-
if (/top/.test(_currentPlacement) || /bottom/.test(_currentPlacement)) {
|
|
1771
|
-
if (/Left/.test(_currentPlacement)) {
|
|
1781
|
+
} else if (/top/.test(currentPlacement) || /bottom/.test(currentPlacement)) {
|
|
1782
|
+
if (/Left/.test(currentPlacement)) {
|
|
1772
1783
|
_arrowPos.left = arrowOffset;
|
|
1773
|
-
} else if (/Right/.test(
|
|
1784
|
+
} else if (/Right/.test(currentPlacement)) {
|
|
1774
1785
|
_arrowPos.left = popperWidth - arrowOffset - 2 * arrowSize;
|
|
1775
1786
|
} else {
|
|
1776
1787
|
_arrowPos.left = (popperWidth - arrowWidth) / 2 - 1;
|
|
1777
1788
|
}
|
|
1789
|
+
|
|
1790
|
+
if (left <= 0) {
|
|
1791
|
+
alignPos.left = locatorPos.left;
|
|
1792
|
+
_arrowPos.left = arrowOffset;
|
|
1793
|
+
} else if (right >= document.body.clientWidth) {
|
|
1794
|
+
alignPos.left = locatorPos.right - popperWidth;
|
|
1795
|
+
alignPos.right = -360;
|
|
1796
|
+
_arrowPos.left = popperWidth - arrowOffset - 2 * arrowSize;
|
|
1797
|
+
}
|
|
1778
1798
|
}
|
|
1779
1799
|
|
|
1780
1800
|
setAlign(alignPos);
|
|
1781
1801
|
setArrowPos(_arrowPos);
|
|
1782
|
-
|
|
1802
|
+
setNextPlacement(currentPlacement);
|
|
1783
1803
|
}
|
|
1784
|
-
}, [locatorRef, popperRef, container, trigger, mousePos,
|
|
1804
|
+
}, [locatorRef, popperRef, container, trigger, mousePos, autoPlacement, gap, arrowOffset, arrowSize, arrowWidth]);
|
|
1785
1805
|
Object(react__WEBPACK_IMPORTED_MODULE_19__["useEffect"])(function () {
|
|
1786
1806
|
if (canAlign) {
|
|
1787
1807
|
alignPopper();
|
|
1788
1808
|
setCanAlign(false);
|
|
1789
1809
|
props.visible === undefined && setVisible(true);
|
|
1790
1810
|
onVisibleChange && onVisibleChange(true);
|
|
1811
|
+
setActive(true);
|
|
1812
|
+
setTimeout(function () {
|
|
1813
|
+
return setActive(false);
|
|
1814
|
+
}, 200);
|
|
1791
1815
|
}
|
|
1792
1816
|
}, [alignPopper, canAlign, onVisibleChange, props]);
|
|
1793
1817
|
var arrowStyle = (_arrowStyle = {}, _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_5___default()(_arrowStyle, "--arrowSize", arrowSize + 'px'), _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_5___default()(_arrowStyle, "--arrowSpill", arrowWidth / -2 + 'px'), _arrowStyle);
|
|
@@ -1801,10 +1825,10 @@ function usePopper(locatorElement, popperElement, props) {
|
|
|
1801
1825
|
var popperProps = {
|
|
1802
1826
|
ref: popperRef,
|
|
1803
1827
|
style: popperContainerStyle,
|
|
1804
|
-
className: classnames__WEBPACK_IMPORTED_MODULE_23___default()(prefixCls, popperClassName,
|
|
1828
|
+
className: classnames__WEBPACK_IMPORTED_MODULE_23___default()(prefixCls, popperClassName, nextPlacement, _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_5___default()({
|
|
1805
1829
|
arrow: arrow,
|
|
1806
1830
|
hidden: !visible
|
|
1807
|
-
}, "".concat(
|
|
1831
|
+
}, "".concat(nextPlacement, "-active"), active))
|
|
1808
1832
|
};
|
|
1809
1833
|
var popperNode = popperRef.current;
|
|
1810
1834
|
var locatorNode = locatorRef.current;
|
|
@@ -1847,10 +1871,10 @@ function usePopper(locatorElement, popperElement, props) {
|
|
|
1847
1871
|
var triggerNode = getTriggerElement(locatorRef.current);
|
|
1848
1872
|
var triggerRect = triggerNode.getBoundingClientRect();
|
|
1849
1873
|
var popperRect = popperRef.current.getBoundingClientRect();
|
|
1850
|
-
var left = /left/.test(
|
|
1851
|
-
var right = /right/.test(
|
|
1852
|
-
var top = /top/.test(
|
|
1853
|
-
var bottom = /bottom/.test(
|
|
1874
|
+
var left = /left/.test(nextPlacement) ? popperRect.right : triggerRect.left;
|
|
1875
|
+
var right = /right/.test(nextPlacement) ? popperRect.left : triggerRect.right;
|
|
1876
|
+
var top = /top/.test(nextPlacement) ? popperRect.bottom : triggerRect.top;
|
|
1877
|
+
var bottom = /bottom/.test(nextPlacement) ? popperRect.top : triggerRect.bottom;
|
|
1854
1878
|
var X = e.clientX,
|
|
1855
1879
|
Y = e.clientY;
|
|
1856
1880
|
var inTriggerRect = X > left - 2 && X < right + 2 && Y > top - 2 && Y < bottom + 2;
|
|
@@ -1883,7 +1907,7 @@ function usePopper(locatorElement, popperElement, props) {
|
|
|
1883
1907
|
}) : document.removeEventListener(mapEvent[trigger], debounceHidePopper);
|
|
1884
1908
|
};
|
|
1885
1909
|
}
|
|
1886
|
-
}, [
|
|
1910
|
+
}, [nextPlacement, evType, exist, getTriggerElement, hidePopper, locatorRef, mouseLeaveDelay, popperRef, visible]);
|
|
1887
1911
|
Object(react__WEBPACK_IMPORTED_MODULE_19__["useEffect"])(function () {
|
|
1888
1912
|
if (visible) {
|
|
1889
1913
|
var scrollAlign = lodash_debounce__WEBPACK_IMPORTED_MODULE_22___default()(function (e) {
|