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
|
@@ -60,14 +60,34 @@ const Dropdown = ({
|
|
|
60
60
|
}, [controlledOpen]);
|
|
61
61
|
|
|
62
62
|
useEffect(() => {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
63
|
+
const handleClickOutside = (e: MouseEvent) => {
|
|
64
|
+
if (
|
|
65
|
+
popupRef.current &&
|
|
66
|
+
!popupRef.current.contains(e.target as Node) &&
|
|
67
|
+
targetRef.current &&
|
|
68
|
+
!targetRef.current.contains(e.target as Node)
|
|
69
|
+
) {
|
|
70
|
+
setOpenInternal(false);
|
|
71
|
+
onVisibleChange?.(false);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
if (open) {
|
|
76
|
+
if (autoFocus) {
|
|
77
|
+
requestAnimationFrame(() => {
|
|
78
|
+
const first = menuRef.current?.querySelector(
|
|
79
|
+
"[role='menuitem']:not([aria-disabled='true'])"
|
|
80
|
+
) as HTMLElement | null;
|
|
81
|
+
|
|
82
|
+
first?.focus();
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
87
|
+
} else {
|
|
88
|
+
return () => {
|
|
89
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
90
|
+
};
|
|
71
91
|
}
|
|
72
92
|
}, [open]);
|
|
73
93
|
|
|
@@ -84,26 +104,6 @@ const Dropdown = ({
|
|
|
84
104
|
onVisibleChange?.(next)
|
|
85
105
|
};
|
|
86
106
|
|
|
87
|
-
useEffect(() => {
|
|
88
|
-
const handleClickOutside = (e: MouseEvent) => {
|
|
89
|
-
if (
|
|
90
|
-
popupRef.current &&
|
|
91
|
-
!popupRef.current.contains(e.target as Node) &&
|
|
92
|
-
targetRef.current &&
|
|
93
|
-
!targetRef.current.contains(e.target as Node)
|
|
94
|
-
) {
|
|
95
|
-
setOpenInternal(false);
|
|
96
|
-
onVisibleChange?.(false);
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
document.addEventListener('mousedown', handleClickOutside);
|
|
101
|
-
|
|
102
|
-
return () => {
|
|
103
|
-
document.removeEventListener('mousedown', handleClickOutside);
|
|
104
|
-
};
|
|
105
|
-
}, []);
|
|
106
|
-
|
|
107
107
|
const triggers = Array.isArray(trigger) ? trigger : [trigger];
|
|
108
108
|
|
|
109
109
|
const onTriggerClick = (e: SyntheticEvent) => {
|
|
@@ -208,7 +208,7 @@ function MenuInner({
|
|
|
208
208
|
aria-disabled={it.disabled ?? false}
|
|
209
209
|
onClick={(e) => {
|
|
210
210
|
console.log(1);
|
|
211
|
-
|
|
211
|
+
|
|
212
212
|
if (it.disabled) {
|
|
213
213
|
return;
|
|
214
214
|
}
|
package/package.json
CHANGED
package/src/app/page.tsx
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { Dropdown } from '../../lib/components/Dropdown';
|
|
4
4
|
|
|
5
5
|
export default function Home() {
|
|
6
6
|
return (
|
|
7
|
-
<
|
|
8
|
-
trigger={'
|
|
7
|
+
<Dropdown
|
|
8
|
+
trigger={['click']}
|
|
9
9
|
placement='bottomRight'
|
|
10
|
-
|
|
11
|
-
<div>Popover</div>
|
|
12
|
-
}
|
|
10
|
+
getPopupContainer={() => document.body}
|
|
13
11
|
>
|
|
14
12
|
Menu
|
|
15
|
-
</
|
|
13
|
+
</Dropdown>
|
|
16
14
|
)
|
|
17
15
|
}
|
|
18
16
|
|