@kdcloudjs/kdesign 1.5.7 → 1.5.8
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/dist/kdesign.css +1 -1
- package/dist/kdesign.css.map +1 -1
- package/dist/kdesign.js +65 -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 +66 -38
- package/lib/_utils/usePopper.js +66 -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.7
|
|
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,49 @@ 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 (['top', 'bottom'].includes(currentPlacement)) {
|
|
1679
|
+
if (right - width / 2 + popperWidth / 2 >= document.body.clientWidth - 5 && right - popperWidth > 5) {
|
|
1680
|
+
currentPlacement += 'Right';
|
|
1681
|
+
}
|
|
1682
|
+
|
|
1683
|
+
if (left - width / 2 - popperWidth / 2 <= 5 && left + popperWidth < document.body.clientWidth - 5) {
|
|
1684
|
+
currentPlacement += 'Left';
|
|
1685
|
+
}
|
|
1671
1686
|
}
|
|
1672
1687
|
}
|
|
1673
1688
|
|
|
@@ -1729,16 +1744,16 @@ function usePopper(locatorElement, popperElement, props) {
|
|
|
1729
1744
|
top: topBottom
|
|
1730
1745
|
}
|
|
1731
1746
|
};
|
|
1732
|
-
var alignPos = mapAlign[
|
|
1747
|
+
var alignPos = mapAlign[currentPlacement];
|
|
1733
1748
|
var _arrowPos = {
|
|
1734
1749
|
top: 0,
|
|
1735
1750
|
left: 0
|
|
1736
1751
|
};
|
|
1737
1752
|
|
|
1738
|
-
if (/left/.test(
|
|
1739
|
-
if (/Top/.test(
|
|
1753
|
+
if (/left/.test(currentPlacement) || /right/.test(currentPlacement)) {
|
|
1754
|
+
if (/Top/.test(currentPlacement)) {
|
|
1740
1755
|
_arrowPos.top = arrowOffset;
|
|
1741
|
-
} else if (/Bottom/.test(
|
|
1756
|
+
} else if (/Bottom/.test(currentPlacement)) {
|
|
1742
1757
|
_arrowPos.top = popperHeight - arrowOffset - 2 * arrowSize;
|
|
1743
1758
|
} else {
|
|
1744
1759
|
_arrowPos.top = (popperHeight - arrowWidth) / 2 - 1;
|
|
@@ -1765,29 +1780,40 @@ function usePopper(locatorElement, popperElement, props) {
|
|
|
1765
1780
|
_arrowPos.top += scrollBottom - document.body.clientHeight;
|
|
1766
1781
|
}
|
|
1767
1782
|
}
|
|
1768
|
-
}
|
|
1769
|
-
|
|
1770
|
-
if (/top/.test(_currentPlacement) || /bottom/.test(_currentPlacement)) {
|
|
1771
|
-
if (/Left/.test(_currentPlacement)) {
|
|
1783
|
+
} else if (/top/.test(currentPlacement) || /bottom/.test(currentPlacement)) {
|
|
1784
|
+
if (/Left/.test(currentPlacement)) {
|
|
1772
1785
|
_arrowPos.left = arrowOffset;
|
|
1773
|
-
} else if (/Right/.test(
|
|
1786
|
+
} else if (/Right/.test(currentPlacement)) {
|
|
1774
1787
|
_arrowPos.left = popperWidth - arrowOffset - 2 * arrowSize;
|
|
1775
1788
|
} else {
|
|
1776
1789
|
_arrowPos.left = (popperWidth - arrowWidth) / 2 - 1;
|
|
1777
1790
|
}
|
|
1791
|
+
|
|
1792
|
+
if (left <= 0) {
|
|
1793
|
+
alignPos.left = locatorPos.left;
|
|
1794
|
+
_arrowPos.left = arrowOffset;
|
|
1795
|
+
} else if (right >= document.body.clientWidth) {
|
|
1796
|
+
alignPos.left = locatorPos.right - popperWidth;
|
|
1797
|
+
alignPos.right = -360;
|
|
1798
|
+
_arrowPos.left = popperWidth - arrowOffset - 2 * arrowSize;
|
|
1799
|
+
}
|
|
1778
1800
|
}
|
|
1779
1801
|
|
|
1780
1802
|
setAlign(alignPos);
|
|
1781
1803
|
setArrowPos(_arrowPos);
|
|
1782
|
-
|
|
1804
|
+
setNextPlacement(currentPlacement);
|
|
1783
1805
|
}
|
|
1784
|
-
}, [locatorRef, popperRef, container, trigger, mousePos,
|
|
1806
|
+
}, [locatorRef, popperRef, container, trigger, mousePos, autoPlacement, gap, arrowOffset, arrowSize, arrowWidth]);
|
|
1785
1807
|
Object(react__WEBPACK_IMPORTED_MODULE_19__["useEffect"])(function () {
|
|
1786
1808
|
if (canAlign) {
|
|
1787
1809
|
alignPopper();
|
|
1788
1810
|
setCanAlign(false);
|
|
1789
1811
|
props.visible === undefined && setVisible(true);
|
|
1790
1812
|
onVisibleChange && onVisibleChange(true);
|
|
1813
|
+
setActive(true);
|
|
1814
|
+
setTimeout(function () {
|
|
1815
|
+
return setActive(false);
|
|
1816
|
+
}, 200);
|
|
1791
1817
|
}
|
|
1792
1818
|
}, [alignPopper, canAlign, onVisibleChange, props]);
|
|
1793
1819
|
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 +1827,10 @@ function usePopper(locatorElement, popperElement, props) {
|
|
|
1801
1827
|
var popperProps = {
|
|
1802
1828
|
ref: popperRef,
|
|
1803
1829
|
style: popperContainerStyle,
|
|
1804
|
-
className: classnames__WEBPACK_IMPORTED_MODULE_23___default()(prefixCls, popperClassName,
|
|
1830
|
+
className: classnames__WEBPACK_IMPORTED_MODULE_23___default()(prefixCls, popperClassName, nextPlacement, _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_5___default()({
|
|
1805
1831
|
arrow: arrow,
|
|
1806
1832
|
hidden: !visible
|
|
1807
|
-
}, "".concat(
|
|
1833
|
+
}, "".concat(nextPlacement, "-active"), active))
|
|
1808
1834
|
};
|
|
1809
1835
|
var popperNode = popperRef.current;
|
|
1810
1836
|
var locatorNode = locatorRef.current;
|
|
@@ -1847,10 +1873,10 @@ function usePopper(locatorElement, popperElement, props) {
|
|
|
1847
1873
|
var triggerNode = getTriggerElement(locatorRef.current);
|
|
1848
1874
|
var triggerRect = triggerNode.getBoundingClientRect();
|
|
1849
1875
|
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(
|
|
1876
|
+
var left = /left/.test(nextPlacement) ? popperRect.right : triggerRect.left;
|
|
1877
|
+
var right = /right/.test(nextPlacement) ? popperRect.left : triggerRect.right;
|
|
1878
|
+
var top = /top/.test(nextPlacement) ? popperRect.bottom : triggerRect.top;
|
|
1879
|
+
var bottom = /bottom/.test(nextPlacement) ? popperRect.top : triggerRect.bottom;
|
|
1854
1880
|
var X = e.clientX,
|
|
1855
1881
|
Y = e.clientY;
|
|
1856
1882
|
var inTriggerRect = X > left - 2 && X < right + 2 && Y > top - 2 && Y < bottom + 2;
|
|
@@ -1883,7 +1909,7 @@ function usePopper(locatorElement, popperElement, props) {
|
|
|
1883
1909
|
}) : document.removeEventListener(mapEvent[trigger], debounceHidePopper);
|
|
1884
1910
|
};
|
|
1885
1911
|
}
|
|
1886
|
-
}, [
|
|
1912
|
+
}, [nextPlacement, evType, exist, getTriggerElement, hidePopper, locatorRef, mouseLeaveDelay, popperRef, visible]);
|
|
1887
1913
|
Object(react__WEBPACK_IMPORTED_MODULE_19__["useEffect"])(function () {
|
|
1888
1914
|
if (visible) {
|
|
1889
1915
|
var scrollAlign = lodash_debounce__WEBPACK_IMPORTED_MODULE_22___default()(function (e) {
|