cynx-ui 1.2.17 → 1.2.18
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/components/ActionsMenu.jsx +149 -149
- package/components/ActivityCard.jsx +184 -184
- package/components/Button.jsx +159 -159
- package/components/Card.jsx +62 -62
- package/components/CircularProgress.jsx +163 -163
- package/components/Dropdown.jsx +116 -116
- package/components/Dropzone.jsx +29 -29
- package/components/HoverCard.jsx +81 -81
- package/components/LineProgress.jsx +109 -109
- package/components/Modal.jsx +218 -218
- package/components/MultiSelect.jsx +167 -167
- package/components/Pagination.jsx +41 -41
- package/components/SearchableDropdown.jsx +118 -118
- package/components/Spinner.jsx +52 -52
- package/components/StatBarCard.jsx +25 -25
- package/components/StatsCard.jsx +171 -171
- package/components/TabBar.jsx +156 -156
- package/components/Tabs.jsx +16 -16
- package/components/Toast.jsx +88 -88
- package/components/Toggle.jsx +67 -67
- package/components/UptimeBar.jsx +200 -200
- package/components/XTable.jsx +28 -22
- package/index.js +94 -94
- package/package.json +1 -1
package/components/HoverCard.jsx
CHANGED
|
@@ -1,81 +1,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
|
-
* triggerStyle — extra trigger wrapper styles
|
|
13
|
-
*/
|
|
14
|
-
export default function HoverCard({ trigger, children, position = 'top', width = 180, style, triggerStyle }) {
|
|
15
|
-
const [open, setOpen] = useState(false);
|
|
16
|
-
const [pos, setPos] = useState({ x: 0, y: 0 });
|
|
17
|
-
const wrapRef = useRef(null);
|
|
18
|
-
|
|
19
|
-
useEffect(() => {
|
|
20
|
-
if (open && wrapRef.current) {
|
|
21
|
-
const r = wrapRef.current.getBoundingClientRect();
|
|
22
|
-
setPos({ x: r.left + r.width / 2, y: position === 'top' ? r.top : r.bottom });
|
|
23
|
-
}
|
|
24
|
-
}, [open, position]);
|
|
25
|
-
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
if (!open) return;
|
|
28
|
-
const close = (e) => {
|
|
29
|
-
if (wrapRef.current && !wrapRef.current.contains(e.target)) setOpen(false);
|
|
30
|
-
};
|
|
31
|
-
document.addEventListener('mousedown', close);
|
|
32
|
-
return () => document.removeEventListener('mousedown', close);
|
|
33
|
-
}, [open]);
|
|
34
|
-
|
|
35
|
-
return (
|
|
36
|
-
<div
|
|
37
|
-
ref={wrapRef}
|
|
38
|
-
onMouseEnter={() => setOpen(true)}
|
|
39
|
-
onMouseLeave={() => setOpen(false)}
|
|
40
|
-
style={{ display: 'inline-block', position: 'relative', ...triggerStyle }}
|
|
41
|
-
>
|
|
42
|
-
{trigger}
|
|
43
|
-
{open && (
|
|
44
|
-
<div style={{
|
|
45
|
-
position: 'fixed',
|
|
46
|
-
left: pos.x,
|
|
47
|
-
top: position === 'top' ? 'auto' : pos.y + 6,
|
|
48
|
-
bottom: position === 'top' ? window.innerHeight - pos.y + 6 : 'auto',
|
|
49
|
-
transform: 'translateX(-50%)',
|
|
50
|
-
zIndex: 9999,
|
|
51
|
-
minWidth: width,
|
|
52
|
-
background: '#fff',
|
|
53
|
-
border: '1px solid var(--border)',
|
|
54
|
-
borderRadius: 'var(--rads, 8px)',
|
|
55
|
-
padding: '10px 14px',
|
|
56
|
-
boxShadow: '0 4px 12px rgba(0,0,0,.12)',
|
|
57
|
-
pointerEvents: 'none',
|
|
58
|
-
animation: 'hoverCardIn .15s ease',
|
|
59
|
-
...style,
|
|
60
|
-
}}>
|
|
61
|
-
{children}
|
|
62
|
-
<div style={{
|
|
63
|
-
position: 'absolute', left: '50%',
|
|
64
|
-
[position === 'top' ? 'bottom' : 'top']: -5,
|
|
65
|
-
transform: 'translateX(-50%) rotate(45deg)',
|
|
66
|
-
width: 8, height: 8, background: '#fff',
|
|
67
|
-
borderRight: '1px solid var(--border)',
|
|
68
|
-
borderBottom: position === 'top' ? 'none' : '1px solid var(--border)',
|
|
69
|
-
borderTop: position === 'top' ? '1px solid var(--border)' : 'none',
|
|
70
|
-
}} />
|
|
71
|
-
</div>
|
|
72
|
-
)}
|
|
73
|
-
<style>{`
|
|
74
|
-
@keyframes hoverCardIn {
|
|
75
|
-
from { opacity: 0; transform: translateX(-50%) translateY(4px); }
|
|
76
|
-
to { opacity: 1; transform: translateX(-50%) translateY(0); }
|
|
77
|
-
}
|
|
78
|
-
`}</style>
|
|
79
|
-
</div>
|
|
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
|
+
* triggerStyle — extra trigger wrapper styles
|
|
13
|
+
*/
|
|
14
|
+
export default function HoverCard({ trigger, children, position = 'top', width = 180, style, triggerStyle }) {
|
|
15
|
+
const [open, setOpen] = useState(false);
|
|
16
|
+
const [pos, setPos] = useState({ x: 0, y: 0 });
|
|
17
|
+
const wrapRef = useRef(null);
|
|
18
|
+
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (open && wrapRef.current) {
|
|
21
|
+
const r = wrapRef.current.getBoundingClientRect();
|
|
22
|
+
setPos({ x: r.left + r.width / 2, y: position === 'top' ? r.top : r.bottom });
|
|
23
|
+
}
|
|
24
|
+
}, [open, position]);
|
|
25
|
+
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (!open) return;
|
|
28
|
+
const close = (e) => {
|
|
29
|
+
if (wrapRef.current && !wrapRef.current.contains(e.target)) setOpen(false);
|
|
30
|
+
};
|
|
31
|
+
document.addEventListener('mousedown', close);
|
|
32
|
+
return () => document.removeEventListener('mousedown', close);
|
|
33
|
+
}, [open]);
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<div
|
|
37
|
+
ref={wrapRef}
|
|
38
|
+
onMouseEnter={() => setOpen(true)}
|
|
39
|
+
onMouseLeave={() => setOpen(false)}
|
|
40
|
+
style={{ display: 'inline-block', position: 'relative', ...triggerStyle }}
|
|
41
|
+
>
|
|
42
|
+
{trigger}
|
|
43
|
+
{open && (
|
|
44
|
+
<div style={{
|
|
45
|
+
position: 'fixed',
|
|
46
|
+
left: pos.x,
|
|
47
|
+
top: position === 'top' ? 'auto' : pos.y + 6,
|
|
48
|
+
bottom: position === 'top' ? window.innerHeight - pos.y + 6 : 'auto',
|
|
49
|
+
transform: 'translateX(-50%)',
|
|
50
|
+
zIndex: 9999,
|
|
51
|
+
minWidth: width,
|
|
52
|
+
background: '#fff',
|
|
53
|
+
border: '1px solid var(--border)',
|
|
54
|
+
borderRadius: 'var(--rads, 8px)',
|
|
55
|
+
padding: '10px 14px',
|
|
56
|
+
boxShadow: '0 4px 12px rgba(0,0,0,.12)',
|
|
57
|
+
pointerEvents: 'none',
|
|
58
|
+
animation: 'hoverCardIn .15s ease',
|
|
59
|
+
...style,
|
|
60
|
+
}}>
|
|
61
|
+
{children}
|
|
62
|
+
<div style={{
|
|
63
|
+
position: 'absolute', left: '50%',
|
|
64
|
+
[position === 'top' ? 'bottom' : 'top']: -5,
|
|
65
|
+
transform: 'translateX(-50%) rotate(45deg)',
|
|
66
|
+
width: 8, height: 8, background: '#fff',
|
|
67
|
+
borderRight: '1px solid var(--border)',
|
|
68
|
+
borderBottom: position === 'top' ? 'none' : '1px solid var(--border)',
|
|
69
|
+
borderTop: position === 'top' ? '1px solid var(--border)' : 'none',
|
|
70
|
+
}} />
|
|
71
|
+
</div>
|
|
72
|
+
)}
|
|
73
|
+
<style>{`
|
|
74
|
+
@keyframes hoverCardIn {
|
|
75
|
+
from { opacity: 0; transform: translateX(-50%) translateY(4px); }
|
|
76
|
+
to { opacity: 1; transform: translateX(-50%) translateY(0); }
|
|
77
|
+
}
|
|
78
|
+
`}</style>
|
|
79
|
+
</div>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
@@ -1,109 +1,109 @@
|
|
|
1
|
-
import { useEffect, useRef } from 'react';
|
|
2
|
-
|
|
3
|
-
const SIZES = {
|
|
4
|
-
xs: { height: 4, fontSize: '.68rem' },
|
|
5
|
-
sm: { height: 5, fontSize: '.75rem' },
|
|
6
|
-
md: { height: 6, fontSize: '.82rem' },
|
|
7
|
-
lg: { height: 8, fontSize: '.9rem' },
|
|
8
|
-
xl: { height: 10, fontSize: '1rem' },
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export default function LineProgress({
|
|
12
|
-
value = 0,
|
|
13
|
-
size = 'md',
|
|
14
|
-
customSize,
|
|
15
|
-
color = 'var(--blue)',
|
|
16
|
-
trackColor = '#e0e0e4',
|
|
17
|
-
label = '',
|
|
18
|
-
showPercent = true,
|
|
19
|
-
animated = true,
|
|
20
|
-
rounded = true,
|
|
21
|
-
indeterminate = false,
|
|
22
|
-
speed = 1,
|
|
23
|
-
height,
|
|
24
|
-
gap = 5,
|
|
25
|
-
labelGap = 2,
|
|
26
|
-
className = '',
|
|
27
|
-
style = {},
|
|
28
|
-
}) {
|
|
29
|
-
const base = SIZES[size] || SIZES.md;
|
|
30
|
-
const barHeight = height ?? (customSize || base.height);
|
|
31
|
-
const fontSize = customSize ? `${Math.max(11, customSize * 1.6)}px` : base.fontSize;
|
|
32
|
-
const pct = Math.min(100, Math.max(0, value));
|
|
33
|
-
const radius = rounded ? barHeight / 2 : 0;
|
|
34
|
-
|
|
35
|
-
const barRef = useRef(null);
|
|
36
|
-
|
|
37
|
-
// Indeterminate animation
|
|
38
|
-
useEffect(() => {
|
|
39
|
-
if (!indeterminate || !barRef.current) return;
|
|
40
|
-
let pos = -40, direction = 1, raf;
|
|
41
|
-
let lastTime = performance.now();
|
|
42
|
-
|
|
43
|
-
function tick(now) {
|
|
44
|
-
const dt = (now - lastTime) / 16.67;
|
|
45
|
-
lastTime = now;
|
|
46
|
-
pos += direction * 1.2 * speed * dt;
|
|
47
|
-
if (pos > 100) { pos = 100; direction = -1; }
|
|
48
|
-
if (pos < -40) { pos = -40; direction = 1; }
|
|
49
|
-
if (barRef.current) {
|
|
50
|
-
barRef.current.style.left = pos + '%';
|
|
51
|
-
barRef.current.style.width = '40%';
|
|
52
|
-
}
|
|
53
|
-
raf = requestAnimationFrame(tick);
|
|
54
|
-
}
|
|
55
|
-
raf = requestAnimationFrame(tick);
|
|
56
|
-
return () => cancelAnimationFrame(raf);
|
|
57
|
-
}, [indeterminate, speed]);
|
|
58
|
-
|
|
59
|
-
const transitionStyle = animated ? 'flex .5s cubic-bezier(0.4,0,0.2,1)' : 'none';
|
|
60
|
-
|
|
61
|
-
return (
|
|
62
|
-
<div className={className} style={{ display: 'inline-flex', flexDirection: 'column', gap: labelGap, width: '100%', ...style }}>
|
|
63
|
-
{(label || showPercent) && (
|
|
64
|
-
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'baseline' }}>
|
|
65
|
-
{label && <span style={{ fontSize, fontWeight: 600, color: 'var(--primary-text, #1a1a2e)' }}>{label}</span>}
|
|
66
|
-
{showPercent && !indeterminate && (
|
|
67
|
-
<span style={{ fontSize, fontWeight: 600, color: 'var(--muted, #9ca3af)', fontVariantNumeric: 'tabular-nums', marginLeft: label ? 0 : 'auto' }}>
|
|
68
|
-
{Math.round(pct)}%
|
|
69
|
-
</span>
|
|
70
|
-
)}
|
|
71
|
-
</div>
|
|
72
|
-
)}
|
|
73
|
-
<div style={{
|
|
74
|
-
height: barHeight, borderRadius: radius,
|
|
75
|
-
background: 'transparent', position: 'relative',
|
|
76
|
-
display: 'flex', gap: gap, overflow: 'hidden',
|
|
77
|
-
}}>
|
|
78
|
-
{indeterminate ? (
|
|
79
|
-
<>
|
|
80
|
-
<div style={{ flex: 1, borderRadius: radius, background: trackColor }} />
|
|
81
|
-
<div
|
|
82
|
-
ref={barRef}
|
|
83
|
-
style={{
|
|
84
|
-
position: 'absolute', top: 0, height: '100%',
|
|
85
|
-
width: '40%', borderRadius: radius,
|
|
86
|
-
background: color, opacity: 0.85,
|
|
87
|
-
}}
|
|
88
|
-
/>
|
|
89
|
-
</>
|
|
90
|
-
) : (
|
|
91
|
-
<>
|
|
92
|
-
<div ref={barRef} style={{
|
|
93
|
-
flex: pct > 0 ? pct : 0, minWidth: pct > 0 ? barHeight : 0,
|
|
94
|
-
borderRadius: radius, background: color,
|
|
95
|
-
transition: transitionStyle,
|
|
96
|
-
}} />
|
|
97
|
-
{pct < 100 && (
|
|
98
|
-
<div style={{
|
|
99
|
-
flex: 100 - pct,
|
|
100
|
-
borderRadius: radius, background: trackColor,
|
|
101
|
-
transition: transitionStyle,
|
|
102
|
-
}} />
|
|
103
|
-
)}
|
|
104
|
-
</>
|
|
105
|
-
)}
|
|
106
|
-
</div>
|
|
107
|
-
</div>
|
|
108
|
-
);
|
|
109
|
-
}
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
const SIZES = {
|
|
4
|
+
xs: { height: 4, fontSize: '.68rem' },
|
|
5
|
+
sm: { height: 5, fontSize: '.75rem' },
|
|
6
|
+
md: { height: 6, fontSize: '.82rem' },
|
|
7
|
+
lg: { height: 8, fontSize: '.9rem' },
|
|
8
|
+
xl: { height: 10, fontSize: '1rem' },
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default function LineProgress({
|
|
12
|
+
value = 0,
|
|
13
|
+
size = 'md',
|
|
14
|
+
customSize,
|
|
15
|
+
color = 'var(--blue)',
|
|
16
|
+
trackColor = '#e0e0e4',
|
|
17
|
+
label = '',
|
|
18
|
+
showPercent = true,
|
|
19
|
+
animated = true,
|
|
20
|
+
rounded = true,
|
|
21
|
+
indeterminate = false,
|
|
22
|
+
speed = 1,
|
|
23
|
+
height,
|
|
24
|
+
gap = 5,
|
|
25
|
+
labelGap = 2,
|
|
26
|
+
className = '',
|
|
27
|
+
style = {},
|
|
28
|
+
}) {
|
|
29
|
+
const base = SIZES[size] || SIZES.md;
|
|
30
|
+
const barHeight = height ?? (customSize || base.height);
|
|
31
|
+
const fontSize = customSize ? `${Math.max(11, customSize * 1.6)}px` : base.fontSize;
|
|
32
|
+
const pct = Math.min(100, Math.max(0, value));
|
|
33
|
+
const radius = rounded ? barHeight / 2 : 0;
|
|
34
|
+
|
|
35
|
+
const barRef = useRef(null);
|
|
36
|
+
|
|
37
|
+
// Indeterminate animation
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (!indeterminate || !barRef.current) return;
|
|
40
|
+
let pos = -40, direction = 1, raf;
|
|
41
|
+
let lastTime = performance.now();
|
|
42
|
+
|
|
43
|
+
function tick(now) {
|
|
44
|
+
const dt = (now - lastTime) / 16.67;
|
|
45
|
+
lastTime = now;
|
|
46
|
+
pos += direction * 1.2 * speed * dt;
|
|
47
|
+
if (pos > 100) { pos = 100; direction = -1; }
|
|
48
|
+
if (pos < -40) { pos = -40; direction = 1; }
|
|
49
|
+
if (barRef.current) {
|
|
50
|
+
barRef.current.style.left = pos + '%';
|
|
51
|
+
barRef.current.style.width = '40%';
|
|
52
|
+
}
|
|
53
|
+
raf = requestAnimationFrame(tick);
|
|
54
|
+
}
|
|
55
|
+
raf = requestAnimationFrame(tick);
|
|
56
|
+
return () => cancelAnimationFrame(raf);
|
|
57
|
+
}, [indeterminate, speed]);
|
|
58
|
+
|
|
59
|
+
const transitionStyle = animated ? 'flex .5s cubic-bezier(0.4,0,0.2,1)' : 'none';
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<div className={className} style={{ display: 'inline-flex', flexDirection: 'column', gap: labelGap, width: '100%', ...style }}>
|
|
63
|
+
{(label || showPercent) && (
|
|
64
|
+
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'baseline' }}>
|
|
65
|
+
{label && <span style={{ fontSize, fontWeight: 600, color: 'var(--primary-text, #1a1a2e)' }}>{label}</span>}
|
|
66
|
+
{showPercent && !indeterminate && (
|
|
67
|
+
<span style={{ fontSize, fontWeight: 600, color: 'var(--muted, #9ca3af)', fontVariantNumeric: 'tabular-nums', marginLeft: label ? 0 : 'auto' }}>
|
|
68
|
+
{Math.round(pct)}%
|
|
69
|
+
</span>
|
|
70
|
+
)}
|
|
71
|
+
</div>
|
|
72
|
+
)}
|
|
73
|
+
<div style={{
|
|
74
|
+
height: barHeight, borderRadius: radius,
|
|
75
|
+
background: 'transparent', position: 'relative',
|
|
76
|
+
display: 'flex', gap: gap, overflow: 'hidden',
|
|
77
|
+
}}>
|
|
78
|
+
{indeterminate ? (
|
|
79
|
+
<>
|
|
80
|
+
<div style={{ flex: 1, borderRadius: radius, background: trackColor }} />
|
|
81
|
+
<div
|
|
82
|
+
ref={barRef}
|
|
83
|
+
style={{
|
|
84
|
+
position: 'absolute', top: 0, height: '100%',
|
|
85
|
+
width: '40%', borderRadius: radius,
|
|
86
|
+
background: color, opacity: 0.85,
|
|
87
|
+
}}
|
|
88
|
+
/>
|
|
89
|
+
</>
|
|
90
|
+
) : (
|
|
91
|
+
<>
|
|
92
|
+
<div ref={barRef} style={{
|
|
93
|
+
flex: pct > 0 ? pct : 0, minWidth: pct > 0 ? barHeight : 0,
|
|
94
|
+
borderRadius: radius, background: color,
|
|
95
|
+
transition: transitionStyle,
|
|
96
|
+
}} />
|
|
97
|
+
{pct < 100 && (
|
|
98
|
+
<div style={{
|
|
99
|
+
flex: 100 - pct,
|
|
100
|
+
borderRadius: radius, background: trackColor,
|
|
101
|
+
transition: transitionStyle,
|
|
102
|
+
}} />
|
|
103
|
+
)}
|
|
104
|
+
</>
|
|
105
|
+
)}
|
|
106
|
+
</div>
|
|
107
|
+
</div>
|
|
108
|
+
);
|
|
109
|
+
}
|