cynx-ui 1.3.25 → 1.3.26
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/Card.jsx +132 -62
- package/components/Pagination.jsx +52 -41
- package/package.json +1 -1
package/components/Card.jsx
CHANGED
|
@@ -1,62 +1,132 @@
|
|
|
1
|
-
import { Pagination } from './Pagination';
|
|
2
|
-
|
|
3
|
-
export function PageShell({ title, children }) {
|
|
4
|
-
return (
|
|
5
|
-
<div style={{
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
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
|
+
}
|
|
@@ -1,41 +1,52 @@
|
|
|
1
|
-
import Button from './Button';
|
|
2
|
-
import { ChevronLeft, ChevronRight } from 'lucide-react';
|
|
3
|
-
|
|
4
|
-
export function Pagination({ page, pages, total, perPage, onChange }) {
|
|
5
|
-
const totalPages = pages || (total && perPage ? Math.ceil(total / perPage) : 0);
|
|
6
|
-
if (!totalPages || totalPages <= 1) return null;
|
|
7
|
-
|
|
8
|
-
const items = [];
|
|
9
|
-
for (let i = 1; i <= totalPages; i++) {
|
|
10
|
-
if (i === 1 || i === totalPages || (i >= page - 1 && i <= page + 1)) items.push(i);
|
|
11
|
-
else if (items[items.length - 1] !== '...') items.push('...');
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const start = perPage ? (page - 1) * perPage + 1 : null;
|
|
15
|
-
const end = perPage ? Math.min(page * perPage, total) : null;
|
|
16
|
-
|
|
17
|
-
return (
|
|
18
|
-
<div style={{
|
|
19
|
-
display: 'flex',
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
1
|
+
import Button from './Button';
|
|
2
|
+
import { ChevronLeft, ChevronRight } from 'lucide-react';
|
|
3
|
+
|
|
4
|
+
export function Pagination({ page = 1, pages = 1, total, perPage, onChange, style = {} }) {
|
|
5
|
+
const totalPages = pages || (total && perPage ? Math.ceil(total / perPage) : 0);
|
|
6
|
+
if (!totalPages || totalPages <= 1) return null;
|
|
7
|
+
|
|
8
|
+
const items = [];
|
|
9
|
+
for (let i = 1; i <= totalPages; i++) {
|
|
10
|
+
if (i === 1 || i === totalPages || (i >= page - 1 && i <= page + 1)) items.push(i);
|
|
11
|
+
else if (items[items.length - 1] !== '...') items.push('...');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const start = perPage ? (page - 1) * perPage + 1 : null;
|
|
15
|
+
const end = perPage ? Math.min(page * perPage, total) : null;
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<div style={{
|
|
19
|
+
display: 'flex',
|
|
20
|
+
alignItems: 'center',
|
|
21
|
+
gap: 8,
|
|
22
|
+
...style,
|
|
23
|
+
}}>
|
|
24
|
+
{start !== null && (
|
|
25
|
+
<div style={{ fontSize: '.72rem', color: 'var(--muted, #797b8d)', fontFamily: 'var(--mono, ui-monospace, monospace)' }}>
|
|
26
|
+
{start}–{end} of {total}
|
|
27
|
+
</div>
|
|
28
|
+
)}
|
|
29
|
+
<div style={{ display: 'flex', gap: 4, alignItems: 'center', marginLeft: start !== null ? 'auto' : 0 }}>
|
|
30
|
+
<Button
|
|
31
|
+
variant="ghost"
|
|
32
|
+
size="xs"
|
|
33
|
+
icon={<ChevronLeft size={14} />}
|
|
34
|
+
onClick={() => onChange?.(page - 1)}
|
|
35
|
+
disabled={page <= 1}
|
|
36
|
+
/>
|
|
37
|
+
{items.map((item, i) =>
|
|
38
|
+
item === '...'
|
|
39
|
+
? <span key={`e${i}`} style={{ padding: '0 4px', color: 'var(--muted, #797b8d)', fontSize: '.78rem' }}>…</span>
|
|
40
|
+
: <Button key={item} variant={item === page ? 'primary' : 'no-line'} size="xs" onClick={() => onChange?.(item)} style={{ minWidth: 28 }}>{item}</Button>
|
|
41
|
+
)}
|
|
42
|
+
<Button
|
|
43
|
+
variant="ghost"
|
|
44
|
+
size="xs"
|
|
45
|
+
icon={<ChevronRight size={14} />}
|
|
46
|
+
onClick={() => onChange?.(page + 1)}
|
|
47
|
+
disabled={page >= totalPages}
|
|
48
|
+
/>
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
);
|
|
52
|
+
}
|