/** * External dependencies */ import { createElement } from '@wordpress/element'; import { Toolbar, ToolbarButton, ToolbarGroup } from '@wordpress/components'; import { chevronRight, chevronLeft, trash } from '@wordpress/icons'; import { MediaItem, MediaUpload } from '@wordpress/media-utils'; import { __ } from '@wordpress/i18n'; /** * Internal dependencies */ import { CoverImageIcon } from './icons'; import { SortableHandle } from '../sortable'; import { MediaUploadComponentType } from './types'; export type ImageGalleryToolbarProps = { childIndex: number; moveItem: ( fromIndex: number, toIndex: number ) => void; removeItem: ( removeIndex: number ) => void; replaceItem: ( replaceIndex: number, media: { id: number } & MediaItem ) => void; setToolBarItem: ( key: string | null ) => void; lastChild: boolean; MediaUploadComponent: MediaUploadComponentType; } & React.HTMLAttributes< HTMLDivElement >; export const ImageGalleryToolbar: React.FC< ImageGalleryToolbarProps > = ( { childIndex, moveItem, removeItem, replaceItem, setToolBarItem, lastChild, MediaUploadComponent = MediaUpload, }: ImageGalleryToolbarProps ) => { const moveNext = () => { moveItem( childIndex, childIndex + 1 ); }; const movePrevious = () => { moveItem( childIndex, childIndex - 1 ); }; const setAsCoverImage = ( coverIndex: number ) => { moveItem( coverIndex, 0 ); setToolBarItem( null ); }; const isCoverItem = childIndex === 0; return (