cynx-lib 1.3.83 → 1.3.85
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/gen.js +77 -77
- package/package.json +5 -1
- package/ui/components/Drawer.jsx +208 -208
- package/ui/components/Layout.jsx +37 -0
- package/ui/components/Pagination.jsx +145 -145
- package/ui/components/PrivacyBlur.jsx +603 -603
- package/ui/components/Sidebar.jsx +300 -134
- package/utils/index.cjs +5 -0
- package/utils/index.js +22 -20
- package/utils/utils/duration.js +139 -139
- package/utils/utils/oidc.js +214 -214
- package/utils/utils/realtime.js +1634 -1634
- package/utils/utils/session.cjs +15 -2
- package/utils/utils/session.js +67 -58
- package/utils/utils/session_manager.cjs +490 -0
- package/utils/utils/session_manager.js +549 -0
- package/utils/utils/storage.js +393 -393
- package/utils/utils/ui.js +111 -111
- package/vue/components/Badge.vue +79 -79
- package/vue/components/Button.vue +209 -209
- package/vue/components/Checkbox.vue +103 -103
- package/vue/components/CircularProgress.vue +383 -383
- package/vue/components/Divider.vue +94 -94
- package/vue/components/Drawer.vue +243 -243
- package/vue/components/InfoBadge.vue +223 -223
- package/vue/components/Input.vue +341 -341
- package/vue/components/LinearProgress.vue +268 -268
- package/vue/components/Modal.vue +226 -226
- package/vue/components/Pagination.vue +199 -199
- package/vue/components/Select.vue +713 -713
- package/vue/components/Sidebar.vue +955 -955
- package/vue/components/Skeleton.vue +91 -91
- package/vue/components/Spinner.vue +263 -263
- package/vue/components/StatusTag.vue +89 -89
- package/vue/components/TabBar.vue +176 -176
- package/vue/components/Table.vue +388 -388
- package/vue/components/TimePicker.vue +399 -399
- package/vue/components/Toggle.vue +115 -115
- package/vue/components/XTable.vue +119 -119
- package/vue/composables/useAutoSkeletonRows.ts +71 -71
- package/vue/index.d.ts +67 -67
- package/vue/index.js +86 -86
package/gen.js
CHANGED
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
import { uid, prefixedId, uuid, ALPHABETS } from './utils/index.js';
|
|
5
|
-
|
|
6
|
-
const ALPHABET_MAP = {
|
|
7
|
-
hex: ALPHABETS.hex,
|
|
8
|
-
num: ALPHABETS.numeric,
|
|
9
|
-
numeric: ALPHABETS.numeric,
|
|
10
|
-
numbers: ALPHABETS.numeric,
|
|
11
|
-
digits: ALPHABETS.numeric,
|
|
12
|
-
lc: ALPHABETS.lowercase,
|
|
13
|
-
lower: ALPHABETS.lowercase,
|
|
14
|
-
lowercase: ALPHABETS.lowercase,
|
|
15
|
-
uc: ALPHABETS.uppercase,
|
|
16
|
-
upper: ALPHABETS.uppercase,
|
|
17
|
-
uppercase: ALPHABETS.uppercase,
|
|
18
|
-
mixed: ALPHABETS.alphanumeric,
|
|
19
|
-
alpha: ALPHABETS.alphanumeric,
|
|
20
|
-
alphanumeric: ALPHABETS.alphanumeric,
|
|
21
|
-
url: ALPHABETS.urlSafe,
|
|
22
|
-
urlsafe: ALPHABETS.urlSafe,
|
|
23
|
-
'url-safe': ALPHABETS.urlSafe,
|
|
24
|
-
clean: ALPHABETS.noLookalikes,
|
|
25
|
-
nolookalikes: ALPHABETS.noLookalikes,
|
|
26
|
-
'no-lookalikes': ALPHABETS.noLookalikes,
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
async function main() {
|
|
30
|
-
const rawArgs = process.argv.slice(2);
|
|
31
|
-
let prefix = '';
|
|
32
|
-
let size = 24;
|
|
33
|
-
let count = 1;
|
|
34
|
-
let isUuid = false;
|
|
35
|
-
let alphabet = ALPHABETS.lowercase;
|
|
36
|
-
|
|
37
|
-
for (let i = 0; i < rawArgs.length; i++) {
|
|
38
|
-
const raw = rawArgs[i].trim();
|
|
39
|
-
const clean = raw.toLowerCase().replace(/^--?/, '');
|
|
40
|
-
|
|
41
|
-
if (clean === 'uuid') {
|
|
42
|
-
isUuid = true;
|
|
43
|
-
} else if (clean === 'n' || clean === 'count') {
|
|
44
|
-
count = parseInt(rawArgs[++i], 10) || 1;
|
|
45
|
-
} else if (clean === 's' || clean === 'size' || clean === 'l' || clean === 'length') {
|
|
46
|
-
size = parseInt(rawArgs[++i], 10) || 24;
|
|
47
|
-
} else if (clean === 'p' || clean === 'prefix') {
|
|
48
|
-
prefix = rawArgs[++i] || '';
|
|
49
|
-
} else if (clean === 'a' || clean === 'alphabet') {
|
|
50
|
-
const val = (rawArgs[++i] || '').toLowerCase();
|
|
51
|
-
alphabet = ALPHABET_MAP[val] || ALPHABETS[val] || val || ALPHABETS.lowercase;
|
|
52
|
-
} else if (ALPHABET_MAP[clean]) {
|
|
53
|
-
alphabet = ALPHABET_MAP[clean];
|
|
54
|
-
} else if (!isNaN(Number(raw)) && /^\d+$/.test(raw)) {
|
|
55
|
-
size = parseInt(raw, 10);
|
|
56
|
-
} else if (!prefix && !raw.startsWith('-')) {
|
|
57
|
-
prefix = raw;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
for (let i = 0; i < count; i++) {
|
|
62
|
-
let result;
|
|
63
|
-
if (isUuid) {
|
|
64
|
-
result = uuid();
|
|
65
|
-
} else if (prefix) {
|
|
66
|
-
result = prefixedId(prefix, size, alphabet);
|
|
67
|
-
} else {
|
|
68
|
-
result = uid(size, alphabet);
|
|
69
|
-
}
|
|
70
|
-
console.log(result);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
main().catch((err) => {
|
|
75
|
-
console.error('[Error]:', err.message);
|
|
76
|
-
process.exit(1);
|
|
77
|
-
});
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
import { uid, prefixedId, uuid, ALPHABETS } from './utils/index.js';
|
|
5
|
+
|
|
6
|
+
const ALPHABET_MAP = {
|
|
7
|
+
hex: ALPHABETS.hex,
|
|
8
|
+
num: ALPHABETS.numeric,
|
|
9
|
+
numeric: ALPHABETS.numeric,
|
|
10
|
+
numbers: ALPHABETS.numeric,
|
|
11
|
+
digits: ALPHABETS.numeric,
|
|
12
|
+
lc: ALPHABETS.lowercase,
|
|
13
|
+
lower: ALPHABETS.lowercase,
|
|
14
|
+
lowercase: ALPHABETS.lowercase,
|
|
15
|
+
uc: ALPHABETS.uppercase,
|
|
16
|
+
upper: ALPHABETS.uppercase,
|
|
17
|
+
uppercase: ALPHABETS.uppercase,
|
|
18
|
+
mixed: ALPHABETS.alphanumeric,
|
|
19
|
+
alpha: ALPHABETS.alphanumeric,
|
|
20
|
+
alphanumeric: ALPHABETS.alphanumeric,
|
|
21
|
+
url: ALPHABETS.urlSafe,
|
|
22
|
+
urlsafe: ALPHABETS.urlSafe,
|
|
23
|
+
'url-safe': ALPHABETS.urlSafe,
|
|
24
|
+
clean: ALPHABETS.noLookalikes,
|
|
25
|
+
nolookalikes: ALPHABETS.noLookalikes,
|
|
26
|
+
'no-lookalikes': ALPHABETS.noLookalikes,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
async function main() {
|
|
30
|
+
const rawArgs = process.argv.slice(2);
|
|
31
|
+
let prefix = '';
|
|
32
|
+
let size = 24;
|
|
33
|
+
let count = 1;
|
|
34
|
+
let isUuid = false;
|
|
35
|
+
let alphabet = ALPHABETS.lowercase;
|
|
36
|
+
|
|
37
|
+
for (let i = 0; i < rawArgs.length; i++) {
|
|
38
|
+
const raw = rawArgs[i].trim();
|
|
39
|
+
const clean = raw.toLowerCase().replace(/^--?/, '');
|
|
40
|
+
|
|
41
|
+
if (clean === 'uuid') {
|
|
42
|
+
isUuid = true;
|
|
43
|
+
} else if (clean === 'n' || clean === 'count') {
|
|
44
|
+
count = parseInt(rawArgs[++i], 10) || 1;
|
|
45
|
+
} else if (clean === 's' || clean === 'size' || clean === 'l' || clean === 'length') {
|
|
46
|
+
size = parseInt(rawArgs[++i], 10) || 24;
|
|
47
|
+
} else if (clean === 'p' || clean === 'prefix') {
|
|
48
|
+
prefix = rawArgs[++i] || '';
|
|
49
|
+
} else if (clean === 'a' || clean === 'alphabet') {
|
|
50
|
+
const val = (rawArgs[++i] || '').toLowerCase();
|
|
51
|
+
alphabet = ALPHABET_MAP[val] || ALPHABETS[val] || val || ALPHABETS.lowercase;
|
|
52
|
+
} else if (ALPHABET_MAP[clean]) {
|
|
53
|
+
alphabet = ALPHABET_MAP[clean];
|
|
54
|
+
} else if (!isNaN(Number(raw)) && /^\d+$/.test(raw)) {
|
|
55
|
+
size = parseInt(raw, 10);
|
|
56
|
+
} else if (!prefix && !raw.startsWith('-')) {
|
|
57
|
+
prefix = raw;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
for (let i = 0; i < count; i++) {
|
|
62
|
+
let result;
|
|
63
|
+
if (isUuid) {
|
|
64
|
+
result = uuid();
|
|
65
|
+
} else if (prefix) {
|
|
66
|
+
result = prefixedId(prefix, size, alphabet);
|
|
67
|
+
} else {
|
|
68
|
+
result = uid(size, alphabet);
|
|
69
|
+
}
|
|
70
|
+
console.log(result);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
main().catch((err) => {
|
|
75
|
+
console.error('[Error]:', err.message);
|
|
76
|
+
process.exit(1);
|
|
77
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cynx-lib",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.85",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.cjs",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -37,6 +37,10 @@
|
|
|
37
37
|
"import": "./utils/utils/storage_manager.js",
|
|
38
38
|
"require": "./utils/utils/storage_manager.cjs"
|
|
39
39
|
},
|
|
40
|
+
"./session": {
|
|
41
|
+
"import": "./utils/utils/session_manager.js",
|
|
42
|
+
"require": "./utils/utils/session_manager.cjs"
|
|
43
|
+
},
|
|
40
44
|
"./gen": "./gen.js"
|
|
41
45
|
},
|
|
42
46
|
"peerDependencies": {
|
package/ui/components/Drawer.jsx
CHANGED
|
@@ -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;
|
package/ui/components/Layout.jsx
CHANGED
|
@@ -12,6 +12,24 @@ export default function Layout({
|
|
|
12
12
|
user,
|
|
13
13
|
onLogout,
|
|
14
14
|
onLock,
|
|
15
|
+
// Footer customization & actions
|
|
16
|
+
footerActions,
|
|
17
|
+
extraFooterActions,
|
|
18
|
+
footerSlot,
|
|
19
|
+
lockLabel,
|
|
20
|
+
logoutLabel,
|
|
21
|
+
lockTitle,
|
|
22
|
+
logoutTitle,
|
|
23
|
+
lockIcon,
|
|
24
|
+
logoutIcon,
|
|
25
|
+
showLock,
|
|
26
|
+
showLogout,
|
|
27
|
+
userSlot,
|
|
28
|
+
renderUser,
|
|
29
|
+
footerStyle,
|
|
30
|
+
footerClassName,
|
|
31
|
+
footerActionsLayout,
|
|
32
|
+
footerActionsStyle,
|
|
15
33
|
collapsible = true,
|
|
16
34
|
isCollapsed,
|
|
17
35
|
onToggleCollapse,
|
|
@@ -38,6 +56,7 @@ export default function Layout({
|
|
|
38
56
|
contentStyle = {},
|
|
39
57
|
contentClassName,
|
|
40
58
|
children,
|
|
59
|
+
...restProps
|
|
41
60
|
}) {
|
|
42
61
|
return (
|
|
43
62
|
<div
|
|
@@ -59,6 +78,23 @@ export default function Layout({
|
|
|
59
78
|
user={user}
|
|
60
79
|
onLogout={onLogout}
|
|
61
80
|
onLock={onLock}
|
|
81
|
+
footerActions={footerActions}
|
|
82
|
+
extraFooterActions={extraFooterActions}
|
|
83
|
+
footerSlot={footerSlot}
|
|
84
|
+
lockLabel={lockLabel}
|
|
85
|
+
logoutLabel={logoutLabel}
|
|
86
|
+
lockTitle={lockTitle}
|
|
87
|
+
logoutTitle={logoutTitle}
|
|
88
|
+
lockIcon={lockIcon}
|
|
89
|
+
logoutIcon={logoutIcon}
|
|
90
|
+
showLock={showLock}
|
|
91
|
+
showLogout={showLogout}
|
|
92
|
+
userSlot={userSlot}
|
|
93
|
+
renderUser={renderUser}
|
|
94
|
+
footerStyle={footerStyle}
|
|
95
|
+
footerClassName={footerClassName}
|
|
96
|
+
footerActionsLayout={footerActionsLayout}
|
|
97
|
+
footerActionsStyle={footerActionsStyle}
|
|
62
98
|
collapsible={collapsible}
|
|
63
99
|
isCollapsed={isCollapsed}
|
|
64
100
|
onToggleCollapse={onToggleCollapse}
|
|
@@ -75,6 +111,7 @@ export default function Layout({
|
|
|
75
111
|
activeSubColor={activeSubColor}
|
|
76
112
|
subItemsIndent={subItemsIndent}
|
|
77
113
|
hasPermission={hasPermission}
|
|
114
|
+
{...restProps}
|
|
78
115
|
/>
|
|
79
116
|
|
|
80
117
|
{/* Main Content Area */}
|