-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathCustomSelectOption.js
More file actions
52 lines (47 loc) · 1.32 KB
/
CustomSelectOption.js
File metadata and controls
52 lines (47 loc) · 1.32 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { MenuDivider, Tooltip } from '@dhis2/ui'
import cx from 'classnames'
import PropTypes from 'prop-types'
import React from 'react'
import i18n from '../../locales/index.js'
import styles from './styles/CustomSelectOption.style.js'
const CustomSelectOptionItem = ({
value,
label,
icon,
insertDivider,
onClick,
active,
disabled,
}) => (
<>
<div
onClick={(e) => onClick({}, e)}
data-value={value}
data-label={label}
className={cx({ active, disabled })}
>
{icon}
<span className={cx({ label: icon })}>{label}</span>
<style jsx>{styles}</style>
</div>
{insertDivider && <MenuDivider dense />}
</>
)
export const CustomSelectOption = (props) =>
props.disabled ? (
<Tooltip content={i18n.t('Not supported by this app yet')}>
<CustomSelectOptionItem {...props} />
</Tooltip>
) : (
<CustomSelectOptionItem {...props} />
)
CustomSelectOption.propTypes = {
label: PropTypes.string.isRequired,
value: PropTypes.string.isRequired,
active: PropTypes.bool,
disabled: PropTypes.bool,
icon: PropTypes.element,
onClick: PropTypes.func,
}
CustomSelectOptionItem.propTypes = CustomSelectOption.propTypes
export default CustomSelectOption