cynx-ui 1.3.16 → 1.3.18
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/Modal.jsx +13 -7
- package/components/Toast.jsx +15 -3
- package/package.json +1 -1
package/components/Modal.jsx
CHANGED
|
@@ -20,13 +20,15 @@ const STYLES = `
|
|
|
20
20
|
display: flex; align-items: center; justify-content: space-between;
|
|
21
21
|
padding: 15px 20px; border-bottom: 1px solid var(--border-light);
|
|
22
22
|
border-radius: 14px 14px 0 0;
|
|
23
|
+
flex-shrink: 0;
|
|
23
24
|
}
|
|
24
25
|
.modal-title { font-size: .88rem; font-weight: 700; letter-spacing: -.01em; }
|
|
25
|
-
.modal-body { padding: 20px; overflow:
|
|
26
|
+
.modal-body { padding: 20px; overflow-x: hidden; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
|
|
26
27
|
.modal-footer {
|
|
27
28
|
display: flex; justify-content: flex-end; gap: 8px;
|
|
28
29
|
padding: 13px 20px; border-top: 1px solid var(--border-light);
|
|
29
30
|
background: var(--grey-1); border-radius: 0 0 14px 14px;
|
|
31
|
+
flex-shrink: 0;
|
|
30
32
|
}
|
|
31
33
|
.modal-card {
|
|
32
34
|
background: var(--surface); border: 1px solid var(--border);
|
|
@@ -94,7 +96,7 @@ function ensureStyles() {
|
|
|
94
96
|
// Auto-inject on module load
|
|
95
97
|
if (typeof document !== 'undefined') ensureStyles();
|
|
96
98
|
|
|
97
|
-
export function Modal({ open, onClose, onBeforeClose, title, children, footer, maxWidth = 520, bodyStyle }) {
|
|
99
|
+
export function Modal({ open, onClose, onBeforeClose, title, children, footer, maxWidth = 520, maxHeight, bodyStyle, style }) {
|
|
98
100
|
const [closing, setClosing] = useState(false);
|
|
99
101
|
const mounted = useRef(open);
|
|
100
102
|
|
|
@@ -131,6 +133,7 @@ export function Modal({ open, onClose, onBeforeClose, title, children, footer, m
|
|
|
131
133
|
|
|
132
134
|
const resolvedFooter = typeof footer === 'function' ? footer(close) : footer;
|
|
133
135
|
const resolvedChildren = typeof children === 'function' ? children(close) : children;
|
|
136
|
+
const resolvedMaxHeight = style?.maxHeight || maxHeight || '60vh';
|
|
134
137
|
|
|
135
138
|
return createPortal(
|
|
136
139
|
<div
|
|
@@ -138,7 +141,7 @@ export function Modal({ open, onClose, onBeforeClose, title, children, footer, m
|
|
|
138
141
|
style={{
|
|
139
142
|
position: 'fixed', inset: 0,
|
|
140
143
|
background: 'rgba(20,22,41,.45)',
|
|
141
|
-
display: 'flex', alignItems: 'center', justifyContent: 'center',
|
|
144
|
+
display: 'flex', alignItems: 'center', justifyItems: 'center', justifyContent: 'center',
|
|
142
145
|
zIndex: 8000, padding: 20,
|
|
143
146
|
animation: `${closing ? 'modalFadeOut' : 'modalFadeIn'} .26s ease forwards`,
|
|
144
147
|
}}
|
|
@@ -148,25 +151,28 @@ export function Modal({ open, onClose, onBeforeClose, title, children, footer, m
|
|
|
148
151
|
className="modal-card"
|
|
149
152
|
style={{
|
|
150
153
|
background: 'var(--surface)', border: '1px solid var(--border)',
|
|
151
|
-
borderRadius: 14, width: '100%',
|
|
154
|
+
borderRadius: 14, width: '100%',
|
|
155
|
+
maxWidth: style?.maxWidth || maxWidth,
|
|
156
|
+
maxHeight: resolvedMaxHeight,
|
|
152
157
|
boxShadow: 'var(--slg, 0 20px 60px rgba(0,0,0,.25))',
|
|
153
158
|
overflow: 'hidden', display: 'flex', flexDirection: 'column',
|
|
154
159
|
animation: `${closing ? 'modalCardOut' : 'modalCardIn'} .26s cubic-bezier(.4,0,.2,1) forwards`,
|
|
160
|
+
...style,
|
|
155
161
|
}}
|
|
156
162
|
onMouseDown={e => e.stopPropagation()}
|
|
157
163
|
>
|
|
158
164
|
<div className="modal-hdr" style={{
|
|
159
165
|
display: 'flex', alignItems: 'center', justifyContent: 'space-between',
|
|
160
166
|
padding: '15px 20px', borderBottom: '1px solid var(--border-light)',
|
|
161
|
-
borderRadius: '14px 14px 0 0',
|
|
167
|
+
borderRadius: '14px 14px 0 0', flexShrink: 0,
|
|
162
168
|
}}>
|
|
163
169
|
<span className="modal-title" style={{ fontSize: '.88rem', fontWeight: 700, letterSpacing: '-.01em' }}>{title}</span>
|
|
164
170
|
</div>
|
|
165
|
-
<div className="modal-body" style={{ padding: 20, overflowX: 'hidden', overflowY: 'auto', flex: 1, minHeight: 0, ...bodyStyle }}>{resolvedChildren}</div>
|
|
171
|
+
<div className="modal-body" style={{ padding: 20, overflowX: 'hidden', overflowY: 'auto', flex: '1 1 auto', minHeight: 0, ...bodyStyle }}>{resolvedChildren}</div>
|
|
166
172
|
{resolvedFooter && <div className="modal-footer" style={{
|
|
167
173
|
display: 'flex', justifyContent: 'flex-end', gap: 8,
|
|
168
174
|
padding: '13px 20px', borderTop: '1px solid var(--border-light)',
|
|
169
|
-
background: 'var(--grey-1)', borderRadius: '0 0 14px 14px',
|
|
175
|
+
background: 'var(--grey-1)', borderRadius: '0 0 14px 14px', flexShrink: 0,
|
|
170
176
|
}}>{resolvedFooter}</div>}
|
|
171
177
|
</div>
|
|
172
178
|
</div>,
|
package/components/Toast.jsx
CHANGED
|
@@ -2,7 +2,7 @@ import { useState, useEffect, useCallback } from 'react';
|
|
|
2
2
|
import { createPortal } from 'react-dom';
|
|
3
3
|
|
|
4
4
|
const STYLES = `
|
|
5
|
-
#toast-root { position: fixed;
|
|
5
|
+
#toast-root { position: fixed; top: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 99999; }
|
|
6
6
|
.toast {
|
|
7
7
|
background: var(--surface, #fff); border: 1px solid var(--border, #d7d8e0);
|
|
8
8
|
border-radius: var(--rads, 8px); padding: 10px 14px;
|
|
@@ -70,11 +70,23 @@ export function useToast() {
|
|
|
70
70
|
return { toasts, toast, remove };
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
const POSITIONS = {
|
|
74
|
+
'top-right': { top: 20, right: 20, bottom: 'auto', left: 'auto' },
|
|
75
|
+
'top-left': { top: 20, left: 20, bottom: 'auto', right: 'auto' },
|
|
76
|
+
'top-center': { top: 20, left: '50%', transform: 'translateX(-50%)', bottom: 'auto', right: 'auto' },
|
|
77
|
+
'bottom-right': { bottom: 20, right: 20, top: 'auto', left: 'auto' },
|
|
78
|
+
'bottom-left': { bottom: 20, left: 20, top: 'auto', right: 'auto' },
|
|
79
|
+
'bottom-center': { bottom: 20, left: '50%', transform: 'translateX(-50%)', top: 'auto', right: 'auto' },
|
|
80
|
+
'top': { top: 20, right: 20, bottom: 'auto', left: 'auto' },
|
|
81
|
+
'bottom': { bottom: 20, right: 20, top: 'auto', left: 'auto' },
|
|
82
|
+
};
|
|
83
|
+
|
|
73
84
|
// ── Render component ──────────────────────────────────────────────────────────
|
|
74
|
-
export function Toast({ toasts, remove }) {
|
|
85
|
+
export function Toast({ toasts, remove, position = 'top-right', style = {} }) {
|
|
75
86
|
ensureStyles();
|
|
87
|
+
const posStyle = POSITIONS[position] || POSITIONS['top-right'];
|
|
76
88
|
return createPortal(
|
|
77
|
-
<div id="toast-root">
|
|
89
|
+
<div id="toast-root" style={{ ...posStyle, ...style }}>
|
|
78
90
|
{toasts.map(t => (
|
|
79
91
|
<div key={t.id} className={`toast ${t.type}`} onClick={() => remove(t.id)}>
|
|
80
92
|
{t.type === 'ok' || t.type === 'success'
|