import PropTypes from 'prop-types';
import React from 'react';
import classNames from 'classnames';
import SpriteSelectorItem from '../../containers/sprite-selector-item.jsx';
import Box from '../box/box.jsx';
import ActionMenu from '../action-menu/action-menu.jsx';
import SortableAsset from './sortable-asset.jsx';
import SortableHOC from '../../lib/sortable-hoc.jsx';
import DragConstants from '../../lib/drag-constants';
import styles from './selector.css';
const Selector = props => {
const {
buttons,
containerRef,
dragType,
isRtl,
items,
selectedItemIndex,
draggingIndex,
draggingType,
ordering,
onAddSortable,
onRemoveSortable,
onDeleteClick,
onDuplicateClick,
onExportClick,
onItemClick
} = props;
const isRelevantDrag = draggingType === dragType;
let newButtonSection = null;
if (buttons.length > 0) {
const {img, title, onClick} = buttons[0];
const moreButtons = buttons.slice(1);
newButtonSection = (
);
}
return (
{items.map((item, index) => (
))}
{newButtonSection}
);
};
Selector.propTypes = {
buttons: PropTypes.arrayOf(PropTypes.shape({
title: PropTypes.string.isRequired,
img: PropTypes.string.isRequired,
onClick: PropTypes.func
})),
containerRef: PropTypes.func,
dragType: PropTypes.oneOf(Object.keys(DragConstants)),
draggingIndex: PropTypes.number,
draggingType: PropTypes.oneOf(Object.keys(DragConstants)),
isRtl: PropTypes.bool,
items: PropTypes.arrayOf(PropTypes.shape({
url: PropTypes.string,
// eslint-disable-next-line react/forbid-prop-types
name: PropTypes.any
})),
onAddSortable: PropTypes.func,
onDeleteClick: PropTypes.func,
onDuplicateClick: PropTypes.func,
onExportClick: PropTypes.func,
onItemClick: PropTypes.func.isRequired,
onRemoveSortable: PropTypes.func,
ordering: PropTypes.arrayOf(PropTypes.number),
selectedItemIndex: PropTypes.number.isRequired
};
export default SortableHOC(Selector);