cynx-ui 1.2.5 → 1.2.7
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/Badge.jsx +129 -105
- package/components/Button.jsx +126 -43
- package/components/Card.jsx +62 -62
- package/components/CircularProgress.jsx +163 -163
- package/components/Dropzone.jsx +29 -29
- package/components/HoverCard.jsx +81 -81
- package/components/Input.jsx +181 -121
- package/components/LineProgress.jsx +109 -109
- package/components/Modal.jsx +124 -8
- package/components/Pagination.jsx +41 -41
- package/components/PulseDot.jsx +76 -58
- package/components/Select.jsx +175 -91
- package/components/Skeleton.jsx +31 -47
- package/components/Spinner.jsx +36 -36
- package/components/StatBarCard.jsx +25 -25
- package/components/StatsCard.jsx +114 -40
- package/components/Tabs.jsx +16 -16
- package/components/Toast.jsx +57 -57
- package/components/Toggle.jsx +56 -58
- package/components/UptimeBar.jsx +200 -200
- package/components/XTable.jsx +22 -22
- package/index.js +94 -94
- package/package.json +18 -18
package/components/StatsCard.jsx
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import CircularProgress from './CircularProgress';
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
.scard-simple .scard-head{width:100%;margin-bottom:8px;display:flex;align-items:center;justify-content:space-between}
|
|
17
|
-
.scard-simple .scard-icon-simple{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0}
|
|
18
|
-
.scard-simple .scard-icon-simple svg{width:14px;height:14px}
|
|
19
|
-
.scard-simple .scard-value{font-size:1.25rem;font-weight:800;letter-spacing:-.03em;line-height:1.1;min-height:1.375em}
|
|
20
|
-
`;
|
|
3
|
+
const BASE = {
|
|
4
|
+
display: 'flex',
|
|
5
|
+
alignItems: 'center',
|
|
6
|
+
justifyContent: 'space-between',
|
|
7
|
+
padding: '10px 14px',
|
|
8
|
+
minHeight: 68,
|
|
9
|
+
borderRadius: 'var(--rad,10px)',
|
|
10
|
+
background: 'var(--surface,#fff)',
|
|
11
|
+
border: '1px solid var(--border)',
|
|
12
|
+
boxShadow: '0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04)',
|
|
13
|
+
minWidth: 0,
|
|
14
|
+
transition: 'border-color .15s',
|
|
15
|
+
};
|
|
21
16
|
|
|
22
|
-
|
|
17
|
+
const SIMPLE_BASE = {
|
|
18
|
+
...BASE,
|
|
19
|
+
padding: '12px 14px',
|
|
20
|
+
flexDirection: 'column',
|
|
21
|
+
alignItems: 'flex-start',
|
|
22
|
+
justifyContent: 'flex-start',
|
|
23
|
+
};
|
|
23
24
|
|
|
24
25
|
export default function StatsCard({
|
|
25
26
|
variant = 'default',
|
|
@@ -38,49 +39,122 @@ export default function StatsCard({
|
|
|
38
39
|
style = {},
|
|
39
40
|
children,
|
|
40
41
|
}) {
|
|
41
|
-
if (!styleInjected && typeof document !== 'undefined') {
|
|
42
|
-
const tag = document.createElement('style');
|
|
43
|
-
tag.textContent = STYLES;
|
|
44
|
-
document.head.appendChild(tag);
|
|
45
|
-
styleInjected = true;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
42
|
if (variant === 'simple') {
|
|
49
43
|
return (
|
|
50
|
-
<div className={
|
|
51
|
-
<div
|
|
52
|
-
|
|
44
|
+
<div className={className} style={{ ...SIMPLE_BASE, ...style }}>
|
|
45
|
+
<div style={{
|
|
46
|
+
width: '100%',
|
|
47
|
+
marginBottom: 8,
|
|
48
|
+
display: 'flex',
|
|
49
|
+
alignItems: 'center',
|
|
50
|
+
justifyContent: 'space-between',
|
|
51
|
+
}}>
|
|
52
|
+
{title && (
|
|
53
|
+
<div style={{
|
|
54
|
+
fontSize: '.58rem',
|
|
55
|
+
fontWeight: 600,
|
|
56
|
+
textTransform: 'uppercase',
|
|
57
|
+
letterSpacing: '.08em',
|
|
58
|
+
color: 'var(--muted,#9b9daa)',
|
|
59
|
+
}}>{title}</div>
|
|
60
|
+
)}
|
|
53
61
|
{icon && (
|
|
54
|
-
<div
|
|
62
|
+
<div style={{
|
|
63
|
+
display: 'inline-flex',
|
|
64
|
+
alignItems: 'center',
|
|
65
|
+
justifyContent: 'center',
|
|
66
|
+
flexShrink: 0,
|
|
67
|
+
color: iconColor,
|
|
68
|
+
}}>
|
|
55
69
|
{icon}
|
|
56
70
|
</div>
|
|
57
71
|
)}
|
|
58
72
|
</div>
|
|
59
|
-
{value !== undefined &&
|
|
73
|
+
{value !== undefined && (
|
|
74
|
+
<div style={{
|
|
75
|
+
fontSize: '1.25rem',
|
|
76
|
+
fontWeight: 800,
|
|
77
|
+
letterSpacing: '-.03em',
|
|
78
|
+
lineHeight: 1.1,
|
|
79
|
+
minHeight: '1.375em',
|
|
80
|
+
}}>{value}</div>
|
|
81
|
+
)}
|
|
60
82
|
{children}
|
|
61
83
|
</div>
|
|
62
84
|
);
|
|
63
85
|
}
|
|
64
86
|
|
|
65
87
|
return (
|
|
66
|
-
<div className={
|
|
67
|
-
<div
|
|
68
|
-
|
|
69
|
-
|
|
88
|
+
<div className={className} style={{ ...BASE, ...style }}>
|
|
89
|
+
<div style={{
|
|
90
|
+
display: 'flex',
|
|
91
|
+
flexDirection: 'column',
|
|
92
|
+
minWidth: 0,
|
|
93
|
+
flex: 1,
|
|
94
|
+
}}>
|
|
95
|
+
<div style={{
|
|
96
|
+
display: 'flex',
|
|
97
|
+
alignItems: 'center',
|
|
98
|
+
justifyContent: 'space-between',
|
|
99
|
+
marginBottom: 8,
|
|
100
|
+
}}>
|
|
101
|
+
<div style={{
|
|
102
|
+
display: 'flex',
|
|
103
|
+
alignItems: 'center',
|
|
104
|
+
gap: 6,
|
|
105
|
+
}}>
|
|
70
106
|
{icon && (
|
|
71
|
-
<div
|
|
107
|
+
<div style={{
|
|
108
|
+
width: 24,
|
|
109
|
+
height: 24,
|
|
110
|
+
borderRadius: 6,
|
|
111
|
+
display: 'inline-flex',
|
|
112
|
+
alignItems: 'center',
|
|
113
|
+
justifyContent: 'center',
|
|
114
|
+
flexShrink: 0,
|
|
115
|
+
background: iconBg,
|
|
116
|
+
color: iconColor,
|
|
117
|
+
}}>
|
|
72
118
|
{icon}
|
|
73
119
|
</div>
|
|
74
120
|
)}
|
|
75
|
-
{title &&
|
|
121
|
+
{title && (
|
|
122
|
+
<div style={{
|
|
123
|
+
fontSize: '.58rem',
|
|
124
|
+
fontWeight: 600,
|
|
125
|
+
textTransform: 'uppercase',
|
|
126
|
+
letterSpacing: '.08em',
|
|
127
|
+
color: 'var(--muted,#9b9daa)',
|
|
128
|
+
}}>{title}</div>
|
|
129
|
+
)}
|
|
76
130
|
</div>
|
|
77
131
|
{headRight}
|
|
78
132
|
</div>
|
|
79
|
-
{value !== undefined &&
|
|
80
|
-
|
|
133
|
+
{value !== undefined && (
|
|
134
|
+
<div style={{
|
|
135
|
+
fontSize: '1.1rem',
|
|
136
|
+
fontWeight: 800,
|
|
137
|
+
letterSpacing: '-.02em',
|
|
138
|
+
color: 'var(--primary-text,#0f111c)',
|
|
139
|
+
lineHeight: 1.2,
|
|
140
|
+
minHeight: '1.32em',
|
|
141
|
+
}}>{value}</div>
|
|
142
|
+
)}
|
|
143
|
+
<div style={{
|
|
144
|
+
fontSize: '.62rem',
|
|
145
|
+
color: 'var(--muted,#9b9daa)',
|
|
146
|
+
fontWeight: 500,
|
|
147
|
+
marginTop: 1,
|
|
148
|
+
minHeight: 14,
|
|
149
|
+
}}>{subtitle || '\u00A0'}</div>
|
|
81
150
|
{children}
|
|
82
151
|
</div>
|
|
83
|
-
<div
|
|
152
|
+
<div style={{
|
|
153
|
+
display: 'flex',
|
|
154
|
+
alignItems: 'center',
|
|
155
|
+
gap: 8,
|
|
156
|
+
flexShrink: 0,
|
|
157
|
+
}}>
|
|
84
158
|
{percent !== undefined && (
|
|
85
159
|
<CircularProgress
|
|
86
160
|
value={percent}
|
package/components/Tabs.jsx
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export function Tabs({ tabs, value, onChange, style }) {
|
|
2
|
-
return (
|
|
3
|
-
<div className="xtabs" style={style}>
|
|
4
|
-
{tabs.map(t => {
|
|
5
|
-
const label = typeof t === 'string' ? t : t.label;
|
|
6
|
-
const key = typeof t === 'string' ? t : t.value;
|
|
7
|
-
const active = key === value;
|
|
8
|
-
return (
|
|
9
|
-
<button key={key} className={`xtab${active ? ' active' : ''}`} onClick={() => onChange(key)}>
|
|
10
|
-
{label}
|
|
11
|
-
</button>
|
|
12
|
-
);
|
|
13
|
-
})}
|
|
14
|
-
</div>
|
|
15
|
-
);
|
|
16
|
-
}
|
|
1
|
+
export function Tabs({ tabs, value, onChange, style }) {
|
|
2
|
+
return (
|
|
3
|
+
<div className="xtabs" style={style}>
|
|
4
|
+
{tabs.map(t => {
|
|
5
|
+
const label = typeof t === 'string' ? t : t.label;
|
|
6
|
+
const key = typeof t === 'string' ? t : t.value;
|
|
7
|
+
const active = key === value;
|
|
8
|
+
return (
|
|
9
|
+
<button key={key} className={`xtab${active ? ' active' : ''}`} onClick={() => onChange(key)}>
|
|
10
|
+
{label}
|
|
11
|
+
</button>
|
|
12
|
+
);
|
|
13
|
+
})}
|
|
14
|
+
</div>
|
|
15
|
+
);
|
|
16
|
+
}
|
package/components/Toast.jsx
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
import { useState, useEffect, useCallback } from 'react';
|
|
2
|
-
import { createPortal } from 'react-dom';
|
|
3
|
-
|
|
4
|
-
// ── Module-level state ────────────────────────────────────────────────────────
|
|
5
|
-
let _toasts = [];
|
|
6
|
-
let _listeners = new Set();
|
|
7
|
-
|
|
8
|
-
function notify() {
|
|
9
|
-
const snapshot = [..._toasts];
|
|
10
|
-
_listeners.forEach(fn => fn(snapshot));
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// Global toast — call from anywhere, no hook needed
|
|
14
|
-
export function toast(msg, type = 'ok') {
|
|
15
|
-
const id = Date.now() + Math.random();
|
|
16
|
-
_toasts = [..._toasts, { id, msg, type }];
|
|
17
|
-
notify();
|
|
18
|
-
setTimeout(() => {
|
|
19
|
-
_toasts = _toasts.filter(t => t.id !== id);
|
|
20
|
-
notify();
|
|
21
|
-
}, 3500);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// ── Hook — for components that want reactive state ────────────────────────────
|
|
25
|
-
export function useToast() {
|
|
26
|
-
const [toasts, setToasts] = useState(_toasts);
|
|
27
|
-
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
_listeners.add(setToasts);
|
|
30
|
-
return () => _listeners.delete(setToasts);
|
|
31
|
-
}, []);
|
|
32
|
-
|
|
33
|
-
const remove = useCallback(id => {
|
|
34
|
-
_toasts = _toasts.filter(t => t.id !== id);
|
|
35
|
-
notify();
|
|
36
|
-
}, []);
|
|
37
|
-
|
|
38
|
-
return { toasts, toast, remove };
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// ── Render component ──────────────────────────────────────────────────────────
|
|
42
|
-
export function Toast({ toasts, remove }) {
|
|
43
|
-
return createPortal(
|
|
44
|
-
<div id="toast-root">
|
|
45
|
-
{toasts.map(t => (
|
|
46
|
-
<div key={t.id} className={`toast ${t.type}`} onClick={() => remove(t.id)}>
|
|
47
|
-
{t.type === 'ok'
|
|
48
|
-
? <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="var(--success)" strokeWidth="2.5" strokeLinecap="round"><polyline points="20 6 9 17 4 12"/></svg>
|
|
49
|
-
: <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="var(--danger)" strokeWidth="2.5" strokeLinecap="round"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>
|
|
50
|
-
}
|
|
51
|
-
{t.msg}
|
|
52
|
-
</div>
|
|
53
|
-
))}
|
|
54
|
-
</div>,
|
|
55
|
-
document.body
|
|
56
|
-
);
|
|
57
|
-
}
|
|
1
|
+
import { useState, useEffect, useCallback } from 'react';
|
|
2
|
+
import { createPortal } from 'react-dom';
|
|
3
|
+
|
|
4
|
+
// ── Module-level state ────────────────────────────────────────────────────────
|
|
5
|
+
let _toasts = [];
|
|
6
|
+
let _listeners = new Set();
|
|
7
|
+
|
|
8
|
+
function notify() {
|
|
9
|
+
const snapshot = [..._toasts];
|
|
10
|
+
_listeners.forEach(fn => fn(snapshot));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Global toast — call from anywhere, no hook needed
|
|
14
|
+
export function toast(msg, type = 'ok') {
|
|
15
|
+
const id = Date.now() + Math.random();
|
|
16
|
+
_toasts = [..._toasts, { id, msg, type }];
|
|
17
|
+
notify();
|
|
18
|
+
setTimeout(() => {
|
|
19
|
+
_toasts = _toasts.filter(t => t.id !== id);
|
|
20
|
+
notify();
|
|
21
|
+
}, 3500);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// ── Hook — for components that want reactive state ────────────────────────────
|
|
25
|
+
export function useToast() {
|
|
26
|
+
const [toasts, setToasts] = useState(_toasts);
|
|
27
|
+
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
_listeners.add(setToasts);
|
|
30
|
+
return () => _listeners.delete(setToasts);
|
|
31
|
+
}, []);
|
|
32
|
+
|
|
33
|
+
const remove = useCallback(id => {
|
|
34
|
+
_toasts = _toasts.filter(t => t.id !== id);
|
|
35
|
+
notify();
|
|
36
|
+
}, []);
|
|
37
|
+
|
|
38
|
+
return { toasts, toast, remove };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// ── Render component ──────────────────────────────────────────────────────────
|
|
42
|
+
export function Toast({ toasts, remove }) {
|
|
43
|
+
return createPortal(
|
|
44
|
+
<div id="toast-root">
|
|
45
|
+
{toasts.map(t => (
|
|
46
|
+
<div key={t.id} className={`toast ${t.type}`} onClick={() => remove(t.id)}>
|
|
47
|
+
{t.type === 'ok'
|
|
48
|
+
? <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="var(--success)" strokeWidth="2.5" strokeLinecap="round"><polyline points="20 6 9 17 4 12"/></svg>
|
|
49
|
+
: <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="var(--danger)" strokeWidth="2.5" strokeLinecap="round"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>
|
|
50
|
+
}
|
|
51
|
+
{t.msg}
|
|
52
|
+
</div>
|
|
53
|
+
))}
|
|
54
|
+
</div>,
|
|
55
|
+
document.body
|
|
56
|
+
);
|
|
57
|
+
}
|
package/components/Toggle.jsx
CHANGED
|
@@ -1,58 +1,56 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
}
|
|
1
|
+
const SIZES = {
|
|
2
|
+
sm: { w: 28, h: 16, r: 8, dot: 12, off: 2, on: 14 },
|
|
3
|
+
md: { w: 34, h: 18, r: 9, dot: 14, off: 2, on: 18 },
|
|
4
|
+
lg: { w: 44, h: 24, r: 12, dot: 18, off: 3, on: 23 },
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
const COLORS = {
|
|
8
|
+
primary: 'var(--accent)',
|
|
9
|
+
success: 'var(--success)',
|
|
10
|
+
warning: '#f59e0b',
|
|
11
|
+
danger: 'var(--danger)',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default function Toggle({
|
|
15
|
+
checked = false,
|
|
16
|
+
onChange,
|
|
17
|
+
disabled = false,
|
|
18
|
+
size = 'md',
|
|
19
|
+
color = 'primary',
|
|
20
|
+
label = null,
|
|
21
|
+
labelStyle = {},
|
|
22
|
+
onClick = null,
|
|
23
|
+
className = '',
|
|
24
|
+
style = {},
|
|
25
|
+
}) {
|
|
26
|
+
const s = SIZES[size] || SIZES.md;
|
|
27
|
+
const trackBg = checked ? (COLORS[color] || COLORS.primary) : 'var(--bd2,#d7d8e0)';
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<label
|
|
31
|
+
className={className}
|
|
32
|
+
style={{ display:'inline-flex', alignItems:'center', gap:8, cursor: disabled ? 'not-allowed' : 'pointer', userSelect:'none', opacity: disabled ? .4 : 1, ...style }}
|
|
33
|
+
onClick={onClick}
|
|
34
|
+
>
|
|
35
|
+
<input type="checkbox" checked={checked} disabled={disabled}
|
|
36
|
+
onChange={e => onChange?.(e.target.checked)}
|
|
37
|
+
style={{ position:'absolute', opacity:0, width:0, height:0 }} />
|
|
38
|
+
<span style={{
|
|
39
|
+
position:'relative', width: s.w, height: s.h, borderRadius: s.r,
|
|
40
|
+
background: trackBg, flexShrink:0, transition:'background .2s ease',
|
|
41
|
+
boxShadow:'0 1px 3px rgba(20,22,41,.1)',
|
|
42
|
+
}}>
|
|
43
|
+
<span style={{
|
|
44
|
+
position:'absolute', top:'50%',
|
|
45
|
+
transform:'translateY(-50%)',
|
|
46
|
+
left: checked ? s.on : s.off,
|
|
47
|
+
width: s.dot, height: s.dot,
|
|
48
|
+
background:'#fff', borderRadius:'50%',
|
|
49
|
+
boxShadow:'0 1px 3px rgba(0,0,0,.25)',
|
|
50
|
+
transition:'left .25s cubic-bezier(.34,1.56,.64,1)',
|
|
51
|
+
}} />
|
|
52
|
+
</span>
|
|
53
|
+
{label && <span style={labelStyle}>{label}</span>}
|
|
54
|
+
</label>
|
|
55
|
+
);
|
|
56
|
+
}
|