@@ -1,73 +1,114 @@
1import React from 'react'
1import React from 'react'
2import PropTypes from 'prop-types';
2import PropTypes from 'prop-types';
4+import { DropdownItem, DropdownDivider } from '../components/Base'
5−const InnerLabelDropdown = props => {
6+class InnerLabelDropdown extends React.Component {
6−
7+ constructor(props) {
14+ this.toggle = this.toggle.bind(this)
15+ this.close = this.close.bind(this)
20+ isOpen: !this.state.isOpen
32+ this.props.handleUpdate(opt)
36+ return this.props.options.map(opt => {
37+ if (opt.type === "divider") {
38+ return <DropdownDivider />
41+ <DropdownItem onClick={() => this.selectOption(opt.value)}>
50+ const { props, state } = this
52+ const optionElems = this.getOptionElems()
7− const menuVisibility = props.isOpen === true
54+ const menuVisibility = state.isOpen === true
8− ? 'visible'
55+ ? 'visible'
9− : 'hidden';
56+ : 'hidden';
11− const selectedClasses = props.isOpen === true
58+ const selectedClasses = state.isOpen === true
12− ? 'br-blue'
59+ ? 'br-blue'
13− : 'br-gray-50';
60+ : 'br-gray-50';
15− const fullWidthClass = props.fullWidth ? 'full-width' : ''
62+ const fullWidthClass = props.fullWidth ? 'full-width' : ''
18− <div className={`rel table ${fullWidthClass}`}>
65+ <div className={`rel table ${fullWidthClass}`}>
20− className={`fix full o-0 ${menuVisibility}`}
67+ className={`fix full o-0 ${menuVisibility}`}
21− onClick={props.handleClose}
68+ onClick={this.close}
25− className={`h-10 mp-0 bg-white outline-blue sans ${props.className} ${fullWidthClass}`}
72+ className={`h-10 mp-0 bg-white outline-blue sans ${props.className} ${fullWidthClass}`}
26− onClick={props.handleToggle}
73+ onClick={this.toggle}
27− disabled={props.disabled}>
74+ disabled={props.disabled}>
28− <div className={'flex'}>
75+ <div className={'flex'}>
29− <div className={`ph-4 flex-center-all b-2 br-0 b-solid h-10 ${selectedClasses} ${fullWidthClass}`}>
76+ <div className={`ph-4 flex align-center b-2 br-0 b-solid h-10 ${selectedClasses} ${fullWidthClass}`}>
30− <div className={'text-400 mr-2'}>{props.title}</div>
77+ <div className={'text-400 mr-2'}>{props.title}</div>
31− <div className={'text-600'}>{props.currentSelectionTitle}</div>
78+ <div className={'text-600'}>{props.currentSelectionTitle}</div>
80+ <div className={'white bg-blue s-10 flex-center-all text-sm'}>{'▼'}</div>
33− <div className={'white bg-blue s-10 flex-center-all text-sm'}>{'▼'}</div>
35− </button>
82+ </button>
37− <div className={`abs flex-column bg-white t-12 l-0 w-100 ${menuVisibility}`}>
84+ <div className={`abs flex-column bg-white t-12 l-0 w-100 z-1 ${menuVisibility}`}>
38− <div className={'pv-1 b-solid b-gray-50 b-2 bb-0'} />
85+ <div className={'pv-1 b-solid b-gray-50 b-2 bb-0'} />
40− { props.children }
87+ { optionElems }
42− <div className={'pv-1 b-solid b-gray-50 b-2 bt-0'} />
89+ <div className={'pv-1 b-solid b-gray-50 b-2 bt-0'} />
49InnerLabelDropdown.propTypes = {
97InnerLabelDropdown.propTypes = {
50 disabled: PropTypes.bool,
98 disabled: PropTypes.bool,
51− isOpen: PropTypes.bool,
52− handleToggle: PropTypes.func,
53− handleClose: PropTypes.func,
54 className: PropTypes.string,
99 className: PropTypes.string,
55 title: PropTypes.string,
100 title: PropTypes.string,
56− children: PropTypes.node,
57 style: PropTypes.object,
101 style: PropTypes.object,
58 currentSelectionTitle: PropTypes.string,
102 currentSelectionTitle: PropTypes.string,
103+ children: PropTypes.node,
62InnerLabelDropdown.defaultProps = {
106InnerLabelDropdown.defaultProps = {
63− isOpen: false,
107+ disabled: false,
64 className: '',
108 className: '',
65 title: '',
109 title: '',
66− currentSelectionTitle: '',
67− handleToggle: () => {},
68− handleClose: () => {},
70 style: {},
110 style: {},
111+ currentSelectionTitle: '',
73export default InnerLabelDropdown
114export default InnerLabelDropdown