lost-sia 2.0.1-alpha13 → 2.0.1-alpha15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Annotation/ui/AnnotationComponent.js +1 -1
- package/dist/Annotation/ui/atoms/DaviIcon.d.ts +1 -1
- package/dist/Canvas/Canvas.js +1 -1
- package/dist/IconButton.d.ts +25 -0
- package/dist/IconButton.js +1 -0
- package/dist/Sia.js +1 -1
- package/dist/Toolbar/ToolbarItems/AccessibilityTools.js +1 -1
- package/dist/Toolbar/ToolbarItems/AnnoToolSelector.js +1 -1
- package/dist/Toolbar/ToolbarItems/ImageToolItems/ImageLabelInput.js +1 -1
- package/dist/Toolbar/ToolbarItems/ImageTools.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/models/index.d.ts +1 -1
- package/package.json +3 -2
- package/src/AnnoExampleViewer.jsx +18 -18
- package/src/Annotation/logic/Annotation.ts +24 -24
- package/src/Annotation/ui/AnnotationComponent.tsx +89 -96
- package/src/Annotation/ui/atoms/DaviIcon.tsx +12 -22
- package/src/Annotation/ui/atoms/PolygonArea.tsx +35 -35
- package/src/Annotation/ui/tools/Point.tsx +17 -17
- package/src/Canvas/Canvas.tsx +48 -17
- package/src/Canvas/LabelInput.tsx +27 -34
- package/src/IconButton.tsx +119 -0
- package/src/InfoBoxes/AnnoDetails.jsx +53 -53
- package/src/InfoBoxes/AnnoStats.jsx +41 -41
- package/src/InfoBoxes/InfoBox.jsx +16 -16
- package/src/InfoBoxes/LabelInfo.jsx +30 -30
- package/src/SIASettingButton.jsx +25 -25
- package/src/Sia.tsx +43 -15
- package/src/Toolbar/Toolbar.tsx +25 -25
- package/src/Toolbar/ToolbarItems/AccessibilityTools.tsx +23 -43
- package/src/Toolbar/ToolbarItems/AnnoToolSelector.tsx +53 -43
- package/src/Toolbar/ToolbarItems/ImageToolItems/ImageLabelInput.tsx +71 -71
- package/src/Toolbar/ToolbarItems/ImageToolItems/TagLabel.tsx +24 -24
- package/src/Toolbar/ToolbarItems/ImageTools.tsx +28 -30
- package/src/Toolbar/ToolbarItems/Instructions.tsx +47 -50
- package/src/Toolbar/ToolbarItems/InstructionsModal.tsx +8 -8
- package/src/index.ts +1 -0
- package/src/models/AnnotationMode.ts +1 -1
- package/src/models/AnnotationStatus.ts +1 -1
- package/src/models/AnnotationTool.ts +1 -1
- package/src/models/CanvasAction.ts +1 -1
- package/src/models/Direction.ts +1 -1
- package/src/models/EditorModes.ts +1 -1
- package/src/models/KeyAction.ts +1 -1
- package/src/models/NotificationType.ts +1 -1
- package/src/models/index.ts +6 -12
- package/src/siaDummyData.js +71 -71
- package/src/stories/Button.jsx +11 -15
- package/src/stories/Button.stories.js +17 -17
- package/src/stories/Canvas/CanvasWithOffset.stories.tsx +25 -25
- package/src/stories/FilterDropdown.stories.ts +10 -10
- package/src/stories/Header.jsx +8 -13
- package/src/stories/Header.stories.js +9 -9
- package/src/stories/Page.jsx +21 -26
- package/src/stories/Page.stories.js +14 -14
- package/src/stories/SIA2/DemoWrapper.stories.tsx +22 -22
- package/src/stories/Toolbar/ImageTools/TagLabel.stories.tsx +11 -11
- package/src/stories/Toolbar/Instructions.stories.tsx +11 -11
- package/src/stories/Toolbar/Toolbar.stories.tsx +20 -20
- package/src/stories/siaDummyData.js +71 -71
- package/src/stories/siaDummyData2.ts +72 -72
- package/src/types.ts +47 -47
- package/src/utils/KeyMapper.ts +56 -61
- package/src/utils/TimeUtils.ts +7 -10
- package/src/utils/color.ts +25 -25
- package/src/utils/hist.js +22 -22
- package/src/utils/index.ts +3 -3
- package/src/utils/keyActions.js +81 -81
- package/src/utils/mouse.ts +9 -9
- package/src/utils/transform.ts +66 -72
- package/src/utils/uiConfig.js +19 -22
- package/src/utils/windowViewport.ts +10 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as G,jsx as
|
|
1
|
+
import{jsxs as G,jsx as l}from"react/jsx-runtime";import h from"../../models/AnnotationTool.js";import{getDefaultColor as L}from"../../utils/color.js";import H from"./tools/Point.js";import J from"./tools/Line.js";import K from"./atoms/AnnoBar.js";import Q from"../../models/CanvasAction.js";import X from"./tools/BBox.js";import Y from"./tools/Polygon.js";import{useState as I,useRef as x,useEffect as M}from"react";import e from"../../models/AnnotationMode.js";import Z from"../../utils/TimeUtils.js";const lo=({scaledAnnotation:r,annotationSettings:m,possibleLabels:b,svgScale:i,svgTranslation:f,pageToStageOffset:a,strokeWidth:B,nodeRadius:P,isSelected:c,isDisabled:V=!1,onFinishAnnoCreate:w,onLabelIconClicked:W,onAction:k=(n,C)=>{},onAnnoChanged:A=n=>{},onAnnotationModeChange:F=n=>{},onNotification:O=n=>{}})=>{const[n,C]=I(r.coordinates),[t,d]=I(r.mode),[j,D]=I(!1),R=x(void 0),[_,U]=I();M(()=>{R.current=_},[_]);const y=x(n);M(()=>{y.current=n},[n]);const N=()=>{d(e.VIEW);const o={...r,coordinates:y.current};w(o)},q=o=>b.find(s=>s.id===o),T=(()=>{if(!r.labelIds||r.labelIds.length==0)return L();const o=q(r.labelIds[0]);return o===void 0||o.color===void 0||o.color===null?L():o.color})(),u={stroke:T,fill:T,strokeWidth:B/i,r:P/i},p=o=>{C(o);let s=o;[e.ADD,e.MOVE].includes(t)&&(s=o.slice(0,-1)),A({...r,coordinates:s})},g=o=>{[e.ADD,e.CREATE,e.MOVE].includes(t)||(d(e.MOVE),U(performance.now())),C(o)},E=()=>{d(e.VIEW);const o=Z.getRoundedDuration(R.current,performance.now()),s=isNaN(r.annoTime)||r.annoTime===null?o:r.annoTime+o;A({...r,coordinates:y.current,annoTime:s})};M(()=>{F(t)},[t]),M(()=>{t===e.CREATE||t===e.ADD||C(r.coordinates)},[r]);const z=()=>{switch(r.type){case h.Point:return l(H,{isSelected:c,annotationSettings:m,coordinates:n[0],pageToStageOffset:a,svgScale:i,svgTranslation:f,style:u,onMoving:o=>g([o]),onMoved:E,onIsDraggingStateChanged:D});case h.Line:return l(J,{annotationSettings:m,coordinates:n,isSelected:c,pageToStageOffset:a,annotationMode:t,setAnnotationMode:d,svgScale:i,svgTranslation:f,style:u,onAddNode:p,onDeleteNode:p,onMoving:g,onMoved:E,onIsDraggingStateChanged:D,onFinishAnnoCreate:N});case h.BBox:return l(X,{annotationMode:t,annotationSettings:m,startCoords:n[0],endCoords:n[1],isSelected:c,pageToStageOffset:a,style:u,svgScale:i,svgTranslation:f,onDeleteNode:()=>{console.log("TODO")},onIsDraggingStateChanged:D,onFinishAnnoCreate:N,onMoving:g,onMoved:E});case h.Polygon:return l(Y,{annotationSettings:m,coordinates:n,isSelected:c,isDisabled:V,pageToStageOffset:a,annotationMode:t,setAnnotationMode:d,svgScale:i,svgTranslation:f,style:u,onAddNode:p,onDeleteNode:p,onMoving:g,onMoved:E,onNotification:O,onIsDraggingStateChanged:D,onFinishAnnoCreate:N})}};return G("g",{onClick:o=>{o.stopPropagation(),k(r,Q.ANNO_SELECTED)},children:[!j&&t!==e.CREATE&&l(K,{annotationCoordinates:n,canLabel:m.canLabel,labels:b,color:T,isSelected:c,selectedLabelIds:r.labelIds,style:u,svgScale:i,onLabelIconClicked:W}),z()]})};export{lo as default};
|
|
@@ -5,5 +5,5 @@ type DaviIconProps = {
|
|
|
5
5
|
size: number;
|
|
6
6
|
onClick?: () => void;
|
|
7
7
|
};
|
|
8
|
-
declare const DaviIcon: ({ x, y, color, size, onClick
|
|
8
|
+
declare const DaviIcon: ({ x, y, color, size, onClick }: DaviIconProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
9
|
export default DaviIcon;
|
package/dist/Canvas/Canvas.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as
|
|
1
|
+
import{jsxs as W,jsx as x,Fragment as Qe}from"react/jsx-runtime";import{useState as E,useRef as Z,useEffect as M}from"react";import w from"../models/AnnotationTool.js";import i from"../models/EditorModes.js";import Ze from"../utils/KeyMapper.js";import a from"../models/KeyAction.js";import pe from"../Annotation/logic/Annotation.js";import qe from"../models/CanvasAction.js";import et from"../Annotation/ui/AnnotationComponent.js";import he from"../utils/mouse.js";import N from"../models/AnnotationMode.js";import tt from"./LabelInput.js";import{FontAwesomeIcon as nt}from"@fortawesome/react-fontawesome";import{faBan as ot}from"@fortawesome/free-solid-svg-icons";import D from"../models/AnnotationStatus.js";import C from"../utils/transform.js";import rt from"../models/NotificationType.js";import st from"../utils/TimeUtils.js";import xe from"../utils/windowViewport.js";const wt=({annotations:O=[],annotationSettings:B,defaultLabelId:q,image:ee,isFullscreen:Ce=!1,isImageJunk:K=!1,isPolygonSelectionMode:F=!1,polygonOperationResult:X={annotationsToDelete:[],polygonsToCreate:[]},possibleLabels:te,preventScrolling:ne=!0,selectedAnnotation:r,selectedAnnoTool:R,toolbarHeight:U=0,uiConfig:z,onAnnoCreated:Oe,onAnnoCreationFinished:oe,onAnnoChanged:re,onAnnoEditing:Te=g=>{},onNotification:se=g=>{},onRequestNewAnnoId:k,onSelectAnnotation:A,onSetIsImageJunk:ve,onSetSelectedTool:Ae=g=>{},onShouldDeleteAnno:ie})=>{const[g,T]=E(i.VIEW),[Me,Ie]=E(),[ce,we]=E(q),[V,De]=E({x:-1,y:-1}),[ae,le]=E(0),L={x:V.x,y:V.y},[u,Y]=E({x:-1,y:-1}),[d,G]=E({x:-1,y:-1}),[m,de]=E({x:-1,y:-1}),[l,P]=E(1),[c,S]=E({x:0,y:0}),H={x:c.x+ae,y:c.y},[p,$]=E(),[j,_]=E(!1),fe=Z(null),h=Z(null),y=Z(null),v=((e,t)=>{if(e.x===0||e.y===0||t.x===0||t.y===0)return 0;const n=t.x/e.x,o=t.y/e.y;return Math.min(n,o)})(u,d),Se=()=>{if((y==null?void 0:y.current)===null)return{x:0,y:0};const e=u.x*v;if(z.imageCentered&&d.x>e){const f=(d.x-e)/2;le(f)}else le(0);const{top:t,left:n}=h.current.getBoundingClientRect(),o={x:n+window.scrollX,y:t+window.scrollY};De(o)},_e=new Ze(e=>Pe(e)),be=e=>{T(i.CREATE);const t=C.convertStageCoordinatesToPercentaged([e],v,u);R===w.BBox&&t.push(t[0]);const n=k(),o=new pe(n,R,t);if(Ie(performance.now()),ce!==void 0&&(o.labelIds=[ce]),Oe(o),R===w.Point){const s={...o,coordinates:[e],annoTime:0};Q(s)}},Ne=()=>{if(r&&![w.Line,w.Polygon].includes(r.type))return;const e=O.find(n=>n.internalId===(r==null?void 0:r.internalId));if(e===void 0)return;T(i.CREATE),Ae(e.type);const t={...e,mode:N.CREATE,status:D.CREATING,internalId:k(),selectedNode:e.coordinates.length-1};Te(t)},Re=()=>{const e=r?r.internalId:0,t=O.find(n=>n.internalId>e);if(t)return A(t);if(O.length>0)return A(O[0])},ke=()=>{const e=r?r.internalId:0,t=[...O];t.sort((o,s)=>s.internalId-o.internalId);const n=t.find(o=>o.internalId<e);if(n)return A(n);if(O.length>0)return A(O[O.length-1])},Ve=()=>{if(r){const e=JSON.stringify(r);localStorage.setItem("lostAnnotationClipboard",e);const t={title:"Success",message:"Annotation copied",type:rt.SUCCESS};se(t)}},Le=()=>{const e=localStorage.getItem("lostAnnotationClipboard");if(e==null)return;const t=JSON.parse(e);t.internalId=k(),t.externalId="",oe(t,!0),A(t)},Pe=e=>{switch(e){case a.EDIT_LABEL:r&&_(!0);break;case a.DELETE_ANNO:r&&ie(r.internalId);break;case a.DELETE_ANNO_IN_CREATION:g===i.CREATE&&(ie(r.internalId),T(i.VIEW));break;case a.ENTER_ANNO_ADD_MODE:console.log("KeyAction TODO: ENTER_ANNO_ADD_MODE");break;case a.LEAVE_ANNO_ADD_MODE:console.log("KeyAction TODO: LEAVE_ANNO_ADD_MODE");break;case a.UNDO:console.log("KeyAction TODO: UNDO");break;case a.REDO:console.log("KeyAction TODO: REDO");break;case a.TRAVERSE_ANNOS:Re();break;case a.TRAVERSE_ANNOS_BACKWARDS:ke();break;case a.CAM_MOVE_LEFT:b(20*l,0);break;case a.CAM_MOVE_RIGHT:b(-20*l,0);break;case a.CAM_MOVE_UP:b(0,20*l);break;case a.CAM_MOVE_DOWN:b(0,-20*l);break;case a.CAM_MOVE_STOP:console.log("KeyAction TODO: CAM_MOVE_STOP");break;case a.COPY_ANNOTATION:Ve();break;case a.PASTE_ANNOTATION:Le();break;case a.RECREATE_ANNO:console.log("KeyAction TODO: RECREATE_ANNO"),Ne();break;case a.TOGGLE_IMAGE_JUNK:if(g===i.ADD||g===i.CREATE)return;ve(!K);break;default:console.log("Unknown KeyAction",e);break}},b=(e,t)=>{let n=c.x+e/l,o=c.y+t/l;const s=d.x*.45,f=d.x*.55,I=d.y*.45,je=d.y*.55,Je={x:0,y:0},Ee=xe.getViewportCoordinates(c,d,l,Je),me=xe.getViewportCoordinates(c,d,l,d);Ee.vX>=s?n=c.x-5:me.vX<=f?n=c.x+5:Ee.vY>=I?o=c.y-5:me.vY<=je&&(o=c.y+5),S({x:n,y:o})},J=(e=>m.x<=0||m.y<=0||u.x<=0||u.y<=0?[]:O.map(n=>({...n,coordinates:C.convertPercentagedCoordinatesToStage(n.coordinates,u,m)})))(),We=()=>{if(T(i.VIEW),de({x:-1,y:-1}),y.current!==null){const{width:e,height:t}=y.current.getBoundingClientRect();Y({x:e,y:t})}P(1),S({x:0,y:0}),$(void 0),_(!1)};M(()=>{var e;(e=fe.current)==null||e.focus()},[]),M(()=>{if((h==null?void 0:h.current)!==void 0){const{width:e,height:t}=h.current.getBoundingClientRect(),n=t-U;G({x:e,y:n});const o=new ResizeObserver(()=>{const{width:s,height:f}=h.current.getBoundingClientRect(),I=f-U;G({x:s,y:I})});return o.observe(h.current),()=>o.disconnect()}We()},[ee,Ce]),M(()=>{Se()},[y,c,d]),M(()=>{if(h.current===null)return;const{width:e,height:t}=h.current.getBoundingClientRect(),n=t-U;G({x:e,y:n})},[h]),M(()=>{if(y.current===null)return;const{width:e,height:t}=y.current.getBoundingClientRect();Y({x:e,y:t});const n=new ResizeObserver(()=>{const{width:o,height:s}=y.current.getBoundingClientRect();Y({x:o,y:s})});return n.observe(y.current),()=>n.disconnect()},[y]),M(()=>{if(v===0)return;const e={x:u.x*v,y:u.y*v};de(e)},[v,u]),M(()=>{F&&X.polygonsToCreate!==void 0&&X.polygonsToCreate.forEach(e=>{const t=k(),n=new pe(t,e.type,C.convertPercentagedCoordinatesToStage(e.coordinates,u,m),N.VIEW,D.CREATED);Q(n)})},[X]);const Q=e=>{T(i.VIEW);const t={...e,mode:N.VIEW};if(e.type!==w.Point){const s=st.getRoundedDuration(Me,performance.now());t.annoTime=s}const n=C.convertStageCoordinatesToPercentaged(e.coordinates,v,u);t.coordinates=n,re(t);const o=R===w.Point||F;oe(t,o)},Be=e=>{e.preventDefault(),_e.keyDown(e.key,e.shiftKey,e.ctrlKey)},Ke=e=>{e.preventDefault()},Fe=e=>{if(e.button!==0){if(e.button===1)T(i.CAMERA_MOVE);else if(e.button===2){if(!B.canCreate||g===i.ADD||g===i.CREATE)return;const t=he.getAntiScaledMouseStagePosition(e,L,l,c),n={x:t.x-ae,y:t.y};be(n)}}},Xe=()=>{ne&&(document.body.style.overflow="hidden")},Ue=e=>{switch(e.button){case 1:T(i.VIEW);break}},ue=(e,t)=>{g===i.CAMERA_MOVE&&b(e,t)},ze=()=>{ne&&(document.body.style.overflow="")},Ye=e=>{const o=(e.deltaY<0?1:-1)>0?l*1.25:l/1.25,s=he.getAntiScaledMouseStagePosition(e,L,l,c),f=l/o,I={x:f*(s.x+c.x)-s.x,y:f*(s.y+c.y)-s.y};o<1?(P(1),(c.x!=0||c.y!=0)&&S({x:0,y:0})):o>200?(P(200),S(I)):(P(o),S(I))},Ge=(e,t)=>{if(t!==qe.ANNO_SELECTED){console.log("Unknown Canvas Action:",t);return}const n={...e,coordinates:C.convertStageCoordinatesToPercentaged([...e.coordinates],v,u)};A(n);const o=C.getMostLeftPoints(e.coordinates),s=C.getTopPoint(o)[0],f=C.convertStageToPage(s,L,l,c);$(f)},ge=e=>{const t=C.convertStageCoordinatesToPercentaged(e.coordinates,v,u),n={...e,coordinates:t};n.status===D.LOADED&&(n.status=D.CHANGED),re(n)},He=()=>{if(g===i.CAMERA_MOVE)return x(Qe,{});const t=[i.CREATE,i.ADD,i.MOVE].includes(g),n=J.map(o=>{const s=o.internalId===(r==null?void 0:r.internalId);return t&&!s?x("g",{},`annotationComponent_${o.internalId}`):x(et,{scaledAnnotation:o,annotationSettings:B,possibleLabels:te,svgScale:l,svgTranslation:H,pageToStageOffset:L,nodeRadius:z.nodeRadius,strokeWidth:z.strokeWidth,isSelected:s,isDisabled:F&&s,onFinishAnnoCreate:Q,onLabelIconClicked:()=>_(!0),onAction:Ge,onAnnoChanged:ge,onAnnotationModeChange:f=>{f===N.MOVE&&T(i.MOVE),g===i.MOVE&&f===N.VIEW&&T(i.VIEW)},onNotification:se},`annotationComponent_${o.internalId}`)});if(r){const o=J.find(f=>f.internalId===(r==null?void 0:r.internalId)),s=J.indexOf(o);n.push(n.splice(s,1)[0])}return x("g",{children:n})},$e=()=>x("circle",{cx:m.x/2,cy:m.y/2,r:"100%",style:{opacity:0},onContextMenu:e=>e.preventDefault(),onClick:()=>{_(!1)}}),ye={x:V.x+d.x/2,y:V.y+d.y/2};return W("div",{ref:h,style:{flex:"1 1 auto",minHeight:0,display:"flex",flexDirection:"column"},children:[x("div",{style:{position:"absolute",left:(p==null?void 0:p.x)!==void 0?p.x:0,top:(p==null?void 0:p.y)!==void 0?p.y:0,display:(p==null?void 0:p.y)!==void 0?"inherit":"none",zIndex:j?7e3:-1},children:x(tt,{defaultLabelId:q,isVisible:j,selectedLabelsIds:r==null?void 0:r.labelIds,possibleLabels:te,isMultilabel:B.canHaveMultipleLabels,onLabelSelect:e=>{if(_(!1),e.length>0){const o=e.filter(s=>!r.labelIds.includes(s));o.length>0&&we(o[0])}const t=r.status===D.LOADED?D.CHANGED:r.status,n={...r,coordinates:C.convertPercentagedCoordinatesToStage(r.coordinates,u,m),labelIds:[...e],status:t};ge(n)}})}),K&&W("div",{style:{position:"absolute",left:ye.x,top:ye.y,transform:"translate(-50%, -50%)",textAlign:"center",color:"white"},children:[x(nt,{icon:ot,size:"5x",style:{marginBottom:15}}),x("h2",{children:"Marked as Junk"})]}),W("svg",{ref:fe,style:{flex:"1 1 auto",minHeight:0},onKeyDown:Be,onKeyUp:Ke,onMouseMove:e=>ue(e.movementX,e.movementY),tabIndex:0,onMouseDown:e=>Fe(e),children:[W("g",{transform:`scale(${l}) translate(${H.x}, ${H.y})`,onMouseOver:Xe,onMouseLeave:ze,onMouseUp:Ue,onWheel:Ye,onMouseMove:e=>ue(e.movementX,e.movementY),onClick:()=>{A(void 0)},children:[x("image",{onContextMenu:e=>e.preventDefault(),href:ee,ref:y,width:m.x>0?m.x:void 0,height:m.y>0?m.y:void 0}),He()]}),j&&$e(),K&&x("rect",{x:"0",y:"0",width:d.x,height:d.y,style:{opacity:.8},onContextMenu:e=>e.preventDefault(),onClick:()=>{$(void 0)}})]})]})};export{wt as default};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { IconDefinition } from '@fortawesome/free-solid-svg-icons';
|
|
2
|
+
import { CSSProperties } from 'react';
|
|
3
|
+
import { SizeProp } from '@fortawesome/fontawesome-svg-core';
|
|
4
|
+
type IconButtonProps = {
|
|
5
|
+
loadingSize?: SizeProp;
|
|
6
|
+
isLoading?: boolean;
|
|
7
|
+
margin?: number;
|
|
8
|
+
icon?: IconDefinition;
|
|
9
|
+
text?: string;
|
|
10
|
+
size?: 'sm' | 'lg' | undefined;
|
|
11
|
+
isTextLeft?: boolean;
|
|
12
|
+
style?: CSSProperties;
|
|
13
|
+
id?: string;
|
|
14
|
+
type?: 'button' | 'submit' | 'reset' | undefined;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
onClick?: () => void;
|
|
17
|
+
className?: string;
|
|
18
|
+
color?: string;
|
|
19
|
+
isOutline?: boolean;
|
|
20
|
+
tooltip?: string;
|
|
21
|
+
ttipPlacement?: 'top' | 'left' | 'right' | 'auto' | 'bottom' | undefined;
|
|
22
|
+
shape?: string;
|
|
23
|
+
};
|
|
24
|
+
declare const IconButton: ({ loadingSize, isLoading, margin, icon, text, size, isTextLeft, style, id, type, disabled, onClick, className, color, isOutline, tooltip, ttipPlacement, shape, }: IconButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
export default IconButton;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as t,jsxs as w}from"react/jsx-runtime";import{faSync as A}from"@fortawesome/free-solid-svg-icons";import{FontAwesomeIcon as v}from"@fortawesome/react-fontawesome";import{CTooltip as F,CButton as y}from"@coreui/react";const D=({loadingSize:o="1x",isLoading:n=!1,margin:c=5,icon:B,text:i="",size:s,isTextLeft:j=!1,style:a={},id:I=void 0,type:N="button",disabled:e=!1,onClick:u,className:l="",color:m="primary",isOutline:C=!0,tooltip:f="",ttipPlacement:T="top",shape:b=""})=>{const r=B,p=C?"outline":void 0,x=()=>{if(n)return w("div",{className:"flex justify-center items-center",children:[t(v,{className:"mr-3",size:o||"2x",icon:A,spin:!0}),t("span",{className:"text-center",children:"Loading"})]});const d=r&&r.iconName&&r.prefix?t(v,{icon:r,size:o||"2x"},"icon"):null,h=i?t("span",{style:{marginLeft:c,marginRight:c},children:i},"text"):null;return j?[h,d]:[d,h]};return f!=""?t(F,{content:f,placement:T,children:t(y,{id:I,size:s,className:l,style:a,variant:p,disabled:e||n,onClick:u,color:e||n?"secondary":m,shape:b,children:x()})}):t(y,{size:s,type:N,className:l,style:a,variant:p,disabled:e||n,onClick:u,color:e||n?"secondary":m,children:x()})};export{D as default};
|
package/dist/Sia.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as d,jsxs as
|
|
1
|
+
import{jsx as d,jsxs as W}from"react/jsx-runtime";import{useRef as cn,useState as s,useEffect as u}from"react";import{CSpinner as q}from"@coreui/react";import fn from"./Canvas/Canvas.js";import un from"./models/AnnotationTool.js";import In from"./Toolbar/Toolbar.js";import mn from"./models/AnnotationMode.js";import hn from"./models/AnnotationStatus.js";const yn=({additionalButtons:z,allowedTools:S,polygonOperationResult:c={annotationsToDelete:[],polygonsToCreate:[]},annotationSettings:A,uiConfig:g,defaultAnnotationTool:w,defaultLabelId:M,image:I,isLoading:y=!1,isPolygonSelectionMode:D=!1,initialAnnotations:x=[],initialImageLabelIds:_=[],initialIsImageJunk:V=!1,possibleLabels:b,onAnnoCreated:G=(f,m)=>{},onAnnoCreationFinished:K=(f,m)=>{},onAnnoChanged:Q=(f,m)=>{},onAnnoDeleted:k=(f,m)=>{},onImageLabelsChanged:X=()=>{},onIsImageJunk:Y=()=>{},onNotification:Z=f=>{},onSelectAnnotation:$=f=>{}})=>{const m=cn(null),[p,E]=s(),[i,r]=s([]),[j,R]=s(),[O,nn]=s(),[l,h]=s(),[N,B]=s(w!==void 0?w:un.Point),[en,Sn]=s({flex:"1 1 auto",minHeight:0,display:"flex",flexDirection:"column"}),[tn,F]=s(_),[J,L]=s(),[C,on]=s(!1),[U,H]=s([]),T=n=>{const e=i.findIndex(a=>a.internalId===n),t=[...i],o=t.splice(e,1)[0];r(t),h(void 0),k(o,t)},sn=()=>{l!==void 0&&T(l.internalId)},an=()=>{let n=0;const e=x.map(t=>({...t,internalId:n++,mode:mn.VIEW,selectedNode:1,status:t.status,annoTime:t.annoTime!==void 0?t.annoTime:0}));H([...Array(n).keys()]),r(e)},rn=()=>{let n=0;for(;U.includes(n);)n++;const e=[...U];return e.push(n),H(e),n},ln=n=>{const e=[...i],t=e.findIndex(v=>v.internalId===(l==null?void 0:l.internalId));if(t===-1)return;const o=e.splice(t,1)[0];k(o,e);const a=[...e];a.push(n),r(a),h(n)},P=n=>{L(n),Y(n)};u(()=>{I===void 0&&(r([]),h(void 0))},[I]),u(()=>{L(V),!(I!==void 0||x.length===0)&&an()},[x]),u(()=>{F(_)},[_]),u(()=>{const e={...{canCreate:!0,canEdit:!0,canHaveMultipleLabels:!1,canLabel:!0,minimalArea:250},...A};R(e)},[A]),u(()=>{const e={...{nodeRadius:4,strokeWidth:4,imageCentered:!1},...g};nn(e)},[g]),u(()=>{const n={bbox:!0,point:!0,line:!0,junk:!0,polygon:!0};if(S===void 0)return E(n);E(S)},[S]);const dn={position:"fixed",top:0,left:0,zIndex:6e3,backgroundColor:"#ffff",width:"100%",height:"100%",padding:15};return p===void 0?d("div",{className:"d-flex justify-content-center",children:d(q,{color:"primary",style:{width:"5rem",height:"5rem"}})}):W("div",{style:{...C?dn:{},flex:"1 1 auto",minHeight:0,display:"flex",flexDirection:"column"},children:[d("div",{ref:m,style:{marginBottom:10},children:d(In,{annotationSettings:j,allowedTools:p,additionalButtons:z,isDisabled:y,isFullscreen:C,isImageJunk:J,imageLabelIds:tn,possibleLabels:b,selectedTool:N,onImageLabelsChanged:n=>{F(n),X(n)},onSetIsFullscreen:on,onSetIsImageJunk:P,onSetSelectedTool:B,onShouldDeleteSelectedAnnotation:sn})}),W("div",{style:en,children:[y&&d("div",{className:"d-flex justify-content-center",children:d(q,{color:"primary",style:{width:"5rem",height:"5rem",marginTop:200}})}),I&&i&&d(fn,{annotations:i,annotationSettings:j,defaultLabelId:M,image:I,isFullscreen:C,isImageJunk:J,isPolygonSelectionMode:D,selectedAnnotation:l,selectedAnnoTool:N,polygonOperationResult:c,possibleLabels:b,uiConfig:O,onAnnoCreated:n=>{const e=[...i];e.push(n),r(e),h(n),G(n,e)},onAnnoChanged:n=>{const e=i.findIndex(o=>o.internalId===n.internalId);if(e===-1)return;const t=[...i];t[e]=n,r(t),Q(n,t)},onAnnoCreationFinished:(n,e)=>{const t=[...i];if(D&&(c==null?void 0:c.annotationsToDelete)!==void 0&&(c.annotationsToDelete.push(l),c.annotationsToDelete.forEach(o=>{T(o.internalId);const a=t.findIndex(v=>v.internalId===o.internalId);t.splice(a,1)})),e)t.push(n);else{const o=i.findIndex(a=>a.internalId===n.internalId);t[o]=n}r(t),n.status=hn.CREATED,K(n,t)},onAnnoEditing:ln,onSetIsImageJunk:P,onNotification:Z,onRequestNewAnnoId:rn,onSelectAnnotation:n=>{h(n),$(n)},onSetSelectedTool:B,onShouldDeleteAnno:T})]})]})};export{yn as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as
|
|
1
|
+
import{jsxs as n,jsx as o}from"react/jsx-runtime";import{CButtonGroup as a}from"@coreui/react";import{faMaximize as c,faQuestion as p}from"@fortawesome/free-solid-svg-icons";import{useState as m}from"react";import u from"./InstructionsModal.js";import s from"../../IconButton.js";const M=({isDisabled:i=!1,isFullscreen:t=!1,onSetIsFullscreen:e=()=>{}})=>{const[l,r]=m(!1);return n(a,{role:"group","aria-label":"Basic example",children:[o(s,{color:"primary",icon:c,isOutline:!t,disabled:i,onClick:()=>e(!t),tooltip:"Toggle fullscreen"}),o(s,{color:"primary",icon:p,isOutline:!0,disabled:i,onClick:()=>r(!0),tooltip:"Open instructions"}),o(u,{isOpen:l,setIsOpen:r})]})};export{M as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as
|
|
1
|
+
import{jsxs as l,jsx as i}from"react/jsx-runtime";import{CButtonGroup as e}from"@coreui/react";import{pointIcon as c,lineIcon as x,bBoxIcon as u,polygonIcon as g}from"../../utils/siaIcons.js";import o from"../../models/AnnotationTool.js";import{faTrash as y}from"@fortawesome/free-solid-svg-icons";import t from"../../IconButton.js";const k=({allowedTools:r,isDisabled:n=!1,selectedTool:a,onSetSelectedTool:p,onShouldDeleteSelectedAnnotation:m=()=>{}})=>l(e,{role:"group","aria-label":"Basic example",children:[r.point&&i(t,{color:"primary",text:c(),isOutline:a!=o.Point,disabled:n,onClick:()=>p(o.Point),tooltip:"Create Point Annotation",margin:0}),r.line&&i(t,{color:"primary",text:x(),isOutline:a!=o.Line,disabled:n,onClick:()=>p(o.Line),tooltip:"Create Line Annotation",margin:0}),r.bbox&&i(t,{color:"primary",text:u(),isOutline:a!=o.BBox,disabled:n,onClick:()=>p(o.BBox),tooltip:"Create BBox Annotation",margin:0}),r.polygon&&i(t,{color:"primary",text:g(),isOutline:a!=o.Polygon,disabled:n,onClick:()=>p(o.Polygon),tooltip:"Create Polygon Annotation",margin:0}),i(t,{color:"primary",icon:y,isOutline:!0,disabled:n,onClick:m,tooltip:"Delete selected annotation",margin:0})]});export{k as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{jsx as r,jsxs as s}from"react/jsx-runtime";import{useState as C}from"react";import{CTooltip as L,CDropdown as w,CDropdownToggle as v,CDropdownMenu as T,CFormInput as x,CDropdownDivider as y,CDropdownItem as d}from"@coreui/react";import{FontAwesomeIcon as D}from"@fortawesome/react-fontawesome";import{faTag as b}from"@fortawesome/free-solid-svg-icons";import F from"./TagLabel.js";const M=({isDisabled:c,isVisible:m,selectedLabelsIds:t,possibleLabels:n,isMultilabel:p=!1,onLabelSelect:u})=>{const[i,f]=C(""),a=n.filter(e=>e.name.toLowerCase().includes(i.toLowerCase())),g=e=>{let o=[];if(p){o=[...t];const l=t.indexOf(e.id);l!==-1?o.splice(l,1):o.push(e.id)}else o=[e.id];u(o)},h=()=>n.filter(o=>t.includes(o.id));return r(L,{content:"Add Image Label",children:s(w,{visible:m,autoClose:!1,children:[r(v,{variant:"outline",caret:!1,color:c?"secondary":"primary",style:{paddingTop:0,paddingBottom:0},as:"div",children:t.length===0?r("div",{style:{marginTop:6},children:r(D,{icon:b})}):h().map(o=>r(F,{name:o.name,color:o.color,size:25,triangleSize:17,style:{marginLeft:1,marginTop:5}},o.name))}),s(T,{children:[r("div",{className:"px-3 py-2",children:r(x,{placeholder:"Filter label...",value:i,onChange:e=>f(e.target.value),autoFocus:!0})}),r(y,{}),a.length>0?a.map(e=>r(d,{onClick:()=>g(e),children:e.name},e.id)):r(d,{disabled:!0,children:"No results"})]})]})})};export{M as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as
|
|
1
|
+
import{jsxs as n,jsx as r}from"react/jsx-runtime";import{CButtonGroup as c}from"@coreui/react";import{faBan as b}from"@fortawesome/free-solid-svg-icons";import{useState as I,useEffect as d}from"react";import g from"./ImageToolItems/ImageLabelInput.js";import L from"../../IconButton.js";const S=({canJunk:a,isDisabled:e=!1,isFullscreen:s=!1,isImageJunk:o=!1,imageLabelIds:i=[],possibleLabels:l,onImageLabelsChanged:f=()=>{},onSetIsImageJunk:m=()=>{}})=>{const[p,t]=I(!1);return d(()=>{t(!1)},[s]),n(c,{role:"group","aria-label":"Image Tools",children:[l&&r(g,{isDisabled:e,isMultilabel:!0,isVisible:p,selectedLabelsIds:i,possibleLabels:l,onLabelSelect:u=>{t(!1),f(u)}}),a&&r(L,{color:"primary",icon:b,isOutline:!o,disabled:e,onClick:()=>m(!o),tooltip:"Junk image"})]})};export{S as default};
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
/* empty css *//* empty css */import{default as e}from"./
|
|
1
|
+
/* empty css *//* empty css */import{default as e}from"./IconButton.js";import{default as m}from"./Sia.js";import{default as l}from"./utils/transform.js";import{default as u}from"./Toolbar/ToolbarItems/ImageToolItems/TagLabel.js";export{e as IconButton,m as Sia,u as TagLabel,l as transform};
|
package/dist/models/index.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ import { default as AnnotationMode } from './AnnotationMode';
|
|
|
3
3
|
import { default as AnnotationStatus } from './AnnotationStatus';
|
|
4
4
|
import { default as AnnotationTool } from './AnnotationTool';
|
|
5
5
|
import { default as NotificationType } from './NotificationType';
|
|
6
|
-
export { Annotation, AnnotationMode, AnnotationStatus, AnnotationTool, NotificationType
|
|
6
|
+
export { Annotation, AnnotationMode, AnnotationStatus, AnnotationTool, NotificationType };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lost-sia",
|
|
3
|
-
"version": "2.0.1-
|
|
3
|
+
"version": "2.0.1-alpha15",
|
|
4
4
|
"description": "Single Image Annotation Tool",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "l3p-cv/lost-sia",
|
|
@@ -53,7 +53,8 @@
|
|
|
53
53
|
"start": "storybook dev -p 6006",
|
|
54
54
|
"storybook": "storybook dev -p 6006",
|
|
55
55
|
"build-storybook": "storybook build",
|
|
56
|
-
"format": "prettier --write src/"
|
|
56
|
+
"format": "prettier --write src/",
|
|
57
|
+
"pretty": "prettier --write \"./**/*.{js,jsx,mjs,cjs,ts,tsx,json}\""
|
|
57
58
|
},
|
|
58
59
|
"dependencies": {
|
|
59
60
|
"@fortawesome/free-regular-svg-icons": "^6.7.2",
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import Prompt from
|
|
2
|
-
import React from
|
|
3
|
-
import { Card, Image } from
|
|
1
|
+
import Prompt from './Prompt'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { Card, Image } from 'semantic-ui-react'
|
|
4
4
|
|
|
5
5
|
const LabelExampleViewer = (props) => {
|
|
6
6
|
const requestExample = (e) => {
|
|
7
|
-
e.stopPropagation()
|
|
7
|
+
e.stopPropagation()
|
|
8
8
|
if (props.onRequestExample) {
|
|
9
|
-
props.onRequestExample()
|
|
9
|
+
props.onRequestExample()
|
|
10
10
|
}
|
|
11
|
-
}
|
|
11
|
+
}
|
|
12
12
|
const renderContent = () => {
|
|
13
|
-
if (!props.lbl) return null
|
|
14
|
-
if (!props.exampleImg) return null
|
|
13
|
+
if (!props.lbl) return null
|
|
14
|
+
if (!props.exampleImg) return null
|
|
15
15
|
const description = (
|
|
16
16
|
<div>
|
|
17
17
|
{props.lbl.description}
|
|
18
18
|
<h4>Comment:</h4>
|
|
19
|
-
{props.exampleImg.anno ? props.exampleImg.anno.comment :
|
|
19
|
+
{props.exampleImg.anno ? props.exampleImg.anno.comment : 'no comment'}
|
|
20
20
|
</div>
|
|
21
|
-
)
|
|
21
|
+
)
|
|
22
22
|
return (
|
|
23
23
|
<div>
|
|
24
24
|
<Card
|
|
@@ -46,24 +46,24 @@ const LabelExampleViewer = (props) => {
|
|
|
46
46
|
{props.lbl.description}
|
|
47
47
|
<Image src={props.exampleImg.img} centered size='medium'></Image> */}
|
|
48
48
|
</div>
|
|
49
|
-
)
|
|
50
|
-
}
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
51
|
|
|
52
52
|
const handlePromptClick = () => {
|
|
53
53
|
if (props.onClose) {
|
|
54
|
-
props.onClose()
|
|
54
|
+
props.onClose()
|
|
55
55
|
}
|
|
56
|
-
}
|
|
56
|
+
}
|
|
57
57
|
|
|
58
58
|
return (
|
|
59
59
|
<Prompt
|
|
60
60
|
onClick={() => {
|
|
61
|
-
handlePromptClick()
|
|
61
|
+
handlePromptClick()
|
|
62
62
|
}}
|
|
63
63
|
active={props.active}
|
|
64
64
|
content={renderContent()}
|
|
65
65
|
/>
|
|
66
|
-
)
|
|
67
|
-
}
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
68
|
|
|
69
|
-
export default LabelExampleViewer
|
|
69
|
+
export default LabelExampleViewer
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { AnnotationMode } from
|
|
2
|
-
import AnnotationStatus from
|
|
3
|
-
import AnnotationTool from
|
|
4
|
-
import { Point } from
|
|
1
|
+
import { AnnotationMode } from '../../models'
|
|
2
|
+
import AnnotationStatus from '../../models/AnnotationStatus'
|
|
3
|
+
import AnnotationTool from '../../models/AnnotationTool'
|
|
4
|
+
import { Point } from '../../types'
|
|
5
5
|
|
|
6
6
|
class Annotation {
|
|
7
|
-
internalId: number
|
|
8
|
-
externalId?: string
|
|
9
|
-
annoTime: number
|
|
10
|
-
coordinates: Point[]
|
|
11
|
-
labelIds?: number[]
|
|
12
|
-
mode: AnnotationMode
|
|
13
|
-
selectedNode: number
|
|
14
|
-
status: AnnotationStatus
|
|
15
|
-
type: AnnotationTool
|
|
7
|
+
internalId: number
|
|
8
|
+
externalId?: string
|
|
9
|
+
annoTime: number
|
|
10
|
+
coordinates: Point[]
|
|
11
|
+
labelIds?: number[]
|
|
12
|
+
mode: AnnotationMode // do we even need this globally? - only really used inside AnnotationComponent
|
|
13
|
+
selectedNode: number
|
|
14
|
+
status: AnnotationStatus
|
|
15
|
+
type: AnnotationTool
|
|
16
16
|
|
|
17
17
|
constructor(
|
|
18
18
|
internalId: number,
|
|
@@ -20,18 +20,18 @@ class Annotation {
|
|
|
20
20
|
coordinates: Point[],
|
|
21
21
|
mode: AnnotationMode = AnnotationMode.CREATE,
|
|
22
22
|
status: AnnotationStatus = AnnotationStatus.CREATING,
|
|
23
|
-
externalId: string =
|
|
23
|
+
externalId: string = '',
|
|
24
24
|
) {
|
|
25
|
-
this.internalId = internalId
|
|
26
|
-
this.externalId = externalId
|
|
27
|
-
this.labelIds = []
|
|
28
|
-
this.type = type
|
|
29
|
-
this.mode = mode
|
|
30
|
-
this.status = status
|
|
31
|
-
this.coordinates = coordinates
|
|
32
|
-
this.selectedNode = 1
|
|
33
|
-
this.annoTime = 0.0
|
|
25
|
+
this.internalId = internalId
|
|
26
|
+
this.externalId = externalId
|
|
27
|
+
this.labelIds = []
|
|
28
|
+
this.type = type
|
|
29
|
+
this.mode = mode
|
|
30
|
+
this.status = status
|
|
31
|
+
this.coordinates = coordinates
|
|
32
|
+
this.selectedNode = 1
|
|
33
|
+
this.annoTime = 0.0
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
export default Annotation
|
|
37
|
+
export default Annotation
|