import { PencilIcon, TrashIcon, ChevronUpDownIcon } from '@heroicons/react/24/outline'; import * as React from 'react'; import { SortableHandle, SortableElement } from 'react-sortable-hoc'; import { LinkButton } from '../Common/LinkButton'; import { Alert } from '../Modals/Alert'; import * as l10n from '@vscode/l10n'; import { LocalizationKey } from '../../../localization'; export interface ISortableItemProps { value: string; index: number; crntIndex: number; selectedIndex: number | null; onSelectedIndexChange: (index: number) => void; onDeleteItem: (index: number) => void; } const DragHandle = SortableHandle(() => ); export const SortableItem = SortableElement( ({ value, selectedIndex, crntIndex, onSelectedIndexChange, onDeleteItem }: ISortableItemProps) => { const [showAlert, setShowAlert] = React.useState(false); const deleteItemConfirm = () => { setShowAlert(true); }; return ( <>
  • onSelectedIndexChange(crntIndex)} > {value}
    onSelectedIndexChange(crntIndex)}> {l10n.t(LocalizationKey.commonEdit)} deleteItemConfirm()}> {l10n.t(LocalizationKey.commonDelete)}
  • {showAlert && ( setShowAlert(false)} trigger={() => { setShowAlert(false); onDeleteItem(crntIndex); }} /> )} ); } );