cynx-lib 1.3.99 → 1.3.101

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 (45) hide show
  1. package/gen.js +77 -77
  2. package/package.json +5 -1
  3. package/ui/components/ActionsMenu.jsx +357 -357
  4. package/ui/components/Drawer.jsx +208 -208
  5. package/ui/components/HoverCard.jsx +85 -85
  6. package/ui/components/Pagination.jsx +145 -145
  7. package/ui/components/PrivacyBlur.jsx +603 -603
  8. package/ui/components/XTable.jsx +112 -112
  9. package/utils/index.cjs +5 -0
  10. package/utils/index.js +23 -21
  11. package/utils/utils/duration.js +139 -139
  12. package/utils/utils/oidc.js +214 -214
  13. package/utils/utils/realtime.js +1634 -1634
  14. package/utils/utils/server.js +371 -371
  15. package/utils/utils/session.js +131 -131
  16. package/utils/utils/session_manager.cjs +17 -11
  17. package/utils/utils/session_manager.js +35 -29
  18. package/utils/utils/sso_manager.cjs +621 -0
  19. package/utils/utils/sso_manager.js +702 -0
  20. package/utils/utils/storage.js +393 -393
  21. package/utils/utils/ui.js +111 -111
  22. package/vue/components/Badge.vue +79 -79
  23. package/vue/components/Button.vue +209 -209
  24. package/vue/components/Checkbox.vue +103 -103
  25. package/vue/components/CircularProgress.vue +383 -383
  26. package/vue/components/Divider.vue +94 -94
  27. package/vue/components/Drawer.vue +243 -243
  28. package/vue/components/InfoBadge.vue +223 -223
  29. package/vue/components/Input.vue +341 -341
  30. package/vue/components/LinearProgress.vue +268 -268
  31. package/vue/components/Modal.vue +226 -226
  32. package/vue/components/Pagination.vue +199 -199
  33. package/vue/components/Select.vue +713 -713
  34. package/vue/components/Sidebar.vue +955 -955
  35. package/vue/components/Skeleton.vue +91 -91
  36. package/vue/components/Spinner.vue +263 -263
  37. package/vue/components/StatusTag.vue +89 -89
  38. package/vue/components/TabBar.vue +176 -176
  39. package/vue/components/Table.vue +388 -388
  40. package/vue/components/TimePicker.vue +399 -399
  41. package/vue/components/Toggle.vue +115 -115
  42. package/vue/components/XTable.vue +140 -140
  43. package/vue/composables/useAutoSkeletonRows.ts +71 -71
  44. package/vue/index.d.ts +67 -67
  45. package/vue/index.js +86 -86
