cynx-ui 1.2.9 → 1.2.11
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/Input.jsx +11 -4
- package/components/Modal.jsx +3 -0
- package/components/Skeleton.jsx +3 -0
- package/components/Spinner.jsx +3 -0
- package/components/Toast.jsx +3 -0
- package/package.json +1 -1
package/components/Input.jsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useRef } from 'react';
|
|
1
|
+
import { useRef, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
const SIZES = {
|
|
4
4
|
xs: { height: 30, fontSize: 11, paddingH: 8 },
|
|
@@ -24,6 +24,8 @@ export default function Input({
|
|
|
24
24
|
...props
|
|
25
25
|
}) {
|
|
26
26
|
const inputRef = useRef(null);
|
|
27
|
+
const [focused, setFocused] = useState(false);
|
|
28
|
+
const [hovered, setHovered] = useState(false);
|
|
27
29
|
const s = SIZES[size] || SIZES.md;
|
|
28
30
|
|
|
29
31
|
function handleClear() {
|
|
@@ -99,8 +101,8 @@ export default function Input({
|
|
|
99
101
|
style={{
|
|
100
102
|
display: 'block',
|
|
101
103
|
width: '100%',
|
|
102
|
-
background: 'var(--input-bg,#fff)',
|
|
103
|
-
border: `1px solid ${error ? 'var(--danger,#f64747)' : 'var(--bd,#d7d8e0)'}`,
|
|
104
|
+
background: props.disabled ? 'var(--grey-1,#f5f5f8)' : 'var(--input-bg,#fff)',
|
|
105
|
+
border: `1px solid ${error ? 'var(--danger,#f64747)' : focused ? 'var(--accent,#f99e2c)' : hovered ? 'var(--accent,#f99e2c)' : 'var(--bd,#d7d8e0)'}`,
|
|
104
106
|
borderRadius: 'var(--rads,8px)',
|
|
105
107
|
color: 'var(--t1,#1a1a2e)',
|
|
106
108
|
fontFamily: 'var(--f,var(--sans,inherit))',
|
|
@@ -113,13 +115,18 @@ export default function Input({
|
|
|
113
115
|
transition: 'border-color .14s, box-shadow .14s',
|
|
114
116
|
boxShadow: error
|
|
115
117
|
? '0 0 0 3px rgba(246,71,71,.12), var(--shadow,0 1px 3px rgba(20,22,41,.1))'
|
|
118
|
+
: focused
|
|
119
|
+
? '0 0 0 3px rgba(249,158,44,.12), var(--shadow,0 1px 3px rgba(20,22,41,.1))'
|
|
116
120
|
: 'var(--shadow,0 1px 3px rgba(20,22,41,.1))',
|
|
117
121
|
opacity: props.disabled ? 0.5 : 1,
|
|
118
122
|
cursor: props.disabled ? 'not-allowed' : undefined,
|
|
119
|
-
background: props.disabled ? 'var(--grey-1,#f5f5f8)' : undefined,
|
|
120
123
|
...style,
|
|
121
124
|
}}
|
|
122
125
|
value={value}
|
|
126
|
+
onFocus={e => { setFocused(true); props.onFocus?.(e); }}
|
|
127
|
+
onBlur={e => { setFocused(false); props.onBlur?.(e); }}
|
|
128
|
+
onMouseEnter={() => setHovered(true)}
|
|
129
|
+
onMouseLeave={() => setHovered(false)}
|
|
123
130
|
{...props}
|
|
124
131
|
/>
|
|
125
132
|
|
package/components/Modal.jsx
CHANGED
|
@@ -91,6 +91,9 @@ function ensureStyles() {
|
|
|
91
91
|
document.head.appendChild(tag);
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
// Auto-inject on module load
|
|
95
|
+
if (typeof document !== 'undefined') ensureStyles();
|
|
96
|
+
|
|
94
97
|
export function Modal({ open, onClose, onBeforeClose, title, children, footer, maxWidth = 520, bodyStyle }) {
|
|
95
98
|
const [closing, setClosing] = useState(false);
|
|
96
99
|
const mounted = useRef(open);
|
package/components/Skeleton.jsx
CHANGED
|
@@ -13,6 +13,9 @@ function ensureStyles() {
|
|
|
13
13
|
document.head.appendChild(tag);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
// Auto-inject on module load so raw className="skeleton" works everywhere
|
|
17
|
+
if (typeof document !== 'undefined') ensureStyles();
|
|
18
|
+
|
|
16
19
|
const SK_BASE = {
|
|
17
20
|
background: 'linear-gradient(90deg, var(--grey-1, #f0f1f5) 25%, var(--border-light, #e8e8ec) 50%, var(--grey-1, #f0f1f5) 75%)',
|
|
18
21
|
backgroundSize: '600px 100%',
|
package/components/Spinner.jsx
CHANGED
|
@@ -10,6 +10,9 @@ function ensureStyles() {
|
|
|
10
10
|
document.head.appendChild(tag);
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
// Auto-inject on module load
|
|
14
|
+
if (typeof document !== 'undefined') ensureStyles();
|
|
15
|
+
|
|
13
16
|
export function Spinner({ size = 20, inline = false, color = 'currentColor', fullPage = false }) {
|
|
14
17
|
ensureStyles();
|
|
15
18
|
const s = inline ? 14 : size;
|
package/components/Toast.jsx
CHANGED
|
@@ -27,6 +27,9 @@ function ensureStyles() {
|
|
|
27
27
|
document.head.appendChild(tag);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
// Auto-inject on module load
|
|
31
|
+
if (typeof document !== 'undefined') ensureStyles();
|
|
32
|
+
|
|
30
33
|
// ── Module-level state ────────────────────────────────────────────────────────
|
|
31
34
|
let _toasts = [];
|
|
32
35
|
let _listeners = new Set();
|