cynx-lib 1.3.102 → 1.3.103

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.
Files changed (46) hide show
  1. package/gen.js +77 -77
  2. package/package.json +1 -1
  3. package/ui/components/ActionsMenu.jsx +357 -357
  4. package/ui/components/Drawer.jsx +208 -208
  5. package/ui/components/Globe.jsx +764 -764
  6. package/ui/components/HoverCard.jsx +85 -85
  7. package/ui/components/Pagination.jsx +145 -145
  8. package/ui/components/PrivacyBlur.jsx +603 -603
  9. package/ui/components/XTable.jsx +112 -112
  10. package/ui/components/useRuler.jsx +94 -0
  11. package/ui/index.cjs +5 -0
  12. package/ui/index.js +3 -0
  13. package/utils/index.js +24 -24
  14. package/utils/utils/duration.js +139 -139
  15. package/utils/utils/oidc.js +214 -214
  16. package/utils/utils/realtime.js +1634 -1634
  17. package/utils/utils/server.js +371 -371
  18. package/utils/utils/session.js +131 -131
  19. package/utils/utils/session_manager.js +580 -580
  20. package/utils/utils/sso_manager.js +702 -702
  21. package/utils/utils/storage.js +393 -393
  22. package/utils/utils/ui.js +111 -111
  23. package/vue/components/Badge.vue +79 -79
  24. package/vue/components/Button.vue +209 -209
  25. package/vue/components/Checkbox.vue +103 -103
  26. package/vue/components/CircularProgress.vue +383 -383
  27. package/vue/components/Divider.vue +94 -94
  28. package/vue/components/Drawer.vue +243 -243
  29. package/vue/components/InfoBadge.vue +223 -223
  30. package/vue/components/Input.vue +341 -341
  31. package/vue/components/LinearProgress.vue +268 -268
  32. package/vue/components/Modal.vue +226 -226
  33. package/vue/components/Pagination.vue +199 -199
  34. package/vue/components/Select.vue +713 -713
  35. package/vue/components/Sidebar.vue +955 -955
  36. package/vue/components/Skeleton.vue +91 -91
  37. package/vue/components/Spinner.vue +263 -263
  38. package/vue/components/StatusTag.vue +89 -89
  39. package/vue/components/TabBar.vue +176 -176
  40. package/vue/components/Table.vue +388 -388
  41. package/vue/components/TimePicker.vue +399 -399
  42. package/vue/components/Toggle.vue +115 -115
  43. package/vue/components/XTable.vue +140 -140
  44. package/vue/composables/useAutoSkeletonRows.ts +71 -71
  45. package/vue/index.d.ts +67 -67
  46. package/vue/index.js +86 -86
