cynx-lib 1.3.107 → 1.3.109
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/Card.jsx +9 -8
- package/ui/index.cjs +0 -15
- package/ui/index.js +0 -8
- package/ui/components/DataView.jsx +0 -245
package/package.json
CHANGED
package/ui/components/Card.jsx
CHANGED
|
@@ -113,21 +113,22 @@ export function CardHdr({ title, icon: Icon, tabs, children, style = {} }) {
|
|
|
113
113
|
);
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
export function StatCard({ label, value, sub }) {
|
|
116
|
+
export function StatCard({ label, value, sub, style }) {
|
|
117
117
|
return (
|
|
118
|
-
<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))' }}>
|
|
119
|
-
<div style={{ fontSize: '.62rem', fontWeight: 600, textTransform: 'uppercase', letterSpacing: '.08em', color: 'var(--muted, #9b9daa)'
|
|
118
|
+
<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))', boxSizing: 'border-box', height: 88, display: 'flex', flexDirection: 'column', justifyContent: 'space-between', ...style }}>
|
|
119
|
+
<div style={{ fontSize: '.62rem', fontWeight: 600, textTransform: 'uppercase', letterSpacing: '.08em', color: 'var(--muted, #9b9daa)' }}>{label}</div>
|
|
120
120
|
<div style={{ fontSize: '1.4rem', fontWeight: 700, color: 'var(--primary-text, #0f111c)', lineHeight: 1.2 }}>{value ?? '—'}</div>
|
|
121
|
-
{sub && <div style={{ fontSize: '.72rem', color: 'var(--muted, #9b9daa)'
|
|
121
|
+
{sub && <div style={{ fontSize: '.72rem', color: 'var(--muted, #9b9daa)' }}>{sub}</div>}
|
|
122
122
|
</div>
|
|
123
123
|
);
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
export function StatCardSkeleton() {
|
|
126
|
+
export function StatCardSkeleton({ style }) {
|
|
127
127
|
return (
|
|
128
|
-
<div style={{ background: 'var(--surface, #fff)', border: '1px solid var(--border-light, #ebebf0)', borderRadius: 'var(--rads, 8px)', padding: '14px 16px' }}>
|
|
129
|
-
<div className="skeleton skeleton-text" style={{
|
|
130
|
-
<div className="skeleton skeleton-text" style={{ height:
|
|
128
|
+
<div style={{ background: 'var(--surface, #fff)', border: '1px solid var(--border-light, #ebebf0)', borderRadius: 'var(--rads, 8px)', padding: '14px 16px', boxSizing: 'border-box', height: 88, display: 'flex', flexDirection: 'column', justifyContent: 'space-between', ...style }}>
|
|
129
|
+
<div className="skeleton skeleton-text" style={{ height: 11, 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)' }} />
|
|
130
|
+
<div className="skeleton skeleton-text" style={{ height: 26, width: '60%', 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)' }} />
|
|
131
|
+
<div className="skeleton skeleton-text" style={{ height: 11, width: '55%', 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)' }} />
|
|
131
132
|
</div>
|
|
132
133
|
);
|
|
133
134
|
}
|
package/ui/index.cjs
CHANGED
|
@@ -39,12 +39,6 @@ __export(index_exports, {
|
|
|
39
39
|
CircularProgress: () => CircularProgress,
|
|
40
40
|
Confirm: () => Confirm,
|
|
41
41
|
ConfirmRoot: () => ConfirmRoot,
|
|
42
|
-
DataView: () => DataView,
|
|
43
|
-
DataViewBody: () => DataViewBody,
|
|
44
|
-
DataViewFilters: () => DataViewFilters,
|
|
45
|
-
DataViewFooter: () => DataViewFooter,
|
|
46
|
-
DataViewHeader: () => DataViewHeader,
|
|
47
|
-
DataViewTh: () => DataViewTh,
|
|
48
42
|
DatePicker: () => DatePicker,
|
|
49
43
|
Divider: () => Divider,
|
|
50
44
|
Drawer: () => Drawer,
|
|
@@ -97,7 +91,6 @@ __export(index_exports, {
|
|
|
97
91
|
createGlobe: () => createGlobe,
|
|
98
92
|
toast: () => toast,
|
|
99
93
|
useAutoSkeletonRows: () => useAutoSkeletonRows,
|
|
100
|
-
useDataViewRuler: () => useDataViewRuler,
|
|
101
94
|
useRuler: () => useRuler,
|
|
102
95
|
useToast: () => useToast
|
|
103
96
|
});
|
|
@@ -137,7 +130,6 @@ var import_Tabs = require("./components/Tabs.jsx");
|
|
|
137
130
|
var import_Skeleton2 = require("./components/Skeleton.jsx");
|
|
138
131
|
var import_XTable = require("./components/XTable.jsx");
|
|
139
132
|
var import_Card = require("./components/Card.jsx");
|
|
140
|
-
var import_DataView = require("./components/DataView.jsx");
|
|
141
133
|
var import_FilePicker = __toESM(require("./components/FilePicker.jsx"), 1);
|
|
142
134
|
var import_Divider = __toESM(require("./components/Divider.jsx"), 1);
|
|
143
135
|
var import_InfoBadge = __toESM(require("./components/InfoBadge.jsx"), 1);
|
|
@@ -213,10 +205,3 @@ const Globe = import_Globe.default || import_Globe.Globe;
|
|
|
213
205
|
const createGlobe = import_Globe.createGlobe;
|
|
214
206
|
const useRuler = import_useRuler.useRuler;
|
|
215
207
|
const useAutoSkeletonRows = import_useRuler.useAutoSkeletonRows;
|
|
216
|
-
const DataView = import_DataView.DataView;
|
|
217
|
-
const DataViewHeader = import_DataView.DataViewHeader;
|
|
218
|
-
const DataViewFilters = import_DataView.DataViewFilters;
|
|
219
|
-
const DataViewBody = import_DataView.DataViewBody;
|
|
220
|
-
const DataViewTh = import_DataView.DataViewTh;
|
|
221
|
-
const DataViewFooter = import_DataView.DataViewFooter;
|
|
222
|
-
const useDataViewRuler = import_DataView.useDataViewRuler;
|
package/ui/index.js
CHANGED
|
@@ -34,7 +34,6 @@ import { Tabs as _Tabs } from './components/Tabs.jsx';
|
|
|
34
34
|
import { SkeletonText as _SkeletonText, SkeletonCard as _SkeletonCard, SkeletonRows as _SkeletonRows, SkeletonStats as _SkeletonStats } from './components/Skeleton.jsx';
|
|
35
35
|
import { XTable as _XTable, XThead as _XThead, XTbody as _XTbody, XTr as _XTr, XTh as _XTh, XTd as _XTd, SkeletonTable as _SkeletonTable } from './components/XTable.jsx';
|
|
36
36
|
import { PageShell as _PageShell, TableCard as _TableCard, TableCardFilters as _TableCardFilters, TableCardBody as _TableCardBody, TableCardFooter as _TableCardFooter, CardHdr as _CardHdr, StatCard as _StatCard, StatCardSkeleton as _StatCardSkeleton } from './components/Card.jsx';
|
|
37
|
-
import { DataView as _DataView, DataViewHeader as _DataViewHeader, DataViewFilters as _DataViewFilters, DataViewBody as _DataViewBody, DataViewTh as _DataViewTh, DataViewFooter as _DataViewFooter, useDataViewRuler as _useDataViewRuler } from './components/DataView.jsx';
|
|
38
37
|
|
|
39
38
|
import { default as _FilePicker } from './components/FilePicker.jsx';
|
|
40
39
|
import { default as _Divider } from './components/Divider.jsx';
|
|
@@ -112,10 +111,3 @@ export const Globe = _Globe || _GlobeNamed;
|
|
|
112
111
|
export const createGlobe = _createGlobe;
|
|
113
112
|
export const useRuler = _useRuler;
|
|
114
113
|
export const useAutoSkeletonRows = _useAutoSkeletonRows;
|
|
115
|
-
export const DataView = _DataView;
|
|
116
|
-
export const DataViewHeader = _DataViewHeader;
|
|
117
|
-
export const DataViewFilters = _DataViewFilters;
|
|
118
|
-
export const DataViewBody = _DataViewBody;
|
|
119
|
-
export const DataViewTh = _DataViewTh;
|
|
120
|
-
export const DataViewFooter = _DataViewFooter;
|
|
121
|
-
export const useDataViewRuler = _useDataViewRuler;
|
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef, useState, useEffect, useLayoutEffect, useRef, useCallback } from 'react';
|
|
2
|
-
import { Pagination } from './Pagination';
|
|
3
|
-
|
|
4
|
-
const DATAVIEW_STYLES = `
|
|
5
|
-
.cynx-dataview-body table tbody tr.cynx-tr:hover {
|
|
6
|
-
background: var(--hover-bg, rgba(0, 0, 0, 0.025));
|
|
7
|
-
}
|
|
8
|
-
.cynx-dataview-body table tr > th:first-child,
|
|
9
|
-
.cynx-dataview-body table tr > td:first-child {
|
|
10
|
-
padding-left: 24px;
|
|
11
|
-
}
|
|
12
|
-
.cynx-dataview-body table tr > th:last-child,
|
|
13
|
-
.cynx-dataview-body table tr > td:last-child {
|
|
14
|
-
padding-right: 24px;
|
|
15
|
-
}
|
|
16
|
-
`;
|
|
17
|
-
|
|
18
|
-
let _dv_style_id = 'cynx-dataview-styles';
|
|
19
|
-
function ensureDataViewStyles() {
|
|
20
|
-
if (typeof document === 'undefined') return;
|
|
21
|
-
if (document.getElementById(_dv_style_id)) return;
|
|
22
|
-
const tag = document.createElement('style');
|
|
23
|
-
tag.id = _dv_style_id;
|
|
24
|
-
tag.textContent = DATAVIEW_STYLES;
|
|
25
|
-
document.head.appendChild(tag);
|
|
26
|
-
}
|
|
27
|
-
if (typeof document !== 'undefined') ensureDataViewStyles();
|
|
28
|
-
|
|
29
|
-
export function DataView({ children, style = {}, className = '', ...props }) {
|
|
30
|
-
ensureDataViewStyles();
|
|
31
|
-
return (
|
|
32
|
-
<div
|
|
33
|
-
className={`cynx-dataview ${className}`.trim()}
|
|
34
|
-
style={{
|
|
35
|
-
flex: 1,
|
|
36
|
-
display: 'flex',
|
|
37
|
-
flexDirection: 'column',
|
|
38
|
-
height: '100%',
|
|
39
|
-
minHeight: 0,
|
|
40
|
-
overflow: 'hidden',
|
|
41
|
-
background: 'var(--bg, #f4f4f5)',
|
|
42
|
-
boxSizing: 'border-box',
|
|
43
|
-
...style,
|
|
44
|
-
}}
|
|
45
|
-
{...props}
|
|
46
|
-
>
|
|
47
|
-
{children}
|
|
48
|
-
</div>
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function DataViewHeader({ title, icon: Icon, badge, tabs, children, style = {}, className = '', ...props }) {
|
|
53
|
-
ensureDataViewStyles();
|
|
54
|
-
return (
|
|
55
|
-
<div
|
|
56
|
-
className={`cynx-dataview-header ${className}`.trim()}
|
|
57
|
-
style={{
|
|
58
|
-
flexShrink: 0,
|
|
59
|
-
display: 'flex',
|
|
60
|
-
alignItems: 'center',
|
|
61
|
-
justifyContent: 'space-between',
|
|
62
|
-
height: 52,
|
|
63
|
-
minHeight: 52,
|
|
64
|
-
padding: '0 24px',
|
|
65
|
-
borderBottom: '1px solid var(--border-light, #ebebf0)',
|
|
66
|
-
background: 'var(--bg, #f4f4f5)',
|
|
67
|
-
boxSizing: 'border-box',
|
|
68
|
-
...style,
|
|
69
|
-
}}
|
|
70
|
-
{...props}
|
|
71
|
-
>
|
|
72
|
-
<div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
|
|
73
|
-
{Icon && <Icon size={16} style={{ color: 'var(--primary-text, #0f111c)' }} />}
|
|
74
|
-
{title && (
|
|
75
|
-
<span style={{ fontSize: '.88rem', fontWeight: 600, color: 'var(--primary-text, #0f111c)', letterSpacing: '-.01em' }}>
|
|
76
|
-
{title}
|
|
77
|
-
</span>
|
|
78
|
-
)}
|
|
79
|
-
{badge}
|
|
80
|
-
{tabs && <div style={{ marginLeft: 6 }}>{tabs}</div>}
|
|
81
|
-
</div>
|
|
82
|
-
{children && (
|
|
83
|
-
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
|
84
|
-
{children}
|
|
85
|
-
</div>
|
|
86
|
-
)}
|
|
87
|
-
</div>
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export function DataViewFilters({ children, style = {}, className = '', ...props }) {
|
|
92
|
-
ensureDataViewStyles();
|
|
93
|
-
return (
|
|
94
|
-
<div
|
|
95
|
-
className={`cynx-dataview-filters ${className}`.trim()}
|
|
96
|
-
style={{
|
|
97
|
-
flexShrink: 0,
|
|
98
|
-
display: 'flex',
|
|
99
|
-
alignItems: 'center',
|
|
100
|
-
gap: 8,
|
|
101
|
-
height: 48,
|
|
102
|
-
minHeight: 48,
|
|
103
|
-
padding: '0 24px',
|
|
104
|
-
borderBottom: '1px solid var(--border-light, #ebebf0)',
|
|
105
|
-
background: 'var(--bg, #f4f4f5)',
|
|
106
|
-
boxSizing: 'border-box',
|
|
107
|
-
...style,
|
|
108
|
-
}}
|
|
109
|
-
{...props}
|
|
110
|
-
>
|
|
111
|
-
{children}
|
|
112
|
-
</div>
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export const DataViewBody = forwardRef(function DataViewBody({ children, style = {}, className = '', ...props }, ref) {
|
|
117
|
-
ensureDataViewStyles();
|
|
118
|
-
return (
|
|
119
|
-
<div
|
|
120
|
-
ref={ref}
|
|
121
|
-
className={`cynx-dataview-body ${className}`.trim()}
|
|
122
|
-
style={{
|
|
123
|
-
flex: 1,
|
|
124
|
-
overflowY: 'auto',
|
|
125
|
-
minHeight: 0,
|
|
126
|
-
padding: 0,
|
|
127
|
-
scrollbarWidth: 'thin',
|
|
128
|
-
scrollbarColor: 'var(--grey-2, #d7d8e0) transparent',
|
|
129
|
-
background: 'var(--bg, #f4f4f5)',
|
|
130
|
-
boxSizing: 'border-box',
|
|
131
|
-
...style,
|
|
132
|
-
}}
|
|
133
|
-
{...props}
|
|
134
|
-
>
|
|
135
|
-
{children}
|
|
136
|
-
</div>
|
|
137
|
-
);
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
export function DataViewTh({ children, style = {}, className = '', bg = 'var(--bg, #f4f4f5)', ...props }) {
|
|
141
|
-
ensureDataViewStyles();
|
|
142
|
-
return (
|
|
143
|
-
<th
|
|
144
|
-
className={className}
|
|
145
|
-
style={{
|
|
146
|
-
position: 'sticky',
|
|
147
|
-
top: 0,
|
|
148
|
-
zIndex: 10,
|
|
149
|
-
background: bg,
|
|
150
|
-
textAlign: 'left',
|
|
151
|
-
padding: '10px 10px',
|
|
152
|
-
fontSize: '.68rem',
|
|
153
|
-
fontWeight: 600,
|
|
154
|
-
textTransform: 'uppercase',
|
|
155
|
-
letterSpacing: '.06em',
|
|
156
|
-
color: 'var(--muted, #9b9daa)',
|
|
157
|
-
borderBottom: '1px solid var(--border-light, #ebebf0)',
|
|
158
|
-
boxSizing: 'border-box',
|
|
159
|
-
...style,
|
|
160
|
-
}}
|
|
161
|
-
{...props}
|
|
162
|
-
>
|
|
163
|
-
{children}
|
|
164
|
-
</th>
|
|
165
|
-
);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
export function DataViewFooter({ total = 0, page = 1, limit = 100, pages = 1, onChange, style = {}, className = '', ...props }) {
|
|
169
|
-
ensureDataViewStyles();
|
|
170
|
-
const from = total === 0 ? 0 : (page - 1) * limit + 1;
|
|
171
|
-
const to = Math.min(page * limit, total);
|
|
172
|
-
return (
|
|
173
|
-
<div
|
|
174
|
-
className={`cynx-dataview-footer ${className}`.trim()}
|
|
175
|
-
style={{
|
|
176
|
-
flexShrink: 0,
|
|
177
|
-
marginTop: 'auto',
|
|
178
|
-
display: 'flex',
|
|
179
|
-
alignItems: 'center',
|
|
180
|
-
justifyContent: 'space-between',
|
|
181
|
-
height: 44,
|
|
182
|
-
minHeight: 44,
|
|
183
|
-
padding: '0 24px',
|
|
184
|
-
borderTop: '1px solid var(--border-light, #ebebf0)',
|
|
185
|
-
background: 'var(--bg, #f4f4f5)',
|
|
186
|
-
fontSize: '.78rem',
|
|
187
|
-
color: 'var(--muted, #9b9daa)',
|
|
188
|
-
boxSizing: 'border-box',
|
|
189
|
-
...style,
|
|
190
|
-
}}
|
|
191
|
-
{...props}
|
|
192
|
-
>
|
|
193
|
-
<span style={{ whiteSpace: 'nowrap', flexShrink: 0 }}>
|
|
194
|
-
{total === 0 ? '0 записей' : `${from}–${to} из ${total}`}
|
|
195
|
-
</span>
|
|
196
|
-
<Pagination page={page} pages={pages} onChange={onChange} size="sm" />
|
|
197
|
-
</div>
|
|
198
|
-
);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
export function useDataViewRuler({ rowHeight = 52, minRows = 3, maxRows = 100 } = {}) {
|
|
202
|
-
const containerRef = useRef(null);
|
|
203
|
-
const [rows, setRows] = useState(15);
|
|
204
|
-
|
|
205
|
-
const calculate = useCallback(() => {
|
|
206
|
-
if (!containerRef.current) return;
|
|
207
|
-
const clientHeight = containerRef.current.clientHeight;
|
|
208
|
-
if (clientHeight <= 0) return;
|
|
209
|
-
|
|
210
|
-
const thead = containerRef.current.querySelector('thead');
|
|
211
|
-
const theadHeight = thead ? thead.offsetHeight : 37;
|
|
212
|
-
|
|
213
|
-
const firstRow = containerRef.current.querySelector('tbody tr');
|
|
214
|
-
const actualRowHeight = firstRow && firstRow.offsetHeight > 0 ? firstRow.offsetHeight : rowHeight;
|
|
215
|
-
|
|
216
|
-
const avail = clientHeight - theadHeight;
|
|
217
|
-
if (avail > 0) {
|
|
218
|
-
const calculated = Math.floor(avail / actualRowHeight);
|
|
219
|
-
const nextRows = Math.max(minRows, Math.min(maxRows, calculated));
|
|
220
|
-
setRows((prev) => (prev !== nextRows ? nextRows : prev));
|
|
221
|
-
}
|
|
222
|
-
}, [rowHeight, minRows, maxRows]);
|
|
223
|
-
|
|
224
|
-
useLayoutEffect(() => {
|
|
225
|
-
calculate();
|
|
226
|
-
}, [calculate]);
|
|
227
|
-
|
|
228
|
-
useEffect(() => {
|
|
229
|
-
if (!containerRef.current) return;
|
|
230
|
-
let observer = null;
|
|
231
|
-
if (typeof ResizeObserver !== 'undefined') {
|
|
232
|
-
observer = new ResizeObserver(() => {
|
|
233
|
-
calculate();
|
|
234
|
-
});
|
|
235
|
-
observer.observe(containerRef.current);
|
|
236
|
-
}
|
|
237
|
-
window.addEventListener('resize', calculate);
|
|
238
|
-
return () => {
|
|
239
|
-
if (observer) observer.disconnect();
|
|
240
|
-
window.removeEventListener('resize', calculate);
|
|
241
|
-
};
|
|
242
|
-
}, [calculate]);
|
|
243
|
-
|
|
244
|
-
return { containerRef, rows };
|
|
245
|
-
}
|