-
-
Notifications
You must be signed in to change notification settings - Fork 489
Expand file tree
/
Copy pathPlaceholder.tsx
More file actions
30 lines (26 loc) · 744 Bytes
/
Placeholder.tsx
File metadata and controls
30 lines (26 loc) · 744 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import * as React from 'react';
import { clsx } from 'clsx';
import { useSelectInputContext } from '../context';
import useBaseProps from '../../hooks/useBaseProps';
export interface PlaceholderProps {
show?: boolean;
}
export default function Placeholder(props: PlaceholderProps) {
const { prefixCls, placeholder, displayValues } = useSelectInputContext();
const { classNames, styles } = useBaseProps();
const { show = true } = props;
if (displayValues.length) {
return null;
}
return (
<div
className={clsx(`${prefixCls}-placeholder`, classNames?.placeholder)}
style={{
visibility: show ? 'visible' : 'hidden',
...styles?.placeholder,
}}
>
{placeholder}
</div>
);
}