x-ui-design 0.8.16 → 0.8.17
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/index.esm.js +42 -22
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +41 -21
- package/dist/index.js.map +1 -1
- package/lib/components/Popover/Popover.tsx +48 -16
- package/lib/components/Popover/style.css +2 -7
- package/package.json +1 -1
- package/src/app/page.tsx +15 -10
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import require$$1 from 'react/jsx-runtime';
|
|
2
|
-
import React, { useRef, useState, Children, isValidElement, Fragment, Suspense, useEffect, useContext, useMemo, useCallback, createContext, useImperativeHandle, useLayoutEffect } from 'react';
|
|
2
|
+
import React, { useRef, useState, Children, isValidElement, Fragment, Suspense, useEffect, useContext, useMemo, useCallback, createContext, useImperativeHandle, useLayoutEffect, cloneElement } from 'react';
|
|
3
3
|
import { createPortal } from 'react-dom';
|
|
4
4
|
import ReactDOMServer from 'react-dom/server';
|
|
5
5
|
|
|
@@ -5497,7 +5497,7 @@ var Dropdown$1 = /*#__PURE__*/Object.freeze({
|
|
|
5497
5497
|
default: Dropdown
|
|
5498
5498
|
});
|
|
5499
5499
|
|
|
5500
|
-
var css_248z$1 = ".xUi-popover{&:before{content:\"\";height:
|
|
5500
|
+
var css_248z$1 = ".xUi-popover{&:before{content:\"\";height:10px;left:0;position:absolute;top:-10px;width:100%;z-index:10000}}.xUi-popover-wrapper-content{cursor:pointer}.xUi-popover{background:var(--xui-background-color);border-radius:6px;box-shadow:0 4px 12px rgba(0,0,0,.15);padding:8px 12px;width:max-content;z-index:1000}.xUi-popover-title{padding:4px}.xUi-popover-inner{color:var(--xui-text-color);font-size:14px}.xUi-popover-arrow{background:var(--xui-background-color);border-left:.5px solid var(--xui-border-color);border-top:.5px solid var(--xui-border-color);height:10px;left:12px;position:absolute;top:-6px;transform:rotate(45deg);width:10px}.xUi-popover-arrow.bottom{border-bottom:.5px solid var(--xui-border-color);border-left:unset;border-right:.5px solid var(--xui-border-color);border-top:unset;bottom:-6px;top:unset}";
|
|
5501
5501
|
styleInject(css_248z$1);
|
|
5502
5502
|
|
|
5503
5503
|
const Popover = ({
|
|
@@ -5530,41 +5530,61 @@ const Popover = ({
|
|
|
5530
5530
|
triggerRef,
|
|
5531
5531
|
getPopupContainer: getPopupContainer?.(triggerRef.current)
|
|
5532
5532
|
});
|
|
5533
|
-
|
|
5533
|
+
useEffect(() => {
|
|
5534
|
+
const handleClickOutside = e => {
|
|
5535
|
+
if (popupRef.current && !popupRef.current.contains(e.target) && triggerRef.current && !triggerRef.current.contains(e.target)) {
|
|
5536
|
+
setInnerOpen(false);
|
|
5537
|
+
onVisibleChange?.(false);
|
|
5538
|
+
}
|
|
5539
|
+
};
|
|
5540
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
5541
|
+
return () => {
|
|
5542
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
5543
|
+
};
|
|
5544
|
+
}, []);
|
|
5545
|
+
const handleOnClick = useCallback(() => {
|
|
5534
5546
|
const newState = !isOpen;
|
|
5535
5547
|
onVisibleChange?.(newState);
|
|
5536
5548
|
setInnerOpen(newState);
|
|
5537
|
-
};
|
|
5538
|
-
const
|
|
5549
|
+
}, [isOpen, trigger]);
|
|
5550
|
+
const handleOnMouseEnter = useCallback(() => {
|
|
5539
5551
|
setHover(true);
|
|
5540
5552
|
if (trigger === "hover") {
|
|
5541
5553
|
onVisibleChange?.(true);
|
|
5542
5554
|
setInnerOpen(true);
|
|
5543
5555
|
}
|
|
5544
|
-
};
|
|
5545
|
-
const
|
|
5556
|
+
}, [trigger]);
|
|
5557
|
+
const handleOnMouseLeave = useCallback(() => {
|
|
5546
5558
|
setHover(false);
|
|
5547
5559
|
if (trigger === "hover") {
|
|
5548
5560
|
onVisibleChange?.(false);
|
|
5549
5561
|
setInnerOpen(false);
|
|
5550
5562
|
}
|
|
5551
|
-
};
|
|
5552
|
-
const childProps = trigger === "click" ? {
|
|
5553
|
-
onClick:
|
|
5563
|
+
}, [trigger]);
|
|
5564
|
+
const childProps = useMemo(() => trigger === "click" ? {
|
|
5565
|
+
onClick: handleOnClick
|
|
5554
5566
|
} : {
|
|
5555
|
-
onMouseEnter:
|
|
5556
|
-
onMouseLeave:
|
|
5557
|
-
};
|
|
5558
|
-
return /*#__PURE__*/React.createElement(
|
|
5559
|
-
|
|
5560
|
-
|
|
5561
|
-
|
|
5562
|
-
|
|
5563
|
-
|
|
5567
|
+
onMouseEnter: handleOnMouseEnter,
|
|
5568
|
+
onMouseLeave: handleOnMouseLeave
|
|
5569
|
+
}, [trigger]);
|
|
5570
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, Children.map(children, (child, index) => {
|
|
5571
|
+
if (! /*#__PURE__*/isValidElement(child)) {
|
|
5572
|
+
child = /*#__PURE__*/React.createElement("div", null, child);
|
|
5573
|
+
}
|
|
5574
|
+
return /*#__PURE__*/cloneElement(child, {
|
|
5575
|
+
key: index,
|
|
5576
|
+
...childProps,
|
|
5577
|
+
...(index === 0 ? {
|
|
5578
|
+
ref: triggerRef,
|
|
5579
|
+
className: `${prefixCls}-wrapper-content`
|
|
5580
|
+
} : {})
|
|
5581
|
+
});
|
|
5582
|
+
}), isOpen && /*#__PURE__*/React.createElement(ConditionalWrapper, {
|
|
5564
5583
|
condition: !!getPopupContainer,
|
|
5565
5584
|
wrapper: element => getPopupContainer ? /*#__PURE__*/createPortal(element, getPopupContainer(popupRef.current)) : /*#__PURE__*/React.createElement(React.Fragment, null, element)
|
|
5566
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
5567
|
-
ref: popupRef
|
|
5585
|
+
}, /*#__PURE__*/React.createElement("div", _extends({
|
|
5586
|
+
ref: popupRef
|
|
5587
|
+
}, childProps, {
|
|
5568
5588
|
className: clsx(prefixCls, `${prefixCls}-${placement}`, overlayClassName),
|
|
5569
5589
|
style: {
|
|
5570
5590
|
zIndex: hover ? 1000 : 1,
|
|
@@ -5572,7 +5592,7 @@ const Popover = ({
|
|
|
5572
5592
|
...overlayStyle,
|
|
5573
5593
|
...dropdownPosition
|
|
5574
5594
|
}
|
|
5575
|
-
}, title && /*#__PURE__*/React.createElement("div", {
|
|
5595
|
+
}), title && /*#__PURE__*/React.createElement("div", {
|
|
5576
5596
|
className: `${prefixCls}-title`
|
|
5577
5597
|
}, title), /*#__PURE__*/React.createElement("div", {
|
|
5578
5598
|
className: `${prefixCls}-inner`
|