import React, { memo } from "react";
import { useTranslation } from "react-i18next";
import styled from "styled-components";
import debounce from "lodash.debounce";
import { useItemActions } from "react-sync-board";
import { search, uid } from "../../utils";
import Chevron from "../../ui/Chevron";
const StyledItemList = styled.ul`
display: flex;
flex-flow: row wrap;
list-style: none;
margin: 0;
padding: 0;
& li.group {
background-color: rgba(0, 0, 0, 0.1);
padding: 0 0.5em;
flex-basis: 100%;
}
overflow: visible;
`;
const StyledItem = styled.li`
display: block;
padding: 0.5em;
margin: 0.2em;
cursor: pointer;
opacity: 0.7;
&:hover {
opacity: 1;
}
& > div {
display: flex;
flex-direction: column;
align-items: center;
pointer-events: none;
max-width: 80px;
& > span {
margin-top: 0.2em;
text-align: center;
max-width: 80px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
padding: 0.2em 0.5em;
}
}
&:hover > div > span {
z-index: 2;
max-width: none;
overflow: visible;
background-color: #222;
box-shadow: 0px 3px 6px #00000029;
}
`;
const size = 60;
const NewItem = memo(({ type, template, component: Component, name }) => {
const { pushItem } = useItemActions();
const addItem = React.useCallback(async () => {
pushItem({
...(typeof template === "function" ? template() : template),
id: uid(),
type,
});
}, [pushItem, template, type]);
return (