| | |
| | | import { |
| | | useCSVDownloader, |
| | | } from 'react-papaparse' |
| | | import { Menu, MenuButton, MenuItems, Transition } from '@headlessui/react' |
| | | import { Menu, Transition } from '@headlessui/react' |
| | | import Button from '../../../base/button' |
| | | import AddAnnotationModal from '../add-annotation-modal' |
| | | import type { AnnotationItemBasic } from '../type' |
| | |
| | | const Operations = () => { |
| | | return ( |
| | | <div className="w-full py-1"> |
| | | <button className='mx-1 flex h-9 w-[calc(100%_-_8px)] cursor-pointer items-center space-x-2 rounded-lg px-3 py-2 hover:bg-components-panel-on-panel-item-bg-hover disabled:opacity-50' onClick={() => { |
| | | <button className='h-9 py-2 px-3 mx-1 flex items-center space-x-2 hover:bg-components-panel-on-panel-item-bg-hover rounded-lg cursor-pointer disabled:opacity-50 w-[calc(100%_-_8px)]' onClick={() => { |
| | | setShowBulkImportModal(true) |
| | | }}> |
| | | <FilePlus02 className='h-4 w-4 text-text-tertiary' /> |
| | | <span className='system-sm-regular grow text-left text-text-secondary'>{t('appAnnotation.table.header.bulkImport')}</span> |
| | | <FilePlus02 className='w-4 h-4 text-text-tertiary' /> |
| | | <span className='grow text-text-secondary system-sm-regular text-left'>{t('appAnnotation.table.header.bulkImport')}</span> |
| | | </button> |
| | | <Menu as="div" className="relative h-full w-full"> |
| | | <MenuButton className='mx-1 flex h-9 w-[calc(100%_-_8px)] cursor-pointer items-center space-x-2 rounded-lg px-3 py-2 hover:bg-components-panel-on-panel-item-bg-hover disabled:opacity-50'> |
| | | <FileDownload02 className='h-4 w-4 text-text-tertiary' /> |
| | | <span className='system-sm-regular grow text-left text-text-secondary'>{t('appAnnotation.table.header.bulkExport')}</span> |
| | | <ChevronRight className='h-[14px] w-[14px] shrink-0 text-text-tertiary' /> |
| | | </MenuButton> |
| | | <Menu as="div" className="relative w-full h-full"> |
| | | <Menu.Button className='h-9 py-2 px-3 mx-1 flex items-center space-x-2 hover:bg-components-panel-on-panel-item-bg-hover rounded-lg cursor-pointer disabled:opacity-50 w-[calc(100%_-_8px)]'> |
| | | <FileDownload02 className='w-4 h-4 text-text-tertiary' /> |
| | | <span className='grow text-text-secondary system-sm-regular text-left'>{t('appAnnotation.table.header.bulkExport')}</span> |
| | | <ChevronRight className='shrink-0 w-[14px] h-[14px] text-text-tertiary' /> |
| | | </Menu.Button> |
| | | <Transition |
| | | as={Fragment} |
| | | enter="transition ease-out duration-100" |
| | |
| | | leaveFrom="transform opacity-100 scale-100" |
| | | leaveTo="transform opacity-0 scale-95" |
| | | > |
| | | <MenuItems |
| | | <Menu.Items |
| | | className={cn( |
| | | 'absolute left-1 top-[1px] z-10 min-w-[100px] origin-top-right -translate-x-full rounded-xl border-[0.5px] border-components-panel-on-panel-item-bg bg-components-panel-bg py-1 shadow-xs', |
| | | 'absolute top-[1px] left-1 -translate-x-full py-1 min-w-[100px] z-10 bg-components-panel-bg border-[0.5px] border-components-panel-on-panel-item-bg origin-top-right rounded-xl shadow-xs', |
| | | )} |
| | | > |
| | | <CSVDownloader |
| | |
| | | ...list.map(item => [item.question, item.answer]), |
| | | ]} |
| | | > |
| | | <button disabled={annotationUnavailable} className='mx-1 flex h-9 w-[calc(100%_-_8px)] cursor-pointer items-center space-x-2 rounded-lg px-3 py-2 hover:bg-components-panel-on-panel-item-bg-hover disabled:opacity-50'> |
| | | <span className='system-sm-regular grow text-left text-text-secondary'>CSV</span> |
| | | <button disabled={annotationUnavailable} className='h-9 py-2 px-3 mx-1 flex items-center space-x-2 hover:bg-components-panel-on-panel-item-bg-hover rounded-lg cursor-pointer disabled:opacity-50 w-[calc(100%_-_8px)]'> |
| | | <span className='grow text-text-secondary system-sm-regular text-left'>CSV</span> |
| | | </button> |
| | | </CSVDownloader> |
| | | <button disabled={annotationUnavailable} className={cn('mx-1 flex h-9 w-[calc(100%_-_8px)] cursor-pointer items-center space-x-2 rounded-lg px-3 py-2 hover:bg-components-panel-on-panel-item-bg-hover disabled:opacity-50', '!border-0')} onClick={JSONLOutput}> |
| | | <span className='system-sm-regular grow text-left text-text-secondary'>JSONL</span> |
| | | <button disabled={annotationUnavailable} className={cn('h-9 py-2 px-3 mx-1 flex items-center space-x-2 hover:bg-components-panel-on-panel-item-bg-hover rounded-lg cursor-pointer disabled:opacity-50 w-[calc(100%_-_8px)]', '!border-0')} onClick={JSONLOutput}> |
| | | <span className='grow text-text-secondary system-sm-regular text-left'>JSONL</span> |
| | | </button> |
| | | </MenuItems> |
| | | </Menu.Items> |
| | | </Transition> |
| | | </Menu> |
| | | </div> |
| | |
| | | return ( |
| | | <div className='flex space-x-2'> |
| | | <Button variant='primary' onClick={() => setShowAddModal(true)}> |
| | | <RiAddLine className='mr-0.5 h-4 w-4' /> |
| | | <RiAddLine className='w-4 h-4 mr-0.5' /> |
| | | <div>{t('appAnnotation.table.header.addAnnotation')}</div> |
| | | </Button> |
| | | <CustomPopover |
| | |
| | | trigger="click" |
| | | btnElement={ |
| | | <Button variant='secondary' className='w-8 p-0'> |
| | | <RiMoreFill className='h-4 w-4' /> |
| | | <RiMoreFill className='w-4 h-4' /> |
| | | </Button> |
| | | } |
| | | btnClassName='p-0 border-0' |
| | | className={'!z-20 h-fit !w-[155px]'} |
| | | className={'!w-[155px] h-fit !z-20'} |
| | | popupClassName='!w-full !overflow-visible' |
| | | manualClose |
| | | /> |