lost-sia
Version:
Single Image Annotation Tool
2 lines (1 loc) • 1.09 kB
JavaScript
import{jsxs as n,Fragment as v,jsx as o}from"react/jsx-runtime";import{useState as g}from"react";import{CPopover as w,CDropdown as D,CDropdownToggle as x,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,C]=g(""),a=d.filter(e=>e.name.toLowerCase().includes(s.toLowerCase())),h=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(v,{children:[o(w,{content:`Default Label: ${p?.name}`,visible:i&&p!==void 0,children:o("div",{style:{marginLeft:80}})}),n(D,{visible:i,autoClose:!1,style:{marginTop:-25},children:[o(x,{style:{display:"none"}}),n(y,{children:[o("div",{className:"px-3 py-2",children:o(F,{placeholder:"Filter label...",value:s,onChange:e=>C(e.target.value),autoFocus:!0})}),o(L,{}),a.length>0?a.map(e=>o(c,{onClick:()=>h(e),children:e.name},e.id)):o(c,{disabled:!0,children:"No results"})]})]})]})};export{S as default};