x-ui-design 0.9.80 → 0.9.81
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 +18 -17
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +18 -17
- package/dist/index.js.map +1 -1
- package/lib/components/Dropdown/Dropdown.tsx +29 -29
- package/package.json +1 -1
- package/src/app/page.tsx +5 -7
package/dist/index.js
CHANGED
|
@@ -5551,11 +5551,24 @@ const Dropdown = ({
|
|
|
5551
5551
|
}
|
|
5552
5552
|
}, [controlledOpen]);
|
|
5553
5553
|
React.useEffect(() => {
|
|
5554
|
-
|
|
5555
|
-
|
|
5556
|
-
|
|
5557
|
-
|
|
5558
|
-
}
|
|
5554
|
+
const handleClickOutside = e => {
|
|
5555
|
+
if (popupRef.current && !popupRef.current.contains(e.target) && targetRef.current && !targetRef.current.contains(e.target)) {
|
|
5556
|
+
setOpenInternal(false);
|
|
5557
|
+
onVisibleChange?.(false);
|
|
5558
|
+
}
|
|
5559
|
+
};
|
|
5560
|
+
if (open) {
|
|
5561
|
+
if (autoFocus) {
|
|
5562
|
+
requestAnimationFrame(() => {
|
|
5563
|
+
const first = menuRef.current?.querySelector("[role='menuitem']:not([aria-disabled='true'])");
|
|
5564
|
+
first?.focus();
|
|
5565
|
+
});
|
|
5566
|
+
}
|
|
5567
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
5568
|
+
} else {
|
|
5569
|
+
return () => {
|
|
5570
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
5571
|
+
};
|
|
5559
5572
|
}
|
|
5560
5573
|
}, [open]);
|
|
5561
5574
|
const setOpenInternal = next => {
|
|
@@ -5568,18 +5581,6 @@ const Dropdown = ({
|
|
|
5568
5581
|
onVisibleChange?.(next);
|
|
5569
5582
|
onVisibleChange?.(next);
|
|
5570
5583
|
};
|
|
5571
|
-
React.useEffect(() => {
|
|
5572
|
-
const handleClickOutside = e => {
|
|
5573
|
-
if (popupRef.current && !popupRef.current.contains(e.target) && targetRef.current && !targetRef.current.contains(e.target)) {
|
|
5574
|
-
setOpenInternal(false);
|
|
5575
|
-
onVisibleChange?.(false);
|
|
5576
|
-
}
|
|
5577
|
-
};
|
|
5578
|
-
document.addEventListener('mousedown', handleClickOutside);
|
|
5579
|
-
return () => {
|
|
5580
|
-
document.removeEventListener('mousedown', handleClickOutside);
|
|
5581
|
-
};
|
|
5582
|
-
}, []);
|
|
5583
5584
|
const triggers = Array.isArray(trigger) ? trigger : [trigger];
|
|
5584
5585
|
const onTriggerClick = e => {
|
|
5585
5586
|
e.preventDefault();
|