Newer
Older
/* eslint-disable no-underscore-dangle */
import React, { useContext, useMemo, useEffect, useState } from 'react';
import styled from 'styled-components';
import Dropdown from 'react-dropdown';
import { v4 as uuidv4 } from 'uuid';
const Wrapper = styled.div`
${ReactDropDownStyles};
`;
const DropdownStyled = styled(Dropdown)`
display: inline-flex;
cursor: not-allowed;
opacity: ${props => (props.select ? 1 : 0.4)};
pointer-events: ${props => (props.select ? 'default' : 'none')};
.Dropdown-control {
border: none;
&:hover {
box-shadow: none;
}
}
.Dropdown-arrow {
top: 17px;
}
.Dropdown-menu {
display: flex;
flex-direction: column;
align-items: flex-start;
.Dropdown-option {
width: 100%;
}
}
`;
const DropDownComponent = ({ view, tools }) => {
const context = useContext(WaxContext);
const {
activeView,
activeViewId,
} = context;
const { state } = view;
const [label, setLabel] = useState(null);
const isEditable = main.props.editable(editable => {
return editable;
});
value: '6',
item: tools[6],
},
{
let isDisabled = tools[0].select(state, activeView);
if (!isEditable) isDisabled = false;
const onChange = option => {
tools[option.value].run(main, context);
};
const MultipleDropDown = useMemo(
() => (
<Wrapper key={uuidv4()}>
<DropdownStyled
key={uuidv4()}
onChange={option => onChange(option)}
options={dropDownOptions}
select={isDisabled}
value={label}
/>
</Wrapper>
),
[isDisabled, label],
);
return MultipleDropDown;
};