cynx-lib 1.3.88 → 1.3.90
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/package.json +1 -1
- package/ui/components/ActionsMenu.jsx +16 -5
- package/ui/components/HoverCard.jsx +85 -81
package/package.json
CHANGED
|
@@ -39,8 +39,14 @@ export function ActionsMenu({ items, align = 'right' }) {
|
|
|
39
39
|
|
|
40
40
|
menu.style.top = top + 'px';
|
|
41
41
|
menu.style.left = left + 'px';
|
|
42
|
+
menu.style.transformOrigin = openUp
|
|
43
|
+
? (align === 'left' ? 'bottom left' : 'bottom right')
|
|
44
|
+
: (align === 'left' ? 'top left' : 'top right');
|
|
42
45
|
menu.classList.toggle('open-up', openUp);
|
|
43
|
-
|
|
46
|
+
if (!closing) {
|
|
47
|
+
menu.style.animationName = openUp ? 'actionsDropUp' : 'actionsDrop';
|
|
48
|
+
}
|
|
49
|
+
}, [align, closing]);
|
|
44
50
|
|
|
45
51
|
useEffect(() => {
|
|
46
52
|
if (!open) return;
|
|
@@ -104,6 +110,7 @@ export function ActionsMenu({ items, align = 'right' }) {
|
|
|
104
110
|
background: 'var(--surface,#fff)', border: '1.5px solid var(--border-light,#e2e8f0)',
|
|
105
111
|
borderRadius: 'var(--rads,8px)',
|
|
106
112
|
boxShadow: 'var(--shadow-lg, 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.06))',
|
|
113
|
+
transformOrigin: align === 'left' ? 'top left' : 'top right',
|
|
107
114
|
animation: closing
|
|
108
115
|
? 'actionsClose .14s ease forwards'
|
|
109
116
|
: 'actionsDrop .14s cubic-bezier(.16,1,.3,1)',
|
|
@@ -145,12 +152,16 @@ export function ActionsMenu({ items, align = 'right' }) {
|
|
|
145
152
|
|
|
146
153
|
<style>{`
|
|
147
154
|
@keyframes actionsDrop {
|
|
148
|
-
from { opacity: 0; transform: translateY(-6px)
|
|
149
|
-
to { opacity: 1; transform: translateY(0)
|
|
155
|
+
from { opacity: 0; transform: translateY(-6px); }
|
|
156
|
+
to { opacity: 1; transform: translateY(0); }
|
|
157
|
+
}
|
|
158
|
+
@keyframes actionsDropUp {
|
|
159
|
+
from { opacity: 0; transform: translateY(6px); }
|
|
160
|
+
to { opacity: 1; transform: translateY(0); }
|
|
150
161
|
}
|
|
151
162
|
@keyframes actionsClose {
|
|
152
|
-
from { opacity: 1; transform: translateY(0)
|
|
153
|
-
to { opacity: 0; transform: translateY(-4px)
|
|
163
|
+
from { opacity: 1; transform: translateY(0); }
|
|
164
|
+
to { opacity: 0; transform: translateY(-4px); }
|
|
154
165
|
}
|
|
155
166
|
`}</style>
|
|
156
167
|
</div>
|
|
@@ -1,81 +1,85 @@
|
|
|
1
|
-
import { useState, useRef, useEffect } from 'react';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* HoverCard — reusable tooltip/popover on hover
|
|
5
|
-
*
|
|
6
|
-
* Props:
|
|
7
|
-
* trigger — React node as hover target
|
|
8
|
-
* children — popup content
|
|
9
|
-
* position — 'top' | 'bottom' (default: 'top')
|
|
10
|
-
* width — min-width (default: 180)
|
|
11
|
-
* style — extra popup styles
|
|
12
|
-
*
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
{
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
1
|
+
import { useState, useRef, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* HoverCard — reusable tooltip/popover on hover
|
|
5
|
+
*
|
|
6
|
+
* Props:
|
|
7
|
+
* trigger — React node as hover target
|
|
8
|
+
* children — popup content
|
|
9
|
+
* position — 'top' | 'bottom' (default: 'top')
|
|
10
|
+
* width — min-width (default: 180)
|
|
11
|
+
* style — extra popup styles
|
|
12
|
+
* arrow — show arrow indicator (default: false)
|
|
13
|
+
* style — extra popup styles
|
|
14
|
+
* triggerStyle — extra trigger wrapper styles
|
|
15
|
+
*/
|
|
16
|
+
export default function HoverCard({ trigger, children, position = 'top', width = 180, arrow = false, style, triggerStyle }) {
|
|
17
|
+
const [open, setOpen] = useState(false);
|
|
18
|
+
const [pos, setPos] = useState({ x: 0, y: 0 });
|
|
19
|
+
const wrapRef = useRef(null);
|
|
20
|
+
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (open && wrapRef.current) {
|
|
23
|
+
const r = wrapRef.current.getBoundingClientRect();
|
|
24
|
+
setPos({ x: r.left + r.width / 2, y: position === 'top' ? r.top : r.bottom });
|
|
25
|
+
}
|
|
26
|
+
}, [open, position]);
|
|
27
|
+
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (!open) return;
|
|
30
|
+
const close = (e) => {
|
|
31
|
+
if (wrapRef.current && !wrapRef.current.contains(e.target)) setOpen(false);
|
|
32
|
+
};
|
|
33
|
+
document.addEventListener('mousedown', close);
|
|
34
|
+
return () => document.removeEventListener('mousedown', close);
|
|
35
|
+
}, [open]);
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<div
|
|
39
|
+
ref={wrapRef}
|
|
40
|
+
onMouseEnter={() => setOpen(true)}
|
|
41
|
+
onMouseLeave={() => setOpen(false)}
|
|
42
|
+
style={{ display: 'inline-block', position: 'relative', ...triggerStyle }}
|
|
43
|
+
>
|
|
44
|
+
{trigger}
|
|
45
|
+
{open && (
|
|
46
|
+
<div style={{
|
|
47
|
+
position: 'fixed',
|
|
48
|
+
left: pos.x,
|
|
49
|
+
top: position === 'top' ? 'auto' : pos.y + 6,
|
|
50
|
+
bottom: position === 'top' ? window.innerHeight - pos.y + 6 : 'auto',
|
|
51
|
+
transform: 'translateX(-50%)',
|
|
52
|
+
zIndex: 9999,
|
|
53
|
+
minWidth: width,
|
|
54
|
+
background: 'var(--surface,#fff)',
|
|
55
|
+
border: '1px solid var(--border, #e2e8f0)',
|
|
56
|
+
borderRadius: 'var(--rads, 8px)',
|
|
57
|
+
padding: '10px 14px',
|
|
58
|
+
boxShadow: 'var(--smd, 0 4px 12px rgba(0,0,0,.12))',
|
|
59
|
+
pointerEvents: 'none',
|
|
60
|
+
animation: 'hoverCardIn .15s ease',
|
|
61
|
+
...style,
|
|
62
|
+
}}>
|
|
63
|
+
{children}
|
|
64
|
+
{arrow && (
|
|
65
|
+
<div style={{
|
|
66
|
+
position: 'absolute', left: '50%',
|
|
67
|
+
[position === 'top' ? 'bottom' : 'top']: -5,
|
|
68
|
+
transform: 'translateX(-50%) rotate(45deg)',
|
|
69
|
+
width: 8, height: 8, background: 'var(--surface,#fff)',
|
|
70
|
+
borderRight: '1px solid var(--border, #e2e8f0)',
|
|
71
|
+
borderBottom: position === 'top' ? 'none' : '1px solid var(--border, #e2e8f0)',
|
|
72
|
+
borderTop: position === 'top' ? '1px solid var(--border, #e2e8f0)' : 'none',
|
|
73
|
+
}} />
|
|
74
|
+
)}
|
|
75
|
+
</div>
|
|
76
|
+
)}
|
|
77
|
+
<style>{`
|
|
78
|
+
@keyframes hoverCardIn {
|
|
79
|
+
from { opacity: 0; transform: translateX(-50%) translateY(4px); }
|
|
80
|
+
to { opacity: 1; transform: translateX(-50%) translateY(0); }
|
|
81
|
+
}
|
|
82
|
+
`}</style>
|
|
83
|
+
</div>
|
|
84
|
+
);
|
|
85
|
+
}
|