cynx-lib 1.3.28
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/index.js +3 -0
- package/package.json +36 -0
- package/ui/components/ActionsMenu.jsx +158 -0
- package/ui/components/ActivityCard.jsx +184 -0
- package/ui/components/AuthOverlay.jsx +94 -0
- package/ui/components/Badge.jsx +186 -0
- package/ui/components/BrandingCard.jsx +146 -0
- package/ui/components/Button.jsx +148 -0
- package/ui/components/Card.jsx +132 -0
- package/ui/components/Checkbox.jsx +59 -0
- package/ui/components/ChipSelect.jsx +54 -0
- package/ui/components/CircularProgress.jsx +216 -0
- package/ui/components/Confirm.jsx +79 -0
- package/ui/components/DatePicker.jsx +605 -0
- package/ui/components/Divider.jsx +96 -0
- package/ui/components/Dropzone.jsx +203 -0
- package/ui/components/FilePicker.jsx +205 -0
- package/ui/components/HoverCard.jsx +81 -0
- package/ui/components/ImageUpload.jsx +147 -0
- package/ui/components/InfoBadge.jsx +204 -0
- package/ui/components/Input.jsx +229 -0
- package/ui/components/LineProgress.jsx +133 -0
- package/ui/components/LinearProgress.jsx +132 -0
- package/ui/components/Modal.jsx +212 -0
- package/ui/components/Pagination.jsx +52 -0
- package/ui/components/PulseDot.jsx +77 -0
- package/ui/components/Select.jsx +415 -0
- package/ui/components/Skeleton.jsx +118 -0
- package/ui/components/Spinner.jsx +108 -0
- package/ui/components/StatBarCard.jsx +25 -0
- package/ui/components/StatsBar.jsx +88 -0
- package/ui/components/StatsCard.jsx +171 -0
- package/ui/components/TabBar.jsx +404 -0
- package/ui/components/Tabs.jsx +29 -0
- package/ui/components/TimePicker.jsx +1069 -0
- package/ui/components/Toast.jsx +106 -0
- package/ui/components/Toggle.jsx +67 -0
- package/ui/components/UptimeBar.jsx +135 -0
- package/ui/components/XTable.jsx +44 -0
- package/ui/index.js +97 -0
- package/utils/index.js +11 -0
- package/utils/utils/oidc.js +209 -0
- package/utils/utils/realtime.js +1040 -0
- package/utils/utils/storage.js +393 -0
- package/utils/utils/tz.js +625 -0
- package/utils/utils/uid.js +252 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
import { Pencil, Trash2, Upload } from 'lucide-react';
|
|
3
|
+
import { Modal } from './Modal';
|
|
4
|
+
import Input from './Input';
|
|
5
|
+
import Button from './Button';
|
|
6
|
+
|
|
7
|
+
export function BrandingCard({ label, hint, value, onUpload, onRemove, saving, option, cardStyle }) {
|
|
8
|
+
const [editOpen, setEditOpen] = useState(false);
|
|
9
|
+
const [pendingFile, setPendingFile] = useState(null);
|
|
10
|
+
const [pendingUrl, setPendingUrl] = useState('');
|
|
11
|
+
const [uploading, setUploading] = useState(false);
|
|
12
|
+
const [previewOpen, setPreviewOpen] = useState(false);
|
|
13
|
+
|
|
14
|
+
const fullview = option === 'fullview';
|
|
15
|
+
|
|
16
|
+
// Pre-fill URL when modal opens
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (editOpen && value && !pendingFile) setPendingUrl(value);
|
|
19
|
+
}, [editOpen]);
|
|
20
|
+
|
|
21
|
+
const hasExisting = !!value;
|
|
22
|
+
const filename = pendingFile ? pendingFile.name : value?.split('/').pop() || null;
|
|
23
|
+
const previewUrl = pendingFile ? URL.createObjectURL(pendingFile) : value;
|
|
24
|
+
|
|
25
|
+
function handleFileDrop(file) {
|
|
26
|
+
setPendingFile(file);
|
|
27
|
+
setPendingUrl('');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function handleSave() {
|
|
31
|
+
setUploading(true);
|
|
32
|
+
try {
|
|
33
|
+
if (pendingFile) {
|
|
34
|
+
await onUpload(pendingFile);
|
|
35
|
+
} else if (pendingUrl) {
|
|
36
|
+
await onUpload(pendingUrl);
|
|
37
|
+
}
|
|
38
|
+
setEditOpen(false);
|
|
39
|
+
setPendingFile(null);
|
|
40
|
+
setPendingUrl('');
|
|
41
|
+
} catch (e) {
|
|
42
|
+
// error handled by parent toast
|
|
43
|
+
} finally {
|
|
44
|
+
setUploading(false);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function handleRemove() {
|
|
49
|
+
setPendingFile(null);
|
|
50
|
+
setPendingUrl('');
|
|
51
|
+
onRemove();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<div>
|
|
56
|
+
<div style={{
|
|
57
|
+
display: 'flex', alignItems: 'center', justifyContent: 'space-between',
|
|
58
|
+
gap: 10,
|
|
59
|
+
padding: '10px 12px', borderRadius: 'var(--rads, 8px)',
|
|
60
|
+
border: '1px solid var(--border-light, #ebebf0)', background: 'var(--surface, #ffffff)',
|
|
61
|
+
boxShadow: 'var(--shadow, 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06))',
|
|
62
|
+
...cardStyle,
|
|
63
|
+
}}>
|
|
64
|
+
{(hasExisting || previewUrl) ? (
|
|
65
|
+
<img src={previewUrl} alt={label} onClick={() => fullview && setPreviewOpen(true)}
|
|
66
|
+
style={{ height: fullview ? 24 : 32, width: fullview ? 'auto' : 32, objectFit: 'contain', borderRadius: 4, flexShrink: 0, cursor: fullview ? 'pointer' : 'default' }} />
|
|
67
|
+
) : (
|
|
68
|
+
<div style={{ width: fullview ? 24 : 32, height: fullview ? 24 : 32, borderRadius: 4, background: 'var(--grey-2, #ebebee)', display: 'flex', alignItems: 'center', justifyContent: 'center', flexShrink: 0 }}>
|
|
69
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="var(--muted, #797b8d)" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
|
70
|
+
<rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/>
|
|
71
|
+
</svg>
|
|
72
|
+
</div>
|
|
73
|
+
)}
|
|
74
|
+
{!fullview && (
|
|
75
|
+
<div style={{ flex: 1, minWidth: 0, fontSize: '.78rem', color: filename ? 'var(--primary-text, #0f172a)' : 'var(--muted, #797b8d)', fontFamily: filename ? 'var(--mono, ui-monospace, monospace)' : 'inherit', wordBreak: 'break-all', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
|
76
|
+
{filename || 'Not set'}
|
|
77
|
+
</div>
|
|
78
|
+
)}
|
|
79
|
+
<div style={{ display: 'flex', gap: 4, flexShrink: 0 }}>
|
|
80
|
+
<Button variant="ghost" size="xs" type="button" icon={<Pencil size={11} />} onClick={() => setEditOpen(true)} style={cardStyle ? { background: 'var(--surface,#fff)', color: 'var(--t, #333)' } : undefined}>Edit</Button>
|
|
81
|
+
{hasExisting && (
|
|
82
|
+
<Button variant="ghost" size="xs" type="button" icon={<Trash2 size={11} />} style={cardStyle ? { background: 'var(--surface,#fff)', color: 'var(--danger, #f64747)' } : { color: 'var(--danger, #f64747)' }}
|
|
83
|
+
onClick={handleRemove} disabled={saving}>Remove</Button>
|
|
84
|
+
)}
|
|
85
|
+
</div>
|
|
86
|
+
</div>
|
|
87
|
+
<div style={{ fontSize: '.68rem', color: 'var(--muted, #797b8d)', marginTop: 4 }}>{hint}</div>
|
|
88
|
+
|
|
89
|
+
{previewOpen && (
|
|
90
|
+
<Modal title={label} open={previewOpen} onClose={() => setPreviewOpen(false)}
|
|
91
|
+
footer={<Button variant="ghost" size="sm" onClick={() => setPreviewOpen(false)}>Close</Button>}>
|
|
92
|
+
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', padding: '16px 0' }}>
|
|
93
|
+
<img src={previewUrl} alt={label} style={{ maxWidth: '100%', maxHeight: 400, objectFit: 'contain', borderRadius: 6 }} />
|
|
94
|
+
</div>
|
|
95
|
+
</Modal>
|
|
96
|
+
)}
|
|
97
|
+
|
|
98
|
+
{editOpen && (
|
|
99
|
+
<Modal title={`Edit ${label}`} open={editOpen} onClose={() => { setEditOpen(false); setPendingFile(null); setPendingUrl(''); }}
|
|
100
|
+
footer={
|
|
101
|
+
<>
|
|
102
|
+
<Button variant="ghost" size="sm" onClick={() => { setEditOpen(false); setPendingFile(null); setPendingUrl(''); }}>Cancel</Button>
|
|
103
|
+
<Button variant="primary" size="sm" disabled={saving || uploading} onClick={handleSave}>
|
|
104
|
+
{uploading ? 'Uploading...' : saving ? 'Saving...' : 'Save'}
|
|
105
|
+
</Button>
|
|
106
|
+
</>
|
|
107
|
+
}>
|
|
108
|
+
<label
|
|
109
|
+
onDragOver={e => { e.preventDefault(); e.currentTarget.style.borderColor = 'var(--accent, #f99e2c)'; }}
|
|
110
|
+
onDragLeave={e => { e.currentTarget.style.borderColor = pendingFile ? 'var(--accent, #f99e2c)' : 'var(--border, #e2e8f0)'; }}
|
|
111
|
+
onDrop={e => { e.preventDefault(); const f = e.dataTransfer.files[0]; if (f) handleFileDrop(f); }}
|
|
112
|
+
style={{
|
|
113
|
+
display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center',
|
|
114
|
+
gap: 8, padding: '24px 16px', borderRadius: 'var(--rads, 8px)',
|
|
115
|
+
border: `1.5px dashed ${pendingFile ? 'var(--accent, #f99e2c)' : 'var(--border, #e2e8f0)'}`,
|
|
116
|
+
background: 'var(--grey-1, #f5f5f8)', cursor: 'pointer', transition: 'all .15s', textAlign: 'center',
|
|
117
|
+
}}>
|
|
118
|
+
<input type="file" accept="image/*,.ico" style={{ display: 'none' }}
|
|
119
|
+
onChange={e => { const f = e.target.files[0]; if (f) handleFileDrop(f); }} />
|
|
120
|
+
{pendingFile ? (
|
|
121
|
+
<>
|
|
122
|
+
<img src={URL.createObjectURL(pendingFile)} alt="preview" style={{ height: 48, maxWidth: 160, objectFit: 'contain', borderRadius: 4 }} />
|
|
123
|
+
<div style={{ fontSize: '.76rem', fontWeight: 600, color: 'var(--accent, #f99e2c)' }}>{pendingFile.name}</div>
|
|
124
|
+
<div style={{ fontSize: '.68rem', color: 'var(--muted, #797b8d)' }}>{(pendingFile.size / 1024).toFixed(1)} KB — click to change</div>
|
|
125
|
+
</>
|
|
126
|
+
) : (
|
|
127
|
+
<>
|
|
128
|
+
<Upload size={20} style={{ color: 'var(--muted, #797b8d)' }} />
|
|
129
|
+
<div style={{ fontSize: '.82rem', fontWeight: 600 }}>Click or drag to upload</div>
|
|
130
|
+
<div style={{ fontSize: '.72rem', color: 'var(--muted, #797b8d)' }}>PNG, JPG, SVG, ICO up to 2MB</div>
|
|
131
|
+
</>
|
|
132
|
+
)}
|
|
133
|
+
</label>
|
|
134
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: 8, margin: '12px 0 4px' }}>
|
|
135
|
+
<div style={{ flex: 1, height: 1, background: 'var(--border, #e2e8f0)' }} />
|
|
136
|
+
<span style={{ fontSize: '.72rem', color: 'var(--muted, #797b8d)' }}>or enter URL directly</span>
|
|
137
|
+
<div style={{ flex: 1, height: 1, background: 'var(--border, #e2e8f0)' }} />
|
|
138
|
+
</div>
|
|
139
|
+
<Input type="url" placeholder="https://example.com/logo.png" value={pendingUrl}
|
|
140
|
+
onChange={e => { setPendingUrl(e.target.value); setPendingFile(null); }}
|
|
141
|
+
style={{ width: '100%', fontSize: '.82rem' }} />
|
|
142
|
+
</Modal>
|
|
143
|
+
)}
|
|
144
|
+
</div>
|
|
145
|
+
);
|
|
146
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { Spinner } from './Spinner';
|
|
2
|
+
|
|
3
|
+
const VARIANTS = {
|
|
4
|
+
default: {
|
|
5
|
+
background: 'var(--surface,#fff)',
|
|
6
|
+
color: 'var(--def-btn-text,#0f111c)',
|
|
7
|
+
border: '1px solid var(--bd,#d7d8e0)',
|
|
8
|
+
hoverBg: 'var(--grey-1,#f5f5f8)',
|
|
9
|
+
hoverBorder: 'var(--grey-2,#ebebee)',
|
|
10
|
+
},
|
|
11
|
+
primary: {
|
|
12
|
+
background: 'var(--accent,#f99e2c)',
|
|
13
|
+
color: 'var(--def-btn-text,#fff)',
|
|
14
|
+
border: '1px solid transparent',
|
|
15
|
+
hoverBg: 'var(--accent-hover,#e68d1f)',
|
|
16
|
+
hoverShadow: '0 2px 8px rgba(249,158,44,.35)',
|
|
17
|
+
},
|
|
18
|
+
secondary: {
|
|
19
|
+
background: 'var(--blue-bg,rgba(39,130,228,.1))',
|
|
20
|
+
color: 'var(--blue,#2782e4)',
|
|
21
|
+
border: '1px solid var(--infd, rgba(39,130,228,.2))',
|
|
22
|
+
hoverBg: 'var(--infd, rgba(39,130,228,.18))',
|
|
23
|
+
hoverShadow: '0 2px 8px rgba(39,130,228,.25)',
|
|
24
|
+
},
|
|
25
|
+
danger: {
|
|
26
|
+
background: 'var(--danger-bg,rgba(246,71,71,.1))',
|
|
27
|
+
color: 'var(--danger,#f64747)',
|
|
28
|
+
border: '1px solid var(--dd, rgba(246,71,71,.2))',
|
|
29
|
+
hoverBg: 'var(--dd, rgba(246,71,71,.18))',
|
|
30
|
+
hoverShadow: '0 2px 8px rgba(246,71,71,.25)',
|
|
31
|
+
},
|
|
32
|
+
success: {
|
|
33
|
+
background: 'var(--success-bg,rgba(39,174,96,.1))',
|
|
34
|
+
color: 'var(--success,#27ae60)',
|
|
35
|
+
border: '1px solid var(--sd, rgba(39,174,96,.2))',
|
|
36
|
+
hoverBg: 'var(--sd, rgba(39,174,96,.18))',
|
|
37
|
+
hoverShadow: '0 2px 8px rgba(39,174,96,.25)',
|
|
38
|
+
},
|
|
39
|
+
warning: {
|
|
40
|
+
background: 'var(--accent-bg,rgba(249,158,44,.1))',
|
|
41
|
+
color: 'var(--accent,#f99e2c)',
|
|
42
|
+
border: '1px solid var(--accent-border,rgba(249,158,44,.25))',
|
|
43
|
+
hoverBg: 'var(--pd, rgba(249,158,44,.18))',
|
|
44
|
+
hoverShadow: '0 2px 8px rgba(249,158,44,.25)',
|
|
45
|
+
},
|
|
46
|
+
ghost: {
|
|
47
|
+
background: 'var(--surface, #ffffff)',
|
|
48
|
+
color: 'var(--t2,#797b8d)',
|
|
49
|
+
border: '1px solid var(--bd,#d7d8e0)',
|
|
50
|
+
hoverColor: 'var(--t1,#1a1a2e)',
|
|
51
|
+
hoverBg: 'var(--grey-1,#f5f5f8)',
|
|
52
|
+
hoverBorder: 'var(--grey-2,#ebebee)',
|
|
53
|
+
},
|
|
54
|
+
outline: {
|
|
55
|
+
background: 'transparent',
|
|
56
|
+
color: 'var(--accent,#f99e2c)',
|
|
57
|
+
border: '1px solid var(--accent,#f99e2c)',
|
|
58
|
+
hoverBg: 'var(--accent-bg,rgba(249,158,44,.1))',
|
|
59
|
+
},
|
|
60
|
+
link: {
|
|
61
|
+
background: 'transparent',
|
|
62
|
+
color: 'var(--accent,#f99e2c)',
|
|
63
|
+
border: '1px solid transparent',
|
|
64
|
+
paddingLeft: 4,
|
|
65
|
+
paddingRight: 4,
|
|
66
|
+
boxShadow: 'none',
|
|
67
|
+
hoverTextDec: 'underline',
|
|
68
|
+
},
|
|
69
|
+
'no-line': {
|
|
70
|
+
background: 'none',
|
|
71
|
+
border: 'none',
|
|
72
|
+
boxShadow: 'none',
|
|
73
|
+
color: 'var(--t3,#8a96b0)',
|
|
74
|
+
paddingLeft: 14,
|
|
75
|
+
paddingRight: 14,
|
|
76
|
+
borderRadius: 'var(--rmd,8px)',
|
|
77
|
+
hoverColor: 'var(--p,var(--accent,#f99e2c))',
|
|
78
|
+
hoverBg: 'var(--pd,var(--accent-bg,rgba(249,158,44,.1)))',
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const SIZES = {
|
|
83
|
+
xs: { padding: '0 6px', fontSize: 11, height: 24 },
|
|
84
|
+
sm: { padding: '0 8px', fontSize: 11.5, height: 28 },
|
|
85
|
+
md: { padding: '0 14px', fontSize: 13, height: 32 },
|
|
86
|
+
lg: { padding: '0 18px', fontSize: 14, height: 36 },
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export default function Button({
|
|
90
|
+
children,
|
|
91
|
+
variant = 'default',
|
|
92
|
+
size = 'md',
|
|
93
|
+
icon = null,
|
|
94
|
+
iconRight = null,
|
|
95
|
+
disabled = false,
|
|
96
|
+
loading = false,
|
|
97
|
+
onClick = null,
|
|
98
|
+
style = {},
|
|
99
|
+
className = '',
|
|
100
|
+
...props
|
|
101
|
+
}) {
|
|
102
|
+
const v = VARIANTS[variant] || VARIANTS.default;
|
|
103
|
+
const s = SIZES[size] || SIZES.md;
|
|
104
|
+
|
|
105
|
+
const isIconOnly = variant === 'icon';
|
|
106
|
+
|
|
107
|
+
return (
|
|
108
|
+
<button
|
|
109
|
+
className={`btn btn-${variant} ${className}`.trim()}
|
|
110
|
+
disabled={disabled || loading}
|
|
111
|
+
onClick={onClick}
|
|
112
|
+
style={{
|
|
113
|
+
display: 'inline-flex',
|
|
114
|
+
alignItems: 'center',
|
|
115
|
+
justifyContent: 'center',
|
|
116
|
+
gap: 6,
|
|
117
|
+
borderRadius: 'var(--rads,8px)',
|
|
118
|
+
fontFamily: 'var(--f,var(--sans,inherit))',
|
|
119
|
+
fontWeight: 500,
|
|
120
|
+
cursor: disabled ? 'not-allowed' : 'pointer',
|
|
121
|
+
whiteSpace: 'nowrap',
|
|
122
|
+
transition: 'all .14s',
|
|
123
|
+
letterSpacing: '-.01em',
|
|
124
|
+
outline: 'none',
|
|
125
|
+
boxShadow: 'var(--shadow,0 1px 3px rgba(20,22,41,.1))',
|
|
126
|
+
opacity: disabled ? 0.45 : 1,
|
|
127
|
+
pointerEvents: disabled ? 'none' : undefined,
|
|
128
|
+
background: v.background,
|
|
129
|
+
color: v.color,
|
|
130
|
+
border: v.border,
|
|
131
|
+
padding: isIconOnly ? 0 : s.padding,
|
|
132
|
+
fontSize: s.fontSize,
|
|
133
|
+
height: s.height,
|
|
134
|
+
width: isIconOnly ? s.height : undefined,
|
|
135
|
+
...(v.paddingLeft !== undefined && { paddingLeft: v.paddingLeft }),
|
|
136
|
+
...(v.paddingRight !== undefined && { paddingRight: v.paddingRight }),
|
|
137
|
+
...(v.boxShadow !== undefined && { boxShadow: v.boxShadow }),
|
|
138
|
+
...style,
|
|
139
|
+
}}
|
|
140
|
+
{...props}
|
|
141
|
+
>
|
|
142
|
+
{loading && <Spinner size={14} inline color="currentColor" />}
|
|
143
|
+
{!loading && icon && icon}
|
|
144
|
+
{!loading && children}
|
|
145
|
+
{!loading && iconRight && iconRight}
|
|
146
|
+
</button>
|
|
147
|
+
);
|
|
148
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { Pagination } from './Pagination';
|
|
2
|
+
|
|
3
|
+
export function PageShell({ title, children, style = {} }) {
|
|
4
|
+
return (
|
|
5
|
+
<div style={{
|
|
6
|
+
flex: 1,
|
|
7
|
+
display: 'flex',
|
|
8
|
+
flexDirection: 'column',
|
|
9
|
+
minHeight: 0,
|
|
10
|
+
height: '100%',
|
|
11
|
+
padding: '20px 24px',
|
|
12
|
+
boxSizing: 'border-box',
|
|
13
|
+
overflow: 'hidden',
|
|
14
|
+
...style,
|
|
15
|
+
}}>
|
|
16
|
+
{children}
|
|
17
|
+
</div>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function TableCard({ children, style = {} }) {
|
|
22
|
+
return (
|
|
23
|
+
<div style={{
|
|
24
|
+
flex: 1,
|
|
25
|
+
display: 'flex',
|
|
26
|
+
flexDirection: 'column',
|
|
27
|
+
minHeight: 0,
|
|
28
|
+
height: '100%',
|
|
29
|
+
overflow: 'hidden',
|
|
30
|
+
...style,
|
|
31
|
+
}}>
|
|
32
|
+
{children}
|
|
33
|
+
</div>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function TableCardFilters({ children, style = {} }) {
|
|
38
|
+
return (
|
|
39
|
+
<div style={{
|
|
40
|
+
flexShrink: 0,
|
|
41
|
+
display: 'flex',
|
|
42
|
+
alignItems: 'center',
|
|
43
|
+
gap: 8,
|
|
44
|
+
padding: '8px 0',
|
|
45
|
+
borderBottom: '1px solid var(--border-light, #ebebf0)',
|
|
46
|
+
...style,
|
|
47
|
+
}}>
|
|
48
|
+
{children}
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function TableCardBody({ children, style = {} }) {
|
|
54
|
+
return (
|
|
55
|
+
<div style={{
|
|
56
|
+
flex: 1,
|
|
57
|
+
overflowY: 'auto',
|
|
58
|
+
minHeight: 0,
|
|
59
|
+
scrollbarWidth: 'thin',
|
|
60
|
+
scrollbarColor: 'var(--grey-2, #d7d8e0) transparent',
|
|
61
|
+
...style,
|
|
62
|
+
}}>
|
|
63
|
+
{children}
|
|
64
|
+
</div>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function TableCardFooter({ total = 0, page = 1, limit = 100, pages = 1, onChange, style = {} }) {
|
|
69
|
+
const from = total === 0 ? 0 : (page - 1) * limit + 1;
|
|
70
|
+
const to = Math.min(page * limit, total);
|
|
71
|
+
return (
|
|
72
|
+
<div style={{
|
|
73
|
+
flexShrink: 0,
|
|
74
|
+
marginTop: 'auto',
|
|
75
|
+
display: 'flex',
|
|
76
|
+
alignItems: 'center',
|
|
77
|
+
justifyContent: 'space-between',
|
|
78
|
+
padding: '12px 0 0 0',
|
|
79
|
+
borderTop: '1px solid var(--border-light, #ebebf0)',
|
|
80
|
+
fontSize: '.78rem',
|
|
81
|
+
color: 'var(--muted, #9b9daa)',
|
|
82
|
+
boxSizing: 'border-box',
|
|
83
|
+
...style,
|
|
84
|
+
}}>
|
|
85
|
+
<span>
|
|
86
|
+
{total === 0 ? '0 записей' : `${from}–${to} из ${total}`}
|
|
87
|
+
</span>
|
|
88
|
+
<Pagination page={page} pages={pages} onChange={onChange} />
|
|
89
|
+
</div>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function CardHdr({ title, icon: Icon, tabs, children, style = {} }) {
|
|
94
|
+
return (
|
|
95
|
+
<div style={{
|
|
96
|
+
flexShrink: 0,
|
|
97
|
+
display: 'flex',
|
|
98
|
+
alignItems: 'center',
|
|
99
|
+
justifyContent: 'space-between',
|
|
100
|
+
padding: '0',
|
|
101
|
+
height: 48,
|
|
102
|
+
borderBottom: '1px solid var(--border-light, #ebebf0)',
|
|
103
|
+
...style,
|
|
104
|
+
}}>
|
|
105
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: 6, fontSize: '.85rem', fontWeight: 600, color: 'var(--primary-text, #0f111c)' }}>
|
|
106
|
+
{Icon && <Icon size={14} />}
|
|
107
|
+
{title}
|
|
108
|
+
{tabs && <span style={{ marginLeft: 12 }}>{tabs}</span>}
|
|
109
|
+
</div>
|
|
110
|
+
{children && <div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>{children}</div>}
|
|
111
|
+
</div>
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function StatCard({ label, value, sub }) {
|
|
116
|
+
return (
|
|
117
|
+
<div style={{ background: 'var(--surface, #fff)', border: '1px solid var(--border-light, #ebebf0)', borderRadius: 'var(--rads, 8px)', padding: '14px 16px', boxShadow: 'var(--shadow, 0px 1px 3px rgba(20,22,41,.10))' }}>
|
|
118
|
+
<div style={{ fontSize: '.62rem', fontWeight: 600, textTransform: 'uppercase', letterSpacing: '.08em', color: 'var(--muted, #9b9daa)', marginBottom: 4 }}>{label}</div>
|
|
119
|
+
<div style={{ fontSize: '1.4rem', fontWeight: 700, color: 'var(--primary-text, #0f111c)', lineHeight: 1.2 }}>{value ?? '—'}</div>
|
|
120
|
+
{sub && <div style={{ fontSize: '.72rem', color: 'var(--muted, #9b9daa)', marginTop: 2 }}>{sub}</div>}
|
|
121
|
+
</div>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function StatCardSkeleton() {
|
|
126
|
+
return (
|
|
127
|
+
<div style={{ background: 'var(--surface, #fff)', border: '1px solid var(--border-light, #ebebf0)', borderRadius: 'var(--rads, 8px)', padding: '14px 16px' }}>
|
|
128
|
+
<div className="skeleton skeleton-text" style={{ marginBottom: 10, height: 12, width: '40%', background: 'linear-gradient(90deg, var(--grey-1, #f5f5f8) 25%, var(--border-light, #ebebf0) 50%, var(--grey-1, #f5f5f8) 75%)', backgroundSize: '600px 100%', animation: 'shimmer 1.4s ease infinite', borderRadius: 'var(--radxs, 6px)' }} />
|
|
129
|
+
<div className="skeleton skeleton-text" style={{ height: 28, width: '60%', marginBottom: 6, background: 'linear-gradient(90deg, var(--grey-1, #f5f5f8) 25%, var(--border-light, #ebebf0) 50%, var(--grey-1, #f5f5f8) 75%)', backgroundSize: '600px 100%', animation: 'shimmer 1.4s ease infinite', borderRadius: 'var(--radxs, 6px)' }} />
|
|
130
|
+
</div>
|
|
131
|
+
);
|
|
132
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { useRef, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Checkbox — custom styled checkbox component
|
|
5
|
+
* Props:
|
|
6
|
+
* checked: bool
|
|
7
|
+
* indeterminate: bool — shows dash instead of check
|
|
8
|
+
* onChange: fn(checked)
|
|
9
|
+
* disabled: bool
|
|
10
|
+
* size: 'sm' | 'md' (default 'md')
|
|
11
|
+
* label: string — optional label text
|
|
12
|
+
* style: object — optional extra styles on wrapper
|
|
13
|
+
*/
|
|
14
|
+
export default function Checkbox({ checked, indeterminate, onChange, disabled = false, size = 'md', label, style }) {
|
|
15
|
+
const inputRef = useRef(null);
|
|
16
|
+
useEffect(() => { if (inputRef.current) inputRef.current.indeterminate = !!indeterminate; }, [indeterminate]);
|
|
17
|
+
|
|
18
|
+
const dims = size === 'sm' ? { w: 14, h: 14, icon: 8 } : { w: 16, h: 16, icon: 10 };
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<label style={{
|
|
22
|
+
display: 'inline-flex', alignItems: 'center', gap: 6,
|
|
23
|
+
cursor: disabled ? 'not-allowed' : 'pointer',
|
|
24
|
+
userSelect: 'none', margin: 0, padding: 0, lineHeight: 1,
|
|
25
|
+
opacity: disabled ? 0.45 : 1,
|
|
26
|
+
...style,
|
|
27
|
+
}}>
|
|
28
|
+
<span style={{
|
|
29
|
+
position: 'relative', width: dims.w, height: dims.h, flexShrink: 0,
|
|
30
|
+
border: `1.5px solid ${checked || indeterminate ? 'var(--accent, #f99e2c)' : 'var(--border, #e2e8f0)'}`,
|
|
31
|
+
borderRadius: size === 'sm' ? 3 : 4,
|
|
32
|
+
background: checked || indeterminate ? 'var(--accent, #f99e2c)' : 'var(--input-bg, #ffffff)',
|
|
33
|
+
transition: 'all .14s',
|
|
34
|
+
cursor: disabled ? 'not-allowed' : 'pointer',
|
|
35
|
+
}}>
|
|
36
|
+
{indeterminate ? (
|
|
37
|
+
<svg style={{ position: 'absolute', top: '50%', left: '50%', transform: 'translate(-50%, -50%)' }}
|
|
38
|
+
width={dims.icon} height={dims.icon} viewBox="0 0 10 10" fill="none">
|
|
39
|
+
<line x1="2" y1="5" x2="8" y2="5" stroke="white" strokeWidth="1.6" strokeLinecap="round" />
|
|
40
|
+
</svg>
|
|
41
|
+
) : checked ? (
|
|
42
|
+
<svg style={{ position: 'absolute', top: '50%', left: '50%', transform: 'translate(-50%, -50%)' }}
|
|
43
|
+
width={dims.icon} height={dims.icon} viewBox="0 0 10 10" fill="none">
|
|
44
|
+
<polyline points="1.5,5 4,7.5 8.5,2.5" stroke="white" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" />
|
|
45
|
+
</svg>
|
|
46
|
+
) : null}
|
|
47
|
+
</span>
|
|
48
|
+
{label && <span style={{ fontSize: size === 'sm' ? '.72rem' : '.78rem' }}>{label}</span>}
|
|
49
|
+
<input
|
|
50
|
+
ref={inputRef}
|
|
51
|
+
type="checkbox"
|
|
52
|
+
checked={!!checked}
|
|
53
|
+
disabled={disabled}
|
|
54
|
+
onChange={e => onChange?.(e.target.checked)}
|
|
55
|
+
style={{ position: 'absolute', opacity: 0, width: 0, height: 0, pointerEvents: 'none' }}
|
|
56
|
+
/>
|
|
57
|
+
</label>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { useRef, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ChipSelect — reusable multi-select chip/toggle group
|
|
5
|
+
* Props:
|
|
6
|
+
* options: [{ value, label }]
|
|
7
|
+
* value: string[] — selected values
|
|
8
|
+
* onChange: fn(string[]) — called with updated selection
|
|
9
|
+
* size: 'sm' | 'md' (default 'md')
|
|
10
|
+
*/
|
|
11
|
+
export default function ChipSelect({ options, value = [], onChange, size = 'md' }) {
|
|
12
|
+
const dims = size === 'sm' ? { h: 14, icon: 8, px: 10, py: 5, gap: 6, font: '.72rem' } : { h: 16, icon: 10, px: 14, py: 7, gap: 7, font: '.78rem' };
|
|
13
|
+
|
|
14
|
+
function toggle(val) {
|
|
15
|
+
const next = value.includes(val) ? value.filter(v => v !== val) : [...value, val];
|
|
16
|
+
onChange?.(next);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<div style={{ display:'flex', gap:10, flexWrap:'wrap' }}>
|
|
21
|
+
{options.map(opt => {
|
|
22
|
+
const active = value.includes(opt.value);
|
|
23
|
+
return (
|
|
24
|
+
<div key={opt.value}
|
|
25
|
+
onClick={() => toggle(opt.value)}
|
|
26
|
+
style={{
|
|
27
|
+
display:'flex', alignItems:'center', gap: dims.gap,
|
|
28
|
+
padding:`${dims.py}px ${dims.px}px`, cursor:'pointer',
|
|
29
|
+
borderRadius: 8,
|
|
30
|
+
background: 'var(--grey-1, #f5f5f8)',
|
|
31
|
+
transition: 'all .14s',
|
|
32
|
+
userSelect: 'none',
|
|
33
|
+
}}>
|
|
34
|
+
<span style={{
|
|
35
|
+
position:'relative', width: dims.h, height: dims.h, flexShrink:0,
|
|
36
|
+
borderRadius: 4,
|
|
37
|
+
background: active ? 'var(--accent, #f99e2c)' : 'var(--input-bg, #ffffff)',
|
|
38
|
+
border: `1.5px solid ${active ? 'var(--accent, #f99e2c)' : 'var(--border, #e2e8f0)'}`,
|
|
39
|
+
transition: 'all .14s',
|
|
40
|
+
display:'flex', alignItems:'center', justifyContent:'center',
|
|
41
|
+
}}>
|
|
42
|
+
{active && (
|
|
43
|
+
<svg width={dims.icon} height={dims.icon} viewBox="0 0 10 10" fill="none">
|
|
44
|
+
<polyline points="1.5,5 4,7.5 8.5,2.5" stroke="white" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" />
|
|
45
|
+
</svg>
|
|
46
|
+
)}
|
|
47
|
+
</span>
|
|
48
|
+
<span style={{ fontSize: dims.font, fontWeight:600, textTransform:'uppercase', letterSpacing:'.04em', color: 'var(--muted, #797b8d)' }}>{opt.label}</span>
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
})}
|
|
52
|
+
</div>
|
|
53
|
+
);
|
|
54
|
+
}
|