/* eslint-disable react/display-name */ import React, { forwardRef, useState } from 'react'; import PropTypes from 'prop-types'; import { FormattedMessage } from 'react-intl'; import { Grab, GrabLarge, Pencil, Remove } from '@buffetjs/icons'; import pluginId from '../../pluginId'; import Link from './Link'; import Wrapper from './Wrapper'; const DraggedField = forwardRef( ( { children, count, isDragging, isHidden, name, onClick, onRemove, selectedItem, style, type, withLongerHeight, }, ref ) => { const opacity = isDragging ? 0.2 : 1; const [isOverRemove, setIsOverRemove] = useState(false); const isSelected = selectedItem === name; return ( {!isHidden && (
{ onClick(name); }} >
e.stopPropagation()}> {withLongerHeight ? ( ) : ( )}
{children ? children : name}
setIsOverRemove(true)} onMouseLeave={() => setIsOverRemove(false)} > {isSelected ? : }
)} {type === 'group' && ( {msg => ( { e.stopPropagation(); // push( // `/plugins/${pluginId}/ctm-configurations/groups/${groupUid}` // ) }} > {msg} )} )}
); } ); DraggedField.defaultProps = { children: null, count: 1, isDragging: false, isHidden: false, onClick: () => {}, onRemove: () => {}, selectedItem: '', style: {}, withLongerHeight: false, }; DraggedField.propTypes = { children: PropTypes.node, count: PropTypes.number, isDragging: PropTypes.bool, isHidden: PropTypes.bool, name: PropTypes.string.isRequired, onClick: PropTypes.func, onRemove: PropTypes.func, selectedItem: PropTypes.string, style: PropTypes.object, type: PropTypes.string, withLongerHeight: PropTypes.bool, }; export default DraggedField;