@@ -1,208 +1,208 @@
1
- import React, { useState, useEffect, useRef } from 'react';
2
- import { createPortal } from 'react-dom';
3
- import { X } from 'lucide-react';
4
-
5
- const DRAWER_STYLES = `
6
- @keyframes cynxDrawerFadeIn { from { opacity: 0; } to { opacity: 1; } }
7
- @keyframes cynxDrawerFadeOut { from { opacity: 1; } to { opacity: 0; } }
8
- @keyframes cynxDrawerSlideInRight { from { transform: translateX(100%); } to { transform: translateX(0); } }
9
- @keyframes cynxDrawerSlideOutRight { from { transform: translateX(0); } to { transform: translateX(100%); } }
10
- @keyframes cynxDrawerSlideInLeft { from { transform: translateX(-100%); } to { transform: translateX(0); } }
11
- @keyframes cynxDrawerSlideOutLeft { from { transform: translateX(0); } to { transform: translateX(-100%); } }
12
- `;
13
-
14
- let _drawer_id = 'cynx-drawer-styles';
15
- function ensureDrawerStyles() {
16
- if (typeof document === 'undefined') return;
17
- if (document.getElementById(_drawer_id)) return;
18
- const tag = document.createElement('style');
19
- tag.id = _drawer_id;
20
- tag.textContent = DRAWER_STYLES;
21
- document.head.appendChild(tag);
22
- }
23
-
24
- export function Drawer({
25
- open = false,
26
- onClose,
27
- title = '',
28
- description = '',
29
- width = 560,
30
- side = 'right',
31
- showClose = true,
32
- children,
33
- footer,
34
- header,
35
- style = {},
36
- bodyStyle = {},
37
- }) {
38
- const [closing, setClosing] = useState(false);
39
-
40
- useEffect(() => {
41
- ensureDrawerStyles();
42
- }, []);
43
-
44
- const handleClose = () => {
45
- if (closing) return;
46
- setClosing(true);
47
- setTimeout(() => {
48
- setClosing(false);
49
- onClose?.();
50
- }, 260);
51
- };
52
-
53
- useEffect(() => {
54
- if (typeof document === 'undefined') return;
55
- const handleKeydown = (e) => {
56
- if (e.key === 'Escape' && open) handleClose();
57
- };
58
- if (open) {
59
- document.body.style.overflow = 'hidden';
60
- window.addEventListener('keydown', handleKeydown);
61
- } else {
62
- document.body.style.overflow = '';
63
- window.removeEventListener('keydown', handleKeydown);
64
- }
65
- return () => {
66
- document.body.style.overflow = '';
67
- window.removeEventListener('keydown', handleKeydown);
68
- };
69
- }, [open]);
70
-
71
- if (!open && !closing) return null;
72
- if (typeof document === 'undefined') return null;
73
-
74
- const resolvedWidth = typeof width === 'number' ? `${width}px` : width;
75
- const slideInAnim = side === 'left' ? 'cynxDrawerSlideInLeft' : 'cynxDrawerSlideInRight';
76
- const slideOutAnim = side === 'left' ? 'cynxDrawerSlideOutLeft' : 'cynxDrawerSlideOutRight';
77
-
78
- return createPortal(
79
- <div
80
- style={{
81
- position: 'fixed',
82
- inset: 0,
83
- background: 'rgba(20, 22, 41, .45)',
84
- zIndex: 8500,
85
- display: 'flex',
86
- justifyContent: side === 'left' ? 'flex-start' : 'flex-end',
87
- animation: `${closing ? 'cynxDrawerFadeOut' : 'cynxDrawerFadeIn'} .26s ease forwards`,
88
- }}
89
- onMouseDown={(e) => {
90
- if (e.target === e.currentTarget) handleClose();
91
- }}
92
- >
93
- <div
94
- style={{
95
- background: 'var(--surface, #ffffff)',
96
- borderLeft: side === 'right' ? '1px solid var(--border, var(--bd, #e2e8f0))' : 'none',
97
- borderRight: side === 'left' ? '1px solid var(--border, var(--bd, #e2e8f0))' : 'none',
98
- width: resolvedWidth,
99
- maxWidth: '100vw',
100
- height: '100%',
101
- boxShadow: 'var(--shadow-lg, 0 20px 60px rgba(0, 0, 0, .25))',
102
- display: 'flex',
103
- flexDirection: 'column',
104
- overflow: 'hidden',
105
- animation: `${closing ? slideOutAnim : slideInAnim} .26s cubic-bezier(.16, 1, .3, 1) forwards`,
106
- ...style,
107
- }}
108
- onMouseDown={(e) => e.stopPropagation()}
109
- >
110
- {/* Header */}
111
- <div
112
- style={{
113
- display: 'flex',
114
- alignItems: 'center',
115
- justifyContent: 'space-between',
116
- padding: '16px 20px',
117
- borderBottom: '1px solid var(--border-light, #ebebf0)',
118
- flexShrink: 0,
119
- }}
120
- >
121
- {header ? (
122
- header
123
- ) : (
124
- <div style={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
125
- <span
126
- style={{
127
- fontSize: '1rem',
128
- fontWeight: 700,
129
- letterSpacing: '-.01em',
130
- color: 'var(--t, var(--primary-text, #0f111c))',
131
- }}
132
- >
133
- {{ title }}
134
- </span>
135
- {description && (
136
- <span
137
- style={{
138
- fontSize: '.75rem',
139
- color: 'var(--muted, #797b8d)',
140
- }}
141
- >
142
- {description}
143
- </span>
144
- )}
145
- </div>
146
- )}
147
-
148
- {showClose && (
149
- <button
150
- type="button"
151
- style={{
152
- background: 'none',
153
- border: 'none',
154
- cursor: 'pointer',
155
- padding: '6px',
156
- borderRadius: '6px',
157
- color: 'var(--muted, #797b8d)',
158
- display: 'flex',
159
- alignItems: 'center',
160
- justifyContent: 'center',
161
- transition: 'all .14s',
162
- }}
163
- onClick={handleClose}
164
- >
165
- <X size={18} />
166
- </button>
167
- )}
168
- </div>
169
-
170
- {/* Body */}
171
- <div
172
- className="custom-scrollbar"
173
- style={{
174
- padding: '20px',
175
- overflowX: 'hidden',
176
- overflowY: 'auto',
177
- flex: '1 1 auto',
178
- minHeight: 0,
179
- color: 'var(--t, var(--primary-text, #0f111c))',
180
- ...bodyStyle,
181
- }}
182
- >
183
- {children}
184
- </div>
185
-
186
- {/* Footer */}
187
- {footer && (
188
- <div
189
- style={{
190
- display: 'flex',
191
- justifyContent: 'flex-end',
192
- gap: 8,
193
- padding: '14px 20px',
194
- borderTop: '1px solid var(--border-light, #ebebf0)',
195
- background: 'var(--grey-1, #f5f5f8)',
196
- flexShrink: 0,
197
- }}
198
- >
199
- {footer}
200
- </div>
201
- )}
202
- </div>
203
- </div>,
204
- document.body
205
- );
206
- }
207
-
208
- export default Drawer;
1
+ import React, { useState, useEffect, useRef } from 'react';
2
+ import { createPortal } from 'react-dom';
3
+ import { X } from 'lucide-react';
4
+
5
+ const DRAWER_STYLES = `
6
+ @keyframes cynxDrawerFadeIn { from { opacity: 0; } to { opacity: 1; } }
7
+ @keyframes cynxDrawerFadeOut { from { opacity: 1; } to { opacity: 0; } }
8
+ @keyframes cynxDrawerSlideInRight { from { transform: translateX(100%); } to { transform: translateX(0); } }
9
+ @keyframes cynxDrawerSlideOutRight { from { transform: translateX(0); } to { transform: translateX(100%); } }
10
+ @keyframes cynxDrawerSlideInLeft { from { transform: translateX(-100%); } to { transform: translateX(0); } }
11
+ @keyframes cynxDrawerSlideOutLeft { from { transform: translateX(0); } to { transform: translateX(-100%); } }
12
+ `;
13
+
14
+ let _drawer_id = 'cynx-drawer-styles';
15
+ function ensureDrawerStyles() {
16
+ if (typeof document === 'undefined') return;
17
+ if (document.getElementById(_drawer_id)) return;
18
+ const tag = document.createElement('style');
19
+ tag.id = _drawer_id;
20
+ tag.textContent = DRAWER_STYLES;
21
+ document.head.appendChild(tag);
22
+ }
23
+
24
+ export function Drawer({
25
+ open = false,
26
+ onClose,
27
+ title = '',
28
+ description = '',
29
+ width = 560,
30
+ side = 'right',
31
+ showClose = true,
32
+ children,
33
+ footer,
34
+ header,
35
+ style = {},
36
+ bodyStyle = {},
37
+ }) {
38
+ const [closing, setClosing] = useState(false);
39
+
40
+ useEffect(() => {
41
+ ensureDrawerStyles();
42
+ }, []);
43
+
44
+ const handleClose = () => {
45
+ if (closing) return;
46
+ setClosing(true);
47
+ setTimeout(() => {
48
+ setClosing(false);
49
+ onClose?.();
50
+ }, 260);
51
+ };
52
+
53
+ useEffect(() => {
54
+ if (typeof document === 'undefined') return;
55
+ const handleKeydown = (e) => {
56
+ if (e.key === 'Escape' && open) handleClose();
57
+ };
58
+ if (open) {
59
+ document.body.style.overflow = 'hidden';
60
+ window.addEventListener('keydown', handleKeydown);
61
+ } else {
62
+ document.body.style.overflow = '';
63
+ window.removeEventListener('keydown', handleKeydown);
64
+ }
65
+ return () => {
66
+ document.body.style.overflow = '';
67
+ window.removeEventListener('keydown', handleKeydown);
68
+ };
69
+ }, [open]);
70
+
71
+ if (!open && !closing) return null;
72
+ if (typeof document === 'undefined') return null;
73
+
74
+ const resolvedWidth = typeof width === 'number' ? `${width}px` : width;
75
+ const slideInAnim = side === 'left' ? 'cynxDrawerSlideInLeft' : 'cynxDrawerSlideInRight';
76
+ const slideOutAnim = side === 'left' ? 'cynxDrawerSlideOutLeft' : 'cynxDrawerSlideOutRight';
77
+
78
+ return createPortal(
79
+ <div
80
+ style={{
81
+ position: 'fixed',
82
+ inset: 0,
83
+ background: 'rgba(20, 22, 41, .45)',
84
+ zIndex: 8500,
85
+ display: 'flex',
86
+ justifyContent: side === 'left' ? 'flex-start' : 'flex-end',
87
+ animation: `${closing ? 'cynxDrawerFadeOut' : 'cynxDrawerFadeIn'} .26s ease forwards`,
88
+ }}
89
+ onMouseDown={(e) => {
90
+ if (e.target === e.currentTarget) handleClose();
91
+ }}
92
+ >
93
+ <div
94
+ style={{
95
+ background: 'var(--surface, #ffffff)',
96
+ borderLeft: side === 'right' ? '1px solid var(--border, var(--bd, #e2e8f0))' : 'none',
97
+ borderRight: side === 'left' ? '1px solid var(--border, var(--bd, #e2e8f0))' : 'none',
98
+ width: resolvedWidth,
99
+ maxWidth: '100vw',
100
+ height: '100%',
101
+ boxShadow: 'var(--shadow-lg, 0 20px 60px rgba(0, 0, 0, .25))',
102
+ display: 'flex',
103
+ flexDirection: 'column',
104
+ overflow: 'hidden',
105
+ animation: `${closing ? slideOutAnim : slideInAnim} .26s cubic-bezier(.16, 1, .3, 1) forwards`,
106
+ ...style,
107
+ }}
108
+ onMouseDown={(e) => e.stopPropagation()}
109
+ >
110
+ {/* Header */}
111
+ <div
112
+ style={{
113
+ display: 'flex',
114
+ alignItems: 'center',
115
+ justifyContent: 'space-between',
116
+ padding: '16px 20px',
117
+ borderBottom: '1px solid var(--border-light, #ebebf0)',
118
+ flexShrink: 0,
119
+ }}
120
+ >
121
+ {header ? (
122
+ header
123
+ ) : (
124
+ <div style={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
125
+ <span
126
+ style={{
127
+ fontSize: '1rem',
128
+ fontWeight: 700,
129
+ letterSpacing: '-.01em',
130
+ color: 'var(--t, var(--primary-text, #0f111c))',
131
+ }}
132
+ >
133
+ {{ title }}
134
+ </span>
135
+ {description && (
136
+ <span
137
+ style={{
138
+ fontSize: '.75rem',
139
+ color: 'var(--muted, #797b8d)',
140
+ }}
141
+ >
142
+ {description}
143
+ </span>
144
+ )}
145
+ </div>
146
+ )}
147
+
148
+ {showClose && (
149
+ <button
150
+ type="button"
151
+ style={{
152
+ background: 'none',
153
+ border: 'none',
154
+ cursor: 'pointer',
155
+ padding: '6px',
156
+ borderRadius: '6px',
157
+ color: 'var(--muted, #797b8d)',
158
+ display: 'flex',
159
+ alignItems: 'center',
160
+ justifyContent: 'center',
161
+ transition: 'all .14s',
162
+ }}
163
+ onClick={handleClose}
164
+ >
165
+ <X size={18} />
166
+ </button>
167
+ )}
168
+ </div>
169
+
170
+ {/* Body */}
171
+ <div
172
+ className="custom-scrollbar"
173
+ style={{
174
+ padding: '20px',
175
+ overflowX: 'hidden',
176
+ overflowY: 'auto',
177
+ flex: '1 1 auto',
178
+ minHeight: 0,
179
+ color: 'var(--t, var(--primary-text, #0f111c))',
180
+ ...bodyStyle,
181
+ }}
182
+ >
183
+ {children}
184
+ </div>
185
+
186
+ {/* Footer */}
187
+ {footer && (
188
+ <div
189
+ style={{
190
+ display: 'flex',
191
+ justifyContent: 'flex-end',
192
+ gap: 8,
193
+ padding: '14px 20px',
194
+ borderTop: '1px solid var(--border-light, #ebebf0)',
195
+ background: 'var(--grey-1, #f5f5f8)',
196
+ flexShrink: 0,
197
+ }}
198
+ >
199
+ {footer}
200
+ </div>
201
+ )}
202
+ </div>
203
+ </div>,
204
+ document.body
205
+ );
206
+ }
207
+
208
+ export default Drawer;
@@ -1,85 +1,85 @@
1
- import { useState, useRef, useEffect } from 'react';
2
-
3
- /**
4
- * HoverCard — reusable tooltip/popover on hover
5
- *
6
- * Props:
7
- * trigger — React node as hover target
8
- * children — popup content
9
- * position — 'top' | 'bottom' (default: 'top')
10
- * width — min-width (default: 180)
11
- * style — extra popup styles
12
- * arrow — show arrow indicator (default: false)
13
- * style — extra popup styles
14
- * triggerStyle — extra trigger wrapper styles
15
- */
16
- export default function HoverCard({ trigger, children, position = 'top', width = 180, arrow = false, style, triggerStyle }) {
17
- const [open, setOpen] = useState(false);
18
- const [pos, setPos] = useState({ x: 0, y: 0 });
19
- const wrapRef = useRef(null);
20
-
21
- useEffect(() => {
22
- if (open && wrapRef.current) {
23
- const r = wrapRef.current.getBoundingClientRect();
24
- setPos({ x: r.left + r.width / 2, y: position === 'top' ? r.top : r.bottom });
25
- }
26
- }, [open, position]);
27
-
28
- useEffect(() => {
29
- if (!open) return;
30
- const close = (e) => {
31
- if (wrapRef.current && !wrapRef.current.contains(e.target)) setOpen(false);
32
- };
33
- document.addEventListener('mousedown', close);
34
- return () => document.removeEventListener('mousedown', close);
35
- }, [open]);
36
-
37
- return (
38
- <div
39
- ref={wrapRef}
40
- onMouseEnter={() => setOpen(true)}
41
- onMouseLeave={() => setOpen(false)}
42
- style={{ display: 'inline-block', position: 'relative', ...triggerStyle }}
43
- >
44
- {trigger}
45
- {open && (
46
- <div style={{
47
- position: 'fixed',
48
- left: pos.x,
49
- top: position === 'top' ? 'auto' : pos.y + 6,
50
- bottom: position === 'top' ? window.innerHeight - pos.y + 6 : 'auto',
51
- transform: 'translateX(-50%)',
52
- zIndex: 9999,
53
- minWidth: width,
54
- background: 'var(--surface,#fff)',
55
- border: '1px solid var(--border, #e2e8f0)',
56
- borderRadius: 'var(--rads, 8px)',
57
- padding: '10px 14px',
58
- boxShadow: 'var(--smd, 0 4px 12px rgba(0,0,0,.12))',
59
- pointerEvents: 'none',
60
- animation: 'hoverCardIn .15s ease',
61
- ...style,
62
- }}>
63
- {children}
64
- {arrow && (
65
- <div style={{
66
- position: 'absolute', left: '50%',
67
- [position === 'top' ? 'bottom' : 'top']: -5,
68
- transform: 'translateX(-50%) rotate(45deg)',
69
- width: 8, height: 8, background: 'var(--surface,#fff)',
70
- borderRight: '1px solid var(--border, #e2e8f0)',
71
- borderBottom: position === 'top' ? 'none' : '1px solid var(--border, #e2e8f0)',
72
- borderTop: position === 'top' ? '1px solid var(--border, #e2e8f0)' : 'none',
73
- }} />
74
- )}
75
- </div>
76
- )}
77
- <style>{`
78
- @keyframes hoverCardIn {
79
- from { opacity: 0; transform: translateX(-50%) translateY(4px); }
80
- to { opacity: 1; transform: translateX(-50%) translateY(0); }
81
- }
82
- `}</style>
83
- </div>
84
- );
85
- }
1
+ import { useState, useRef, useEffect } from 'react';
2
+
3
+ /**
4
+ * HoverCard — reusable tooltip/popover on hover
5
+ *
6
+ * Props:
7
+ * trigger — React node as hover target
8
+ * children — popup content
9
+ * position — 'top' | 'bottom' (default: 'top')
10
+ * width — min-width (default: 180)
11
+ * style — extra popup styles
12
+ * arrow — show arrow indicator (default: false)
13
+ * style — extra popup styles
14
+ * triggerStyle — extra trigger wrapper styles
15
+ */
16
+ export default function HoverCard({ trigger, children, position = 'top', width = 180, arrow = false, style, triggerStyle }) {
17
+ const [open, setOpen] = useState(false);
18
+ const [pos, setPos] = useState({ x: 0, y: 0 });
19
+ const wrapRef = useRef(null);
20
+
21
+ useEffect(() => {
22
+ if (open && wrapRef.current) {
23
+ const r = wrapRef.current.getBoundingClientRect();
24
+ setPos({ x: r.left + r.width / 2, y: position === 'top' ? r.top : r.bottom });
25
+ }
26
+ }, [open, position]);
27
+
28
+ useEffect(() => {
29
+ if (!open) return;
30
+ const close = (e) => {
31
+ if (wrapRef.current && !wrapRef.current.contains(e.target)) setOpen(false);
32
+ };
33
+ document.addEventListener('mousedown', close);
34
+ return () => document.removeEventListener('mousedown', close);
35
+ }, [open]);
36
+
37
+ return (
38
+ <div
39
+ ref={wrapRef}
40
+ onMouseEnter={() => setOpen(true)}
41
+ onMouseLeave={() => setOpen(false)}
42
+ style={{ display: 'inline-block', position: 'relative', ...triggerStyle }}
43
+ >
44
+ {trigger}
45
+ {open && (
46
+ <div style={{
47
+ position: 'fixed',
48
+ left: pos.x,
49
+ top: position === 'top' ? 'auto' : pos.y + 6,
50
+ bottom: position === 'top' ? window.innerHeight - pos.y + 6 : 'auto',
51
+ transform: 'translateX(-50%)',
52
+ zIndex: 9999,
53
+ minWidth: width,
54
+ background: 'var(--surface,#fff)',
55
+ border: '1px solid var(--border, #e2e8f0)',
56
+ borderRadius: 'var(--rads, 8px)',
57
+ padding: '10px 14px',
58
+ boxShadow: 'var(--smd, 0 4px 12px rgba(0,0,0,.12))',
59
+ pointerEvents: 'none',
60
+ animation: 'hoverCardIn .15s ease',
61
+ ...style,
62
+ }}>
63
+ {children}
64
+ {arrow && (
65
+ <div style={{
66
+ position: 'absolute', left: '50%',
67
+ [position === 'top' ? 'bottom' : 'top']: -5,
68
+ transform: 'translateX(-50%) rotate(45deg)',
69
+ width: 8, height: 8, background: 'var(--surface,#fff)',
70
+ borderRight: '1px solid var(--border, #e2e8f0)',
71
+ borderBottom: position === 'top' ? 'none' : '1px solid var(--border, #e2e8f0)',
72
+ borderTop: position === 'top' ? '1px solid var(--border, #e2e8f0)' : 'none',
73
+ }} />
74
+ )}
75
+ </div>
76
+ )}
77
+ <style>{`
78
+ @keyframes hoverCardIn {
79
+ from { opacity: 0; transform: translateX(-50%) translateY(4px); }
80
+ to { opacity: 1; transform: translateX(-50%) translateY(0); }
81
+ }
82
+ `}</style>
83
+ </div>
84
+ );
85
+ }