cynx-ui 1.2.29 → 1.2.30
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 +43 -2
- package/package.json +1 -1
package/components/Input.jsx
CHANGED
|
@@ -17,6 +17,7 @@ export default function Input({
|
|
|
17
17
|
iconRight,
|
|
18
18
|
clearable = false,
|
|
19
19
|
suffix,
|
|
20
|
+
multiline = false,
|
|
20
21
|
onClear,
|
|
21
22
|
className = '',
|
|
22
23
|
style = {},
|
|
@@ -36,8 +37,8 @@ export default function Input({
|
|
|
36
37
|
|
|
37
38
|
const hasIconLeft = !!icon;
|
|
38
39
|
const hasIconRight = !!iconRight;
|
|
39
|
-
const showClear = clearable && !!value && !props.disabled;
|
|
40
|
-
const hasSuffix = !!suffix;
|
|
40
|
+
const showClear = clearable && !!value && !props.disabled && !multiline;
|
|
41
|
+
const hasSuffix = !!suffix && !multiline;
|
|
41
42
|
const showRightSlot = showClear || hasSuffix;
|
|
42
43
|
|
|
43
44
|
return (
|
|
@@ -95,6 +96,45 @@ export default function Input({
|
|
|
95
96
|
</span>
|
|
96
97
|
)}
|
|
97
98
|
|
|
99
|
+
{multiline ? (
|
|
100
|
+
<textarea
|
|
101
|
+
ref={inputRef}
|
|
102
|
+
className={className}
|
|
103
|
+
style={{
|
|
104
|
+
display: 'block',
|
|
105
|
+
width: '100%',
|
|
106
|
+
minHeight: 70,
|
|
107
|
+
resize: 'vertical',
|
|
108
|
+
whiteSpace: 'pre-wrap',
|
|
109
|
+
overflowWrap: 'break-word',
|
|
110
|
+
background: props.disabled ? 'var(--grey-1,#f5f5f8)' : 'var(--input-bg,#fff)',
|
|
111
|
+
border: `1px solid ${error ? 'var(--danger,#f64747)' : focused ? 'var(--accent,#f99e2c)' : hovered ? 'var(--accent,#f99e2c)' : 'var(--bd,#d7d8e0)'}`,
|
|
112
|
+
borderRadius: 'var(--rads,8px)',
|
|
113
|
+
color: 'var(--t1,#1a1a2e)',
|
|
114
|
+
fontFamily: 'var(--f,var(--sans,inherit))',
|
|
115
|
+
fontSize: s.fontSize,
|
|
116
|
+
padding: 0,
|
|
117
|
+
paddingTop: 8,
|
|
118
|
+
paddingBottom: 8,
|
|
119
|
+
paddingLeft: hasIconLeft ? 34 : 12,
|
|
120
|
+
paddingRight: (hasIconRight || showRightSlot) ? 34 : 12,
|
|
121
|
+
outline: 'none',
|
|
122
|
+
transition: 'border-color .14s, box-shadow .14s',
|
|
123
|
+
boxShadow: error
|
|
124
|
+
? 'var(--dd, rgba(246,71,71,.12)), var(--shadow,0 1px 3px rgba(20,22,41,.1))'
|
|
125
|
+
: focused
|
|
126
|
+
? 'var(--pd, rgba(249,158,44,.12)), var(--shadow,0 1px 3px rgba(20,22,41,.1))'
|
|
127
|
+
: 'var(--shadow,0 1px 3px rgba(20,22,41,.1))',
|
|
128
|
+
opacity: props.disabled ? 0.5 : 1,
|
|
129
|
+
cursor: props.disabled ? 'not-allowed' : undefined,
|
|
130
|
+
...style,
|
|
131
|
+
}}
|
|
132
|
+
value={value}
|
|
133
|
+
{...props}
|
|
134
|
+
onFocus={e => { setFocused(true); props.onFocus?.(e); }}
|
|
135
|
+
onBlur={e => { setFocused(false); setHovered(false); props.onBlur?.(e); }}
|
|
136
|
+
/>
|
|
137
|
+
) : (
|
|
98
138
|
<input
|
|
99
139
|
ref={inputRef}
|
|
100
140
|
className={className}
|
|
@@ -129,6 +169,7 @@ export default function Input({
|
|
|
129
169
|
// onMouseEnter={() => setHovered(true)}
|
|
130
170
|
// onMouseLeave={() => setHovered(false)}
|
|
131
171
|
/>
|
|
172
|
+
)}
|
|
132
173
|
|
|
133
174
|
{showClear && (
|
|
134
175
|
<button
|