@@ -1,112 +1,112 @@
1
- const TABLE_STYLES = `
2
- table.cynx-table {
3
- width: 100%;
4
- border-collapse: collapse;
5
- table-layout: fixed;
6
- font-size: .8rem;
7
- }
8
- .cynx-tr {
9
- border-bottom: 1px solid var(--border-light, #ebebf0);
10
- transition: background .12s;
11
- }
12
- tbody tr.cynx-tr:last-child,
13
- .cynx-table tbody tr:last-child {
14
- border-bottom: none;
15
- }
16
- @keyframes shimmer{0%{background-position:-600px 0}100%{background-position:600px 0}}
17
- @keyframes sk-shimmer{0%{background-position:-600px 0}100%{background-position:600px 0}}
18
- `;
19
-
20
- let _tbl_style_id = 'cynx-table-styles';
21
- function ensureTableStyles() {
22
- if (typeof document === 'undefined') return;
23
- if (document.getElementById(_tbl_style_id)) return;
24
- const tag = document.createElement('style');
25
- tag.id = _tbl_style_id;
26
- tag.textContent = TABLE_STYLES;
27
- document.head.appendChild(tag);
28
- }
29
- if (typeof document !== 'undefined') ensureTableStyles();
30
-
31
- export function XTable({ children, style, className = '', ...props }) {
32
- ensureTableStyles();
33
- return (
34
- <table
35
- className={`cynx-table ${className}`.trim()}
36
- style={{ width: '100%', borderCollapse: 'collapse', tableLayout: 'fixed', fontSize: '.8rem', ...style }}
37
- {...props}
38
- >
39
- {children}
40
- </table>
41
- );
42
- }
43
-
44
- export function XThead({ children, ...props }) { return <thead {...props}>{children}</thead>; }
45
- export function XTbody({ children, ...props }) { return <tbody {...props}>{children}</tbody>; }
46
-
47
- export function XTr({ children, onClick, style, className = '', ...props }) {
48
- ensureTableStyles();
49
- return (
50
- <tr
51
- onClick={onClick}
52
- className={`cynx-tr ${className}`.trim()}
53
- style={{
54
- cursor: onClick ? 'pointer' : undefined,
55
- ...style,
56
- }}
57
- {...props}
58
- >
59
- {children}
60
- </tr>
61
- );
62
- }
63
-
64
- export function XTh({ children, style, className = '', ...props }) {
65
- return (
66
- <th
67
- className={className}
68
- style={{
69
- textAlign: 'left',
70
- padding: '8px 10px',
71
- fontSize: '.68rem',
72
- fontWeight: 600,
73
- textTransform: 'uppercase',
74
- letterSpacing: '.06em',
75
- color: 'var(--muted, #9b9daa)',
76
- borderBottom: '1px solid var(--border-light, #ebebf0)',
77
- ...style,
78
- }}
79
- {...props}
80
- >
81
- {children}
82
- </th>
83
- );
84
- }
85
-
86
- export function XTd({ children, style, className = '', colSpan, ...props }) {
87
- return (
88
- <td
89
- className={className}
90
- style={{ padding: '9px 10px', verticalAlign: 'middle', color: 'var(--primary-text, #0f111c)', ...style }}
91
- colSpan={colSpan}
92
- {...props}
93
- >
94
- {children}
95
- </td>
96
- );
97
- }
98
-
99
- export function SkeletonTable({ rows = 6, cols = 5 }) {
100
- ensureTableStyles();
101
- return (
102
- <div>
103
- {Array.from({ length: rows }).map((_, i) => (
104
- <div key={i} style={{ display: 'flex', gap: 8, padding: '8px 10px', borderBottom: i === rows - 1 ? 'none' : '1px solid var(--border-light, #ebebf0)' }}>
105
- {Array.from({ length: cols }).map((_, j) => (
106
- <div key={j} style={{ height: 12, flex: 1, 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)' }} />
107
- ))}
108
- </div>
109
- ))}
110
- </div>
111
- );
112
- }
1
+ const TABLE_STYLES = `
2
+ table.cynx-table {
3
+ width: 100%;
4
+ border-collapse: collapse;
5
+ table-layout: fixed;
6
+ font-size: .8rem;
7
+ }
8
+ .cynx-tr {
9
+ border-bottom: 1px solid var(--border-light, #ebebf0);
10
+ transition: background .12s;
11
+ }
12
+ tbody tr.cynx-tr:last-child,
13
+ .cynx-table tbody tr:last-child {
14
+ border-bottom: none;
15
+ }
16
+ @keyframes shimmer{0%{background-position:-600px 0}100%{background-position:600px 0}}
17
+ @keyframes sk-shimmer{0%{background-position:-600px 0}100%{background-position:600px 0}}
18
+ `;
19
+
20
+ let _tbl_style_id = 'cynx-table-styles';
21
+ function ensureTableStyles() {
22
+ if (typeof document === 'undefined') return;
23
+ if (document.getElementById(_tbl_style_id)) return;
24
+ const tag = document.createElement('style');
25
+ tag.id = _tbl_style_id;
26
+ tag.textContent = TABLE_STYLES;
27
+ document.head.appendChild(tag);
28
+ }
29
+ if (typeof document !== 'undefined') ensureTableStyles();
30
+
31
+ export function XTable({ children, style, className = '', ...props }) {
32
+ ensureTableStyles();
33
+ return (
34
+ <table
35
+ className={`cynx-table ${className}`.trim()}
36
+ style={{ width: '100%', borderCollapse: 'collapse', tableLayout: 'fixed', fontSize: '.8rem', ...style }}
37
+ {...props}
38
+ >
39
+ {children}
40
+ </table>
41
+ );
42
+ }
43
+
44
+ export function XThead({ children, ...props }) { return <thead {...props}>{children}</thead>; }
45
+ export function XTbody({ children, ...props }) { return <tbody {...props}>{children}</tbody>; }
46
+
47
+ export function XTr({ children, onClick, style, className = '', ...props }) {
48
+ ensureTableStyles();
49
+ return (
50
+ <tr
51
+ onClick={onClick}
52
+ className={`cynx-tr ${className}`.trim()}
53
+ style={{
54
+ cursor: onClick ? 'pointer' : undefined,
55
+ ...style,
56
+ }}
57
+ {...props}
58
+ >
59
+ {children}
60
+ </tr>
61
+ );
62
+ }
63
+
64
+ export function XTh({ children, style, className = '', ...props }) {
65
+ return (
66
+ <th
67
+ className={className}
68
+ style={{
69
+ textAlign: 'left',
70
+ padding: '8px 10px',
71
+ fontSize: '.68rem',
72
+ fontWeight: 600,
73
+ textTransform: 'uppercase',
74
+ letterSpacing: '.06em',
75
+ color: 'var(--muted, #9b9daa)',
76
+ borderBottom: '1px solid var(--border-light, #ebebf0)',
77
+ ...style,
78
+ }}
79
+ {...props}
80
+ >
81
+ {children}
82
+ </th>
83
+ );
84
+ }
85
+
86
+ export function XTd({ children, style, className = '', colSpan, ...props }) {
87
+ return (
88
+ <td
89
+ className={className}
90
+ style={{ padding: '9px 10px', verticalAlign: 'middle', color: 'var(--primary-text, #0f111c)', ...style }}
91
+ colSpan={colSpan}
92
+ {...props}
93
+ >
94
+ {children}
95
+ </td>
96
+ );
97
+ }
98
+
99
+ export function SkeletonTable({ rows = 6, cols = 5 }) {
100
+ ensureTableStyles();
101
+ return (
102
+ <div>
103
+ {Array.from({ length: rows }).map((_, i) => (
104
+ <div key={i} style={{ display: 'flex', gap: 8, padding: '8px 10px', borderBottom: i === rows - 1 ? 'none' : '1px solid var(--border-light, #ebebf0)' }}>
105
+ {Array.from({ length: cols }).map((_, j) => (
106
+ <div key={j} style={{ height: 12, flex: 1, 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)' }} />
107
+ ))}
108
+ </div>
109
+ ))}
110
+ </div>
111
+ );
112
+ }
@@ -0,0 +1,94 @@
1
+ import { useState, useLayoutEffect, useEffect, useRef, useCallback } from 'react';
2
+
3
+ /**
4
+ * Universal display and viewport measurement hook (Ruler).
5
+ * Measures element rect relative to window viewport, computes remaining available height,
6
+ * and dynamically calculates rows for grid / table / skeleton layouts.
7
+ *
8
+ * @param {Object|number} arg1 - Options object or rowHeight (for backward compatibility)
9
+ * @param {number} [arg2] - initialOffset (for backward compatibility)
10
+ */
11
+ export function useRuler(arg1 = 51, arg2 = 240) {
12
+ const isObject = arg1 && typeof arg1 === 'object' && !Array.isArray(arg1);
13
+ const options = isObject ? arg1 : {};
14
+ const rowHeight = isObject ? (options.rowHeight ?? 51) : (typeof arg1 === 'number' ? arg1 : 51);
15
+ const initialOffset = isObject ? (options.initialOffset ?? 240) : (typeof arg2 === 'number' ? arg2 : 240);
16
+ const bottomBuffer = options.bottomBuffer ?? 24;
17
+ const minLimit = options.minHeight ?? 200;
18
+ const maxLimit = options.maxHeight ?? null;
19
+ const minRows = options.minRows ?? 3;
20
+ const maxRows = options.maxRows ?? 25;
21
+
22
+ const containerRef = useRef(null);
23
+
24
+ const [availableHeight, setAvailableHeight] = useState(() => {
25
+ if (typeof window === 'undefined') return minLimit;
26
+ return Math.max(minLimit, window.innerHeight - initialOffset - bottomBuffer);
27
+ });
28
+
29
+ const [rows, setRows] = useState(() => {
30
+ if (typeof window === 'undefined') return 8;
31
+ return Math.max(minRows, Math.floor((window.innerHeight - initialOffset) / rowHeight));
32
+ });
33
+
34
+ const calculate = useCallback(() => {
35
+ if (!containerRef.current) return;
36
+ const rect = containerRef.current.getBoundingClientRect();
37
+
38
+ let avail = window.innerHeight - rect.top - bottomBuffer;
39
+ if (avail < minLimit) avail = minLimit;
40
+ if (maxLimit && avail > maxLimit) avail = maxLimit;
41
+ const roundedAvail = Math.round(avail);
42
+
43
+ // Guard against infinite re-renders from subpixel fluctuations
44
+ setAvailableHeight((prev) => (Math.abs(prev - roundedAvail) > 1 ? roundedAvail : prev));
45
+
46
+ const thead = containerRef.current.querySelector('thead');
47
+ const theadHeight = thead ? thead.offsetHeight : 0;
48
+ const cardHeader =
49
+ containerRef.current.firstElementChild !== thead?.parentElement &&
50
+ !containerRef.current.firstElementChild?.contains(thead)
51
+ ? containerRef.current.querySelector(':scope > div:first-child')
52
+ : null;
53
+ const cardHeaderHeight = cardHeader ? cardHeader.offsetHeight : 0;
54
+
55
+ const bodyAvailable = roundedAvail - theadHeight - cardHeaderHeight;
56
+ if (bodyAvailable > 0) {
57
+ const calculated = Math.floor(bodyAvailable / rowHeight);
58
+ const nextRows = Math.max(minRows, Math.min(maxRows, calculated));
59
+ setRows((prev) => (prev !== nextRows ? nextRows : prev));
60
+ }
61
+ }, [rowHeight, bottomBuffer, minLimit, maxLimit, minRows, maxRows]);
62
+
63
+ useLayoutEffect(() => {
64
+ calculate();
65
+ }, [calculate]);
66
+
67
+ useEffect(() => {
68
+ calculate();
69
+ window.addEventListener('resize', calculate);
70
+
71
+ let observer = null;
72
+ if (typeof ResizeObserver !== 'undefined' && containerRef.current?.parentElement) {
73
+ observer = new ResizeObserver(() => {
74
+ calculate();
75
+ });
76
+ observer.observe(containerRef.current.parentElement);
77
+ }
78
+
79
+ return () => {
80
+ window.removeEventListener('resize', calculate);
81
+ if (observer) observer.disconnect();
82
+ };
83
+ }, [calculate]);
84
+
85
+ return {
86
+ containerRef,
87
+ availableHeight,
88
+ minHeight: availableHeight,
89
+ rows,
90
+ };
91
+ }
92
+
93
+ export const useAutoSkeletonRows = useRuler;
94
+ export default useRuler;
package/ui/index.cjs CHANGED
@@ -90,6 +90,8 @@ __export(index_exports, {
90
90
  confirm: () => confirm,
91
91
  createGlobe: () => createGlobe,
92
92
  toast: () => toast,
93
+ useAutoSkeletonRows: () => useAutoSkeletonRows,
94
+ useRuler: () => useRuler,
93
95
  useToast: () => useToast
94
96
  });
95
97
  module.exports = __toCommonJS(index_exports);
@@ -136,6 +138,7 @@ var import_Sidebar = __toESM(require("./components/Sidebar.jsx"), 1);
136
138
  var import_LoginPage = __toESM(require("./components/LoginPage.jsx"), 1);
137
139
  var import_PrivacyBlur = __toESM(require("./components/PrivacyBlur.jsx"), 1);
138
140
  var import_Globe = __toESM(require("./components/Globe.jsx"), 1);
141
+ var import_useRuler = require("./components/useRuler.jsx");
139
142
  const Layout = import_Layout.default;
140
143
  const Sidebar = import_Sidebar.default;
141
144
  const LoginPage = import_LoginPage.default;
@@ -200,3 +203,5 @@ const StatCardSkeleton = import_Card.StatCardSkeleton;
200
203
  const PrivacyBlur = import_PrivacyBlur.default;
201
204
  const Globe = import_Globe.default || import_Globe.Globe;
202
205
  const createGlobe = import_Globe.createGlobe;
206
+ const useRuler = import_useRuler.useRuler;
207
+ const useAutoSkeletonRows = import_useRuler.useAutoSkeletonRows;
package/ui/index.js CHANGED
@@ -43,6 +43,7 @@ import { default as _Sidebar } from './components/Sidebar.jsx';
43
43
  import { default as _LoginPage } from './components/LoginPage.jsx';
44
44
  import { default as _PrivacyBlur } from './components/PrivacyBlur.jsx';
45
45
  import { default as _Globe, createGlobe as _createGlobe, Globe as _GlobeNamed } from './components/Globe.jsx';
46
+ import { useRuler as _useRuler, useAutoSkeletonRows as _useAutoSkeletonRows } from './components/useRuler.jsx';
46
47
 
47
48
  export const Layout = _Layout;
48
49
  export const Sidebar = _Sidebar;
@@ -108,3 +109,5 @@ export const StatCardSkeleton = _StatCardSkeleton;
108
109
  export const PrivacyBlur = _PrivacyBlur;
109
110
  export const Globe = _Globe || _GlobeNamed;
110
111
  export const createGlobe = _createGlobe;
112
+ export const useRuler = _useRuler;
113
+ export const useAutoSkeletonRows = _useAutoSkeletonRows;
package/utils/index.js CHANGED
@@ -1,24 +1,24 @@
1
- // cynx/utils — shared utility functions
2
- export * from './utils/uid.js';
3
- export * from './utils/realtime.js';
4
- export * from './utils/tz.js';
5
- export * from './utils/oidc.js';
6
- export * from './utils/storage.js';
7
- export * from './utils/duration.js';
8
- export * from './utils/session.js';
9
- export * from './utils/session_manager.js';
10
- export * from './utils/sso_manager.js';
11
- export * from './utils/ui.js';
12
- export * from './utils/db.js';
13
-
14
- export { default as uidUtil } from './utils/uid.js';
15
- export { default as realtimeUtil } from './utils/realtime.js';
16
- export { default as tzUtil } from './utils/tz.js';
17
- export { default as oidcUtil } from './utils/oidc.js';
18
- export { default as storageUtil } from './utils/storage.js';
19
- export { default as durationUtil } from './utils/duration.js';
20
- export { default as sessionUtil } from './utils/session.js';
21
- export { default as sessionManagerUtil } from './utils/session_manager.js';
22
- export { default as ssoManagerUtil } from './utils/sso_manager.js';
23
- export { default as uiUtil } from './utils/ui.js';
24
- export { default as dbUtil } from './utils/db.js';
1
+ // cynx/utils — shared utility functions
2
+ export * from './utils/uid.js';
3
+ export * from './utils/realtime.js';
4
+ export * from './utils/tz.js';
5
+ export * from './utils/oidc.js';
6
+ export * from './utils/storage.js';
7
+ export * from './utils/duration.js';
8
+ export * from './utils/session.js';
9
+ export * from './utils/session_manager.js';
10
+ export * from './utils/sso_manager.js';
11
+ export * from './utils/ui.js';
12
+ export * from './utils/db.js';
13
+
14
+ export { default as uidUtil } from './utils/uid.js';
15
+ export { default as realtimeUtil } from './utils/realtime.js';
16
+ export { default as tzUtil } from './utils/tz.js';
17
+ export { default as oidcUtil } from './utils/oidc.js';
18
+ export { default as storageUtil } from './utils/storage.js';
19
+ export { default as durationUtil } from './utils/duration.js';
20
+ export { default as sessionUtil } from './utils/session.js';
21
+ export { default as sessionManagerUtil } from './utils/session_manager.js';
22
+ export { default as ssoManagerUtil } from './utils/sso_manager.js';
23
+ export { default as uiUtil } from './utils/ui.js';
24
+ export { default as dbUtil } from './utils/db.js';