UNPKG

lost-sia

Version:

Single Image Annotation Tool

2 lines (1 loc) 1.16 kB
import{jsxs as n,Fragment as C,jsx as o}from"react/jsx-runtime";import{useState as g}from"react";import{CPopover as w,CDropdown as x,CDropdownToggle as D,CDropdownMenu as y,CFormInput as F,CDropdownDivider as L,CDropdownItem as c}from"@coreui/react";const S=({defaultLabelId:r,isVisible:i,selectedLabelsIds:l,possibleLabels:d,isMultilabel:f=!1,onLabelSelect:m})=>{const[s,h]=g(""),a=d.filter(e=>e.name.toLowerCase().includes(s.toLowerCase())),v=e=>{let t=[];if(f){t=[...l];const u=l.indexOf(e.id);u===-1?t.push(e.id):t.splice(u,1)}else t=[e.id];m(t)},p=r?d.find(e=>e.id===r):void 0;return n(C,{children:[o(w,{content:`Default Label: ${p?.name}`,visible:i&&p!==void 0,children:o("div",{style:{marginLeft:80}})}),n(x,{visible:i,autoClose:!1,style:{marginTop:-25},children:[o(D,{style:{display:"none"}}),n(y,{children:[o("div",{className:"px-3 py-2",children:o(F,{placeholder:"Filter label...",value:s,onChange:e=>h(e.target.value),autoFocus:!0})}),o(L,{}),o("div",{style:{maxHeight:"200px",overflowY:"auto"},children:a.length>0?a.map(e=>o(c,{onClick:()=>v(e),children:e.name},e.id)):o(c,{disabled:!0,children:"No results"})})]})]})]})};export{S as default};