cynx-ui 1.2.42 → 1.2.43
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/Select.jsx +36 -9
- package/package.json +1 -1
package/components/Select.jsx
CHANGED
|
@@ -22,6 +22,8 @@ export default function Select({
|
|
|
22
22
|
disabled = false,
|
|
23
23
|
multi = false,
|
|
24
24
|
searchable = false,
|
|
25
|
+
clearable = false,
|
|
26
|
+
onClear,
|
|
25
27
|
style = {},
|
|
26
28
|
}) {
|
|
27
29
|
const [open, setOpen] = useState(false);
|
|
@@ -186,15 +188,40 @@ export default function Select({
|
|
|
186
188
|
<span style={{ color: 'var(--t3,var(--grey-3))', fontWeight: 400 }}>{placeholder}</span>
|
|
187
189
|
)}
|
|
188
190
|
</div>
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
191
|
+
{!multi && selectedValues.length > 0 && selectedValues[0] !== '' && selectedValues[0] !== null && (clearable || !!onClear) ? (
|
|
192
|
+
<span
|
|
193
|
+
onClick={(e) => {
|
|
194
|
+
e.stopPropagation();
|
|
195
|
+
if (onClear) onClear();
|
|
196
|
+
else onChange?.('');
|
|
197
|
+
}}
|
|
198
|
+
title="Сбросить выбор"
|
|
199
|
+
style={{
|
|
200
|
+
display: 'inline-flex',
|
|
201
|
+
alignItems: 'center',
|
|
202
|
+
justifyContent: 'center',
|
|
203
|
+
cursor: 'pointer',
|
|
204
|
+
color: 'var(--muted, #64748b)',
|
|
205
|
+
padding: '0 2px',
|
|
206
|
+
flexShrink: 0,
|
|
207
|
+
borderRadius: 'var(--radxs, 4px)',
|
|
208
|
+
}}
|
|
209
|
+
onMouseEnter={(e) => { e.currentTarget.style.color = 'var(--danger, #ef4444)'; }}
|
|
210
|
+
onMouseLeave={(e) => { e.currentTarget.style.color = 'var(--muted, #64748b)'; }}
|
|
211
|
+
>
|
|
212
|
+
<X size={13} />
|
|
213
|
+
</span>
|
|
214
|
+
) : (
|
|
215
|
+
<ChevronDown
|
|
216
|
+
size={13}
|
|
217
|
+
style={{
|
|
218
|
+
flexShrink: 0,
|
|
219
|
+
color: 'var(--t3,var(--grey-3))',
|
|
220
|
+
transition: 'transform .2s ease',
|
|
221
|
+
transform: open ? 'rotate(180deg)' : undefined,
|
|
222
|
+
}}
|
|
223
|
+
/>
|
|
224
|
+
)}
|
|
198
225
|
</div>
|
|
199
226
|
|
|
200
227
|
{open && createPortal(
|