import { Badge } from "@prismicio/editor-ui"; import { Menu, MenuButton, MenuItem, MenuList } from "@reach/menu-button"; import React, { Fragment } from "react"; import { Draggable } from "react-beautiful-dnd"; import { AiOutlineEdit } from "react-icons/ai"; import { BsThreeDotsVertical } from "react-icons/bs"; import { FaBars } from "react-icons/fa"; import { Box, Flex, useThemeUI } from "theme-ui"; import { AnyObjectSchema } from "yup"; import { TabField } from "@/legacy/lib/models/common/CustomType"; import { Widget } from "@/legacy/lib/models/common/widgets/Widget"; import Li from "../Li"; import SliceMachineIconButton from "../SliceMachineIconButton"; import ItemHeader from "./Header"; export type Item = { key: string; value: F }; interface ListItemProps { item: Item; index: number; deleteItem: (key: string) => void; enterEditMode: ( itemInfo: [string, F], modelFieldName: string | undefined, index: number, ) => void; modelFieldName?: string; renderFieldAccessor?: (key: string) => string; HintElement?: JSX.Element; CustomEditElement?: JSX.Element; CustomEditElements?: JSX.Element[]; widget: Widget; draggableId: string; testId: string; isRepeatableCustomType?: boolean; children: React.ReactNode; } function ListItem({ item, index, deleteItem, enterEditMode, modelFieldName, renderFieldAccessor, HintElement, CustomEditElement, CustomEditElements, widget, draggableId, testId, isRepeatableCustomType, children, }: ListItemProps): JSX.Element { const { theme } = useThemeUI(); const { key, // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment value: { config, type }, } = item; const shouldDisplayRepeatableBadge = Boolean( (type === "Link" || type === "Group") && config?.repeat, ); return ( {(provided) => (
  • `1px solid ${String(t.colors?.borders)}`, }} > {shouldDisplayRepeatableBadge && ( )} {CustomEditElements ? CustomEditElements : null} {CustomEditElement ? ( CustomEditElement ) : ( enterEditMode( [key, item.value], modelFieldName, index, ) } /> )} { // Prevent deletion of UID for repeatable type !(isRepeatableCustomType === true && type == "UID") && ( deleteItem(key)} > Delete field ) } {HintElement ? HintElement : null} {children}
  • )}
    ); } export default ListItem;