lost-sia 3.0.0 → 3.1.0
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/logic/Annotation.js +1 -1
- package/dist/Annotation/ui/AnnotationComponent.js +1 -1
- package/dist/Annotation/ui/atoms/AnnoBar.js +1 -1
- package/dist/Annotation/ui/tools/Point.js +1 -1
- package/dist/Canvas/Canvas.d.ts +2 -1
- package/dist/Canvas/Canvas.js +1 -1
- package/dist/Canvas/LabelInput.js +1 -1
- package/dist/IconButton.js +1 -1
- package/dist/Sia.d.ts +4 -3
- package/dist/Sia.js +1 -1
- package/dist/assets/node_modules/semantic-ui-css/semantic.min-09YPtVE6.css +1 -0
- package/dist/stories/AnnotationTools.stories.d.ts +2 -1
- package/dist/stories/Canvas/Canvas.stories.d.ts +5 -4
- package/dist/stories/Canvas/CanvasWithOffset.stories.d.ts +6 -6
- package/dist/stories/MinimalSia.stories.d.ts +3 -1
- package/dist/stories/SIA/SIA.stories.d.ts +3 -1
- package/dist/types.d.ts +5 -0
- package/dist/utils/KeyMapper.js +1 -1
- package/package.json +20 -22
- package/src/Annotation/ui/atoms/AnnoBar.tsx +3 -1
- package/src/Canvas/Canvas.tsx +4 -2
- package/src/Canvas/LabelInput.tsx +1 -1
- package/src/Sia.tsx +116 -2
- package/src/types.ts +6 -0
- package/dist/assets/node_modules/semantic-ui-css/semantic.min-Bvulf91l.css +0 -346
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import a from"../../models/AnnotationMode.js";import d from"../../models/AnnotationStatus.js";class m{internalId;externalId;annoTime;coordinates;labelIds;mode;selectedNode;status;type;constructor(t,e,o,s=a.CREATE,n=d.CREATING,i=""){this.internalId=t,this.externalId=i,this.labelIds=[],this.type=e,this.mode=s,this.status=n,this.coordinates=o,this.selectedNode=1,this.annoTime=0}}export{m as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as G,jsx as d}from"react/jsx-runtime";import E 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 h,useRef as x,useEffect as I}from"react";import e from"../../models/AnnotationMode.js";import Z from"../../utils/TimeUtils.js";const
|
|
1
|
+
import{jsxs as G,jsx as d}from"react/jsx-runtime";import E 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 h,useRef as x,useEffect as I}from"react";import e from"../../models/AnnotationMode.js";import Z from"../../utils/TimeUtils.js";const lo=({scaledAnnotation:r,annotationSettings:m,possibleLabels:T,svgScale:i,svgTranslation:l,pageToStageOffset:f,strokeWidth:B,nodeRadius:P,isSelected:c,isDisabled:V=!1,onFinishAnnoCreate:w,onLabelIconClicked:W,onAction:k=(n,a)=>{},onAnnoChanged:A=n=>{},onAnnotationModeChange:F=n=>{},onNotification:O=n=>{}})=>{const[n,a]=h(r.coordinates),[t,M]=h(r.mode),[j,C]=h(!1),R=x(void 0),[_,U]=h();I(()=>{R.current=_},[_]);const N=x(n);I(()=>{N.current=n},[n]);const b=()=>{M(e.VIEW);const o={...r,coordinates:N.current};w(o)},q=o=>T.find(s=>s.id===o),y=(()=>{if(!r.labelIds||r.labelIds.length==0)return L();const o=q(r.labelIds[0]);return o?.color===void 0||o.color===null?L():o.color})(),u={stroke:y,fill:y,strokeWidth:B/i,r:P/i},D=o=>{a(o);let s=o;[e.ADD,e.MOVE].includes(t)&&(s=o.slice(0,-1)),A({...r,coordinates:s})},p=o=>{[e.ADD,e.CREATE,e.MOVE].includes(t)||(M(e.MOVE),U(performance.now())),a(o)},g=()=>{M(e.VIEW);const o=Z.getRoundedDuration(R.current,performance.now()),s=Number.isNaN(r.annoTime)||r.annoTime===null?o:r.annoTime+o;A({...r,coordinates:N.current,annoTime:s})};I(()=>{F(t)},[t]),I(()=>{t===e.CREATE||t===e.ADD||a(r.coordinates)},[r]);const z=()=>{switch(r.type){case E.Point:return d(H,{isSelected:c,annotationSettings:m,coordinates:n[0],pageToStageOffset:f,svgScale:i,svgTranslation:l,style:u,onMoving:o=>p([o]),onMoved:g,onIsDraggingStateChanged:C});case E.Line:return d(J,{annotationSettings:m,coordinates:n,isSelected:c,pageToStageOffset:f,annotationMode:t,svgScale:i,svgTranslation:l,style:u,onAddNode:D,onDeleteNode:D,onMoving:p,onMoved:g,onIsDraggingStateChanged:C,onFinishAnnoCreate:b});case E.BBox:return d(X,{annotationMode:t,annotationSettings:m,startCoords:n[0],endCoords:n[1],isSelected:c,pageToStageOffset:f,style:u,svgScale:i,svgTranslation:l,onDeleteNode:()=>{console.log("TODO")},onIsDraggingStateChanged:C,onFinishAnnoCreate:b,onMoving:p,onMoved:g});case E.Polygon:return d(Y,{annotationSettings:m,coordinates:n,isSelected:c,isDisabled:V,pageToStageOffset:f,annotationMode:t,svgScale:i,svgTranslation:l,style:u,onAddNode:D,onDeleteNode:D,onMoving:p,onMoved:g,onNotification:O,onIsDraggingStateChanged:C,onFinishAnnoCreate:b})}};return G("g",{onClick:o=>{o.stopPropagation(),k(r,Q.ANNO_SELECTED)},children:[!j&&t!==e.CREATE&&d(K,{annotationCoordinates:n,canLabel:m.canLabel,labels:T,color:y,isSelected:c,selectedLabelIds:r.labelIds,style:u,svgScale:i,onLabelIconClicked:W}),z()]})};export{lo as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as
|
|
1
|
+
import{jsxs as C,jsx as x}from"react/jsx-runtime";import{useState as r,useRef as H,useEffect as f}from"react";import m from"../../../utils/transform.js";import R from"./DaviIcon.js";const j=10,a=15,I=3,k=({annotationCoordinates:u,canLabel:y,color:L,labels:b,selectedLabelIds:h=[],isSelected:E,svgScale:t,style:p,onLabelIconClicked:P})=>{const[c,w]=r({x:0,y:0}),e={x:c.x+7/t,y:c.y-10/t},[d,D]=r(0),[z,A]=r(0),[l,B]=r(0),[T,F]=r(""),s=H(null);f(()=>{F(W())},[h]),f(()=>{const i=m.getTopPoint(u),o=m.getMostLeftPoints(i),n=o.length>0?o[0]:{x:0,y:0};w(n);const _=Math.ceil(j/t);B(_),A(a/t)},[t]),f(()=>{if(s===void 0)return;const n=(s.current.getBoundingClientRect().width+I)/t;D(n)},[s,T,l]);const W=()=>{const o=b.filter(n=>h.includes(n.id)).map(n=>n.name).join(", ");return o.length?o:"no label"};return C("g",{children:[E&&y&&x(R,{x:e.x-33/t,y:e.y-30/t,color:L,size:60/t,onClick:()=>P(c)}),x("rect",{x:e.x,y:e.y-6/(t*1.2),width:d,height:z,rx:5/t,opacity:"0.5",style:p}),x("text",{x:e.x+1/t,y:e.y+6/t,fill:"white",textAnchor:"start",alignmentBaseline:"central",ref:s,fontSize:`${l}pt`,children:T}),x("rect",{x:e.x,y:e.y-6/(t*1.2),width:d,height:a,rx:5/t,opacity:"0.01",style:p,onContextMenu:i=>i.preventDefault()})]})};export{k as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as l}from"react/jsx-runtime";import s from"../atoms/Node.js";const N=({annotationSettings:e,coordinates:o,isSelected:n,pageToStageOffset:t,svgScale:r,svgTranslation:d,style:i,onMoving:m,onMoved:f,onIsDraggingStateChanged:p})=>l(s,{index:0,annotationSettings:e,coordinates:o,pageToStageOffset:t,svgScale:r,svgTranslation:d,style:i,onDeleteNode:()=>{},onMoving:(u,x)=>n&&m(x),onMoved:()=>f([o]),onIsDraggingStateChanged:p});export{N as default};
|
|
1
|
+
import{jsx as l}from"react/jsx-runtime";import s from"../atoms/Node.js";const N=({annotationSettings:e,coordinates:o,isSelected:n,pageToStageOffset:t,svgScale:r,svgTranslation:d,style:i,onMoving:m,onMoved:f,onIsDraggingStateChanged:p})=>l(s,{index:0,annotationSettings:e,coordinates:o,pageToStageOffset:t,svgScale:r,svgTranslation:d,style:i,onDeleteNode:(()=>{}),onMoving:(u,x)=>n&&m(x),onMoved:()=>f([o]),onIsDraggingStateChanged:p});export{N as default};
|
package/dist/Canvas/Canvas.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ type CanvasProps = {
|
|
|
26
26
|
onSetIsImageJunk: (newJunkState: boolean) => void;
|
|
27
27
|
onSetSelectedTool: (tool: AnnotationTool) => void;
|
|
28
28
|
onShouldDeleteAnno: (internalAnnoId: number) => void;
|
|
29
|
+
onTraverseAnnotationHistory: (isUndo: boolean) => void;
|
|
29
30
|
};
|
|
30
|
-
declare const Canvas: ({ annotations, annotationSettings, defaultLabelId, image, isFullscreen, isImageJunk, isPolygonSelectionMode, polygonOperationResult, possibleLabels, preventScrolling, selectedAnnotation, selectedAnnoTool, toolbarHeight, uiConfig, onAnnoCreated, onAnnoCreationFinished, onAnnoChanged, onAnnoEditing, onNotification, onRequestNewAnnoId, onSelectAnnotation, onSetIsImageJunk, onSetSelectedTool, onShouldDeleteAnno, }: CanvasProps) => import("react/jsx-runtime").JSX.Element;
|
|
31
|
+
declare const Canvas: ({ annotations, annotationSettings, defaultLabelId, image, isFullscreen, isImageJunk, isPolygonSelectionMode, polygonOperationResult, possibleLabels, preventScrolling, selectedAnnotation, selectedAnnoTool, toolbarHeight, uiConfig, onAnnoCreated, onAnnoCreationFinished, onAnnoChanged, onAnnoEditing, onNotification, onRequestNewAnnoId, onSelectAnnotation, onSetIsImageJunk, onSetSelectedTool, onShouldDeleteAnno, onTraverseAnnotationHistory, }: CanvasProps) => import("react/jsx-runtime").JSX.Element;
|
|
31
32
|
export default Canvas;
|
package/dist/Canvas/Canvas.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as
|
|
1
|
+
import{jsxs as L,jsx as m,Fragment as Ze}from"react/jsx-runtime";import{useState as y,useRef as Z,useEffect as I}from"react";import M from"../models/AnnotationTool.js";import i from"../models/EditorModes.js";import qe from"../utils/KeyMapper.js";import c from"../models/KeyAction.js";import Ae from"../Annotation/logic/Annotation.js";import et from"../models/CanvasAction.js";import tt from"../Annotation/ui/AnnotationComponent.js";import he from"../utils/mouse.js";import _ from"../models/AnnotationMode.js";import nt from"./LabelInput.js";import{FontAwesomeIcon as ot}from"@fortawesome/react-fontawesome";import{faBan as rt}from"@fortawesome/free-solid-svg-icons";import w from"../models/AnnotationStatus.js";import A from"../utils/transform.js";import st from"../models/NotificationType.js";import it from"../utils/TimeUtils.js";import xe from"../utils/windowViewport.js";const bt=({annotations:v=[],annotationSettings:W,defaultLabelId:q,image:ee,isFullscreen:Ce=!1,isImageJunk:B=!1,isPolygonSelectionMode:K=!1,polygonOperationResult:F={annotationsToDelete:[],polygonsToCreate:[]},possibleLabels:te,preventScrolling:ne=!0,selectedAnnotation:s,selectedAnnoTool:N,toolbarHeight:X=0,uiConfig:z,onAnnoCreated:ve,onAnnoCreationFinished:oe,onAnnoChanged:re,onAnnoEditing:Te=g=>{},onNotification:se=g=>{},onRequestNewAnnoId:R,onSelectAnnotation:T,onSetIsImageJunk:Ie,onSetSelectedTool:Oe=g=>{},onShouldDeleteAnno:ie,onTraverseAnnotationHistory:ae})=>{const[g,h]=y(i.VIEW),[Me,we]=y(),[ce,be]=y(q),[V,Se]=y({x:-1,y:-1}),[le,de]=y(0),k={x:V.x,y:V.y},[u,U]=y({x:-1,y:-1}),[d,Y]=y({x:-1,y:-1}),[E,fe]=y({x:-1,y:-1}),[l,P]=y(1),[a,b]=y({x:0,y:0}),G={x:a.x+le,y:a.y},[H,$]=y(),[j,S]=y(!1),ue=Z(null),x=Z(null),p=Z(null),C=((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),De=()=>{if(p?.current===null)return{x:0,y:0};const e=u.x*C;if(z.imageCentered&&d.x>e){const f=(d.x-e)/2;de(f)}else de(0);const{top:t,left:n}=x.current.getBoundingClientRect(),o={x:n+window.scrollX,y:t+window.scrollY};Se(o)},_e=new qe(e=>We(e)),Ne=e=>{h(i.CREATE);const t=A.convertStageCoordinatesToPercentaged([e],C,u);N===M.BBox&&t.push(t[0]);const n=R(),o=new Ae(n,N,t);if(we(performance.now()),ce!==void 0&&(o.labelIds=[ce]),ve(o),N===M.Point){const r={...o,coordinates:[e],annoTime:0};Q(r)}},Re=()=>{if(s&&![M.Line,M.Polygon].includes(s.type))return;const e=v.find(n=>n.internalId===s?.internalId);if(e===void 0)return;h(i.CREATE),Oe(e.type);const t={...e,mode:_.CREATE,status:w.CREATING,internalId:R(),selectedNode:e.coordinates.length-1};Te(t)},Ve=()=>{const e=s?s.internalId:0,t=v.find(n=>n.internalId>e);if(t)return T(t);if(v.length>0)return T(v[0])},ke=()=>{const e=s?s.internalId:0,t=[...v];t.sort((o,r)=>r.internalId-o.internalId);const n=t.find(o=>o.internalId<e);if(n)return T(n);if(v.length>0)return T(v.at(-1))},Pe=()=>{if(s){const e=JSON.stringify(s);localStorage.setItem("lostAnnotationClipboard",e);const t={title:"Success",message:"Annotation copied",type:st.SUCCESS};se(t)}},Le=()=>{const e=localStorage.getItem("lostAnnotationClipboard");if(e==null)return;const t=JSON.parse(e);t.internalId=R(),t.externalId="",oe(t,!0),T(t)},We=e=>{switch(e){case c.EDIT_LABEL:s&&S(!0);break;case c.DELETE_ANNO:s&&ie(s.internalId);break;case c.DELETE_ANNO_IN_CREATION:g===i.CREATE&&(ie(s.internalId),h(i.VIEW));break;case c.ENTER_ANNO_ADD_MODE:console.log("KeyAction TODO: ENTER_ANNO_ADD_MODE");break;case c.LEAVE_ANNO_ADD_MODE:console.log("KeyAction TODO: LEAVE_ANNO_ADD_MODE");break;case c.UNDO:ae(!0);break;case c.REDO:ae(!1);break;case c.TRAVERSE_ANNOS:Ve();break;case c.TRAVERSE_ANNOS_BACKWARDS:ke();break;case c.CAM_MOVE_LEFT:D(20*l,0);break;case c.CAM_MOVE_RIGHT:D(-20*l,0);break;case c.CAM_MOVE_UP:D(0,20*l);break;case c.CAM_MOVE_DOWN:D(0,-20*l);break;case c.CAM_MOVE_STOP:console.log("KeyAction TODO: CAM_MOVE_STOP");break;case c.COPY_ANNOTATION:Pe();break;case c.PASTE_ANNOTATION:Le();break;case c.RECREATE_ANNO:console.log("KeyAction TODO: RECREATE_ANNO"),Re();break;case c.TOGGLE_IMAGE_JUNK:if(g===i.ADD||g===i.CREATE)return;Ie(!B);break;default:console.log("Unknown KeyAction",e);break}},D=(e,t)=>{let n=a.x+e/l,o=a.y+t/l;const r=d.x*.45,f=d.x*.55,O=d.y*.45,Je=d.y*.55,Qe={x:0,y:0},me=xe.getViewportCoordinates(a,d,l,Qe),pe=xe.getViewportCoordinates(a,d,l,d);me.vX>=r?n=a.x-5:pe.vX<=f?n=a.x+5:me.vY>=O?o=a.y-5:pe.vY<=Je&&(o=a.y+5),b({x:n,y:o})},J=(e=>E.x<=0||E.y<=0||u.x<=0||u.y<=0?[]:v.map(n=>({...n,coordinates:A.convertPercentagedCoordinatesToStage(n.coordinates,u,E)})))(),Be=()=>{if(h(i.VIEW),fe({x:-1,y:-1}),p.current!==null){const{width:e,height:t}=p.current.getBoundingClientRect();U({x:e,y:t})}P(1),b({x:0,y:0}),$(void 0),S(!1)};I(()=>{ue.current?.focus()},[]),I(()=>{if(x?.current!==void 0){const{width:e,height:t}=x.current.getBoundingClientRect(),n=t-X;Y({x:e,y:n});const o=new ResizeObserver(()=>{const{width:r,height:f}=x.current.getBoundingClientRect(),O=f-X;Y({x:r,y:O})});return o.observe(x.current),()=>o.disconnect()}Be()},[ee,Ce]),I(()=>{De()},[p,a,d]),I(()=>{if(x.current===null)return;const{width:e,height:t}=x.current.getBoundingClientRect(),n=t-X;Y({x:e,y:n})},[x]),I(()=>{if(p.current===null)return;const{width:e,height:t}=p.current.getBoundingClientRect();U({x:e,y:t});const n=new ResizeObserver(()=>{const{width:o,height:r}=p.current.getBoundingClientRect();U({x:o,y:r})});return n.observe(p.current),()=>n.disconnect()},[p]),I(()=>{if(C===0)return;const e={x:u.x*C,y:u.y*C};fe(e)},[C,u]),I(()=>{K&&F.polygonsToCreate!==void 0&&F.polygonsToCreate.forEach(e=>{const t=R(),n=new Ae(t,e.type,A.convertPercentagedCoordinatesToStage(e.coordinates,u,E),_.VIEW,w.CREATED);Q(n)})},[F]);const Q=e=>{h(i.VIEW);const t={...e,mode:_.VIEW};if(e.type!==M.Point){const r=it.getRoundedDuration(Me,performance.now());t.annoTime=r}const n=A.convertStageCoordinatesToPercentaged(e.coordinates,C,u);t.coordinates=n,re(t);const o=N===M.Point||K;oe(t,o)},Ke=e=>{_e.keyDown(e.key,e.shiftKey,e.ctrlKey)&&e.preventDefault()},Fe=e=>{e.preventDefault()},Xe=e=>{if(e.button!==0){if(e.button===1)h(i.CAMERA_MOVE);else if(e.button===2){if(!W.canCreate||g===i.ADD||g===i.CREATE)return;const t=he.getAntiScaledMouseStagePosition(e,k,l,a),n={x:t.x-le,y:t.y};Ne(n)}}},ze=()=>{ne&&(document.body.style.overflow="hidden")},Ue=e=>{e.button===1&&h(i.VIEW)},ge=(e,t)=>{g===i.CAMERA_MOVE&&D(e,t)},Ye=()=>{ne&&(document.body.style.overflow="")},Ge=e=>{const o=(e.deltaY<0?1:-1)>0?l*1.25:l/1.25,r=he.getAntiScaledMouseStagePosition(e,k,l,a),f=l/o,O={x:f*(r.x+a.x)-r.x,y:f*(r.y+a.y)-r.y};o<1?(P(1),(a.x!=0||a.y!=0)&&b({x:0,y:0})):o>200?(P(200),b(O)):(P(o),b(O))},He=(e,t)=>{if(t!==et.ANNO_SELECTED){console.log("Unknown Canvas Action:",t);return}const n={...e,coordinates:A.convertStageCoordinatesToPercentaged([...e.coordinates],C,u)};T(n);const o=A.getMostLeftPoints(e.coordinates),r=A.getTopPoint(o)[0],f=A.convertStageToPage(r,k,l,a);$(f)},ye=e=>{const t=A.convertStageCoordinatesToPercentaged(e.coordinates,C,u),n={...e,coordinates:t};n.status===w.LOADED&&(n.status=w.CHANGED),re(n)},$e=()=>{if(g===i.CAMERA_MOVE)return m(Ze,{});const t=[i.CREATE,i.ADD,i.MOVE].includes(g),n=J.map(o=>{const r=o.internalId===s?.internalId;return t&&!r?m("g",{},`annotationComponent_${o.internalId}`):m(tt,{scaledAnnotation:o,annotationSettings:W,possibleLabels:te,svgScale:l,svgTranslation:G,pageToStageOffset:k,nodeRadius:z.nodeRadius,strokeWidth:z.strokeWidth,isSelected:r,isDisabled:K&&r,onFinishAnnoCreate:Q,onLabelIconClicked:()=>S(!0),onAction:He,onAnnoChanged:ye,onAnnotationModeChange:f=>{f===_.MOVE&&h(i.MOVE),g===i.MOVE&&f===_.VIEW&&h(i.VIEW)},onNotification:se},`annotationComponent_${o.internalId}`)});if(s){const o=J.find(f=>f.internalId===s?.internalId),r=J.indexOf(o);n.push(n.splice(r,1)[0])}return m("g",{children:n})},je=()=>m("circle",{cx:E.x/2,cy:E.y/2,r:"100%",style:{opacity:0},onContextMenu:e=>e.preventDefault(),onClick:()=>{S(!1)}}),Ee={x:V.x+d.x/2,y:V.y+d.y/2};return L("div",{ref:x,style:{flex:"1 1 auto",minHeight:0,display:"flex",flexDirection:"column"},children:[m("div",{style:{position:"absolute",left:H?.x??0,top:H?.y??0,display:H?.y===void 0?"none":"inherit",zIndex:j?7e3:-1},children:m(nt,{defaultLabelId:q,isVisible:j,selectedLabelsIds:s?.labelIds,possibleLabels:te,isMultilabel:W.canHaveMultipleLabels,onLabelSelect:e=>{if(S(!1),e.length>0){const o=e.filter(r=>!s.labelIds.includes(r));o.length>0&&be(o[0])}const t=s.status===w.LOADED?w.CHANGED:s.status,n={...s,coordinates:A.convertPercentagedCoordinatesToStage(s.coordinates,u,E),labelIds:[...e],status:t};ye(n)}})}),B&&L("div",{style:{position:"absolute",left:Ee.x,top:Ee.y,transform:"translate(-50%, -50%)",textAlign:"center",color:"white"},children:[m(ot,{icon:rt,size:"5x",style:{marginBottom:15}}),m("h2",{children:"Marked as Junk"})]}),L("svg",{ref:ue,style:{flex:"1 1 auto",minHeight:0},onKeyDown:Ke,onKeyUp:Fe,onMouseMove:e=>ge(e.movementX,e.movementY),tabIndex:0,onMouseDown:e=>Xe(e),children:[L("g",{transform:`scale(${l}) translate(${G.x}, ${G.y})`,onMouseOver:ze,onMouseLeave:Ye,onMouseUp:Ue,onWheel:Ge,onMouseMove:e=>ge(e.movementX,e.movementY),onClick:()=>{T(void 0)},children:[m("image",{onContextMenu:e=>e.preventDefault(),href:ee,ref:p,width:E.x>0?E.x:void 0,height:E.y>0?E.y:void 0}),$e()]}),j&&je(),B&&m("rect",{x:"0",y:"0",width:d.x,height:d.y,style:{opacity:.8},onContextMenu:e=>e.preventDefault(),onClick:()=>{$(void 0)}})]})]})};export{bt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as
|
|
1
|
+
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};
|
package/dist/IconButton.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as t,jsxs as
|
|
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?.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.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
2
|
import { default as AnnotationTool } from './models/AnnotationTool';
|
|
3
3
|
import { default as Annotation } from './Annotation/logic/Annotation';
|
|
4
|
-
import { AllowedTools, AnnotationSettings, ExternalAnnotation, Label, PolygonOperationResult, SIANotification, UiConfig } from './types';
|
|
4
|
+
import { AllowedTools, AnnotationSettings, ExternalAnnotation, Label, PolygonOperationResult, SIANotification, TimeTravelChanges, UiConfig } from './types';
|
|
5
5
|
type SiaProps = {
|
|
6
6
|
additionalButtons?: ReactElement;
|
|
7
7
|
allowedTools?: AllowedTools;
|
|
@@ -25,9 +25,10 @@ type SiaProps = {
|
|
|
25
25
|
onIsImageJunk?: (isJunk: boolean) => void;
|
|
26
26
|
onNotification?: (notification: SIANotification) => void;
|
|
27
27
|
onSelectAnnotation?: (annotation: Annotation) => void;
|
|
28
|
+
onTimeTravel?: (timeTravelAction: TimeTravelChanges) => void;
|
|
28
29
|
};
|
|
29
30
|
/**
|
|
30
31
|
* Main SIA component
|
|
31
32
|
*/
|
|
32
|
-
declare const
|
|
33
|
-
export default
|
|
33
|
+
declare const Sia: ({ additionalButtons, allowedTools: propAllowedTools, polygonOperationResult, annotationSettings: propAnnotationSettings, uiConfig: propUiConfig, defaultAnnotationTool, defaultLabelId, image, isLoading, isPolygonSelectionMode, initialAnnotations, initialImageLabelIds, initialIsImageJunk, possibleLabels, onAnnoCreated, onAnnoCreationFinished, onAnnoChanged, onAnnoDeleted, onImageLabelsChanged, onIsImageJunk, onNotification, onSelectAnnotation, onTimeTravel, }: SiaProps) => import("react/jsx-runtime").JSX.Element;
|
|
34
|
+
export default Sia;
|
package/dist/Sia.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as f,jsxs as M}from"react/jsx-runtime";import{useRef as gn,useState as a,useEffect as u}from"react";import{CSpinner as V}from"@coreui/react";import Sn from"./Canvas/Canvas.js";import _n from"./models/AnnotationTool.js";import Tn from"./Toolbar/Toolbar.js";import Cn from"./models/AnnotationMode.js";import K from"./models/AnnotationStatus.js";const Nn=({additionalButtons:Q,allowedTools:S,polygonOperationResult:y={annotationsToDelete:[],polygonsToCreate:[]},annotationSettings:w,uiConfig:D,defaultAnnotationTool:X,defaultLabelId:Y,image:I,isLoading:b=!1,isPolygonSelectionMode:k=!1,initialAnnotations:x=void 0,initialImageLabelIds:_=void 0,initialIsImageJunk:Z=!1,possibleLabels:E,onAnnoCreated:$=(l,m)=>{},onAnnoCreationFinished:O=(l,m)=>{},onAnnoChanged:nn=(l,m)=>{},onAnnoDeleted:F=(l,m)=>{},onImageLabelsChanged:tn=()=>{},onIsImageJunk:en=()=>{},onNotification:on=l=>{},onSelectAnnotation:sn=l=>{},onTimeTravel:an=l=>{}})=>{const m=gn(null),[N,J]=a(),[i,r]=a([]),[j,rn]=a(),[d,T]=a(),[A,B]=a([]),[dn,ln]=a(),[h,v]=a(),[L,P]=a(X??_n.Point),g=n=>{const t=[...n],e=[...A];d!==void 0&&e.splice(d+1),e.push(t),T(void 0),B(e)},[cn,R]=a(_),[U,W]=a(),[C,fn]=a(!1),[q,z]=a([]),p=n=>{const t=i.findIndex(o=>o.internalId===n),e=[...i],s=e.splice(t,1)[0];r(e),v(void 0),g(e),F(s,e)},un=()=>{h!==void 0&&p(h.internalId)},In=()=>{let n=0;const t=x.map(e=>({...e,internalId:n++,mode:Cn.VIEW,selectedNode:1,status:e.status,annoTime:e.annoTime??0}));z([...new Array(n).keys()]),r(t),g(t)},mn=()=>{let n=0;for(;q.includes(n);)n++;const t=[...q];return t.push(n),z(t),n},An=n=>{const t=[...i],e=t.findIndex(c=>c.internalId===h?.internalId);if(e===-1)return;const s=t.splice(e,1)[0];F(s,t);const o=[...t];o.push(n),r(o),v(n)},G=n=>{W(n),en(n)},hn=n=>{const t=d??A.length-1,e=t==A.length-1,s=t==0;if(e&&!n||s&&n)return;const o=t+(n?-1:1);T(o)},vn=n=>{const t=[],e=[],s=[];for(const o of n){const c=i.find(H=>H.internalId===o.internalId);c?JSON.stringify(c)!==JSON.stringify(o)&&s.push(o):t.push(o)}for(const o of i)n.find(H=>H.internalId===o.internalId)||e.push(o);return{addedAnnotations:t,removedAnnotations:e,changedAnnotations:s}};u(()=>{if(d==null||d<0||d>A.length-1)return;const t=[...A[d]];r(t);const e=vn(t);an(e)},[d]),u(()=>{I===void 0&&(r([]),v(void 0),B([]),T(void 0))},[I]),u(()=>{W(Z),!(I!==void 0||x===void 0||x.length===0)&&In()},[x]),u(()=>{R(_)},[_]),u(()=>{const t={...{canCreate:!0,canEdit:!0,canHaveMultipleLabels:!1,canLabel:!0,minimalArea:250},...w};rn(t)},[w]),u(()=>{const t={...{nodeRadius:4,strokeWidth:4,imageCentered:!1},...D};ln(t)},[D]),u(()=>{const n={bbox:!0,point:!0,line:!0,junk:!0,polygon:!0};if(S===void 0)return J(n);J(S)},[S]);const yn={position:"fixed",top:0,left:0,zIndex:6e3,backgroundColor:"#ffff",width:"100%",height:"100%",padding:15},xn={flex:"1 1 auto",minHeight:0,display:"flex",flexDirection:"column"};return N===void 0?f("div",{className:"d-flex justify-content-center",children:f(V,{color:"primary",style:{width:"5rem",height:"5rem"}})}):M("div",{style:{...C?yn:{},flex:"1 1 auto",minHeight:0,display:"flex",flexDirection:"column"},children:[f("div",{ref:m,style:{marginBottom:10},children:f(Tn,{annotationSettings:j,allowedTools:N,additionalButtons:Q,isDisabled:b,isFullscreen:C,isImageJunk:U,imageLabelIds:cn,possibleLabels:E,selectedTool:L,onImageLabelsChanged:n=>{R(n),tn(n)},onSetIsFullscreen:fn,onSetIsImageJunk:G,onSetSelectedTool:P,onShouldDeleteSelectedAnnotation:un})}),M("div",{style:xn,children:[b&&f("div",{className:"d-flex justify-content-center",children:f(V,{color:"primary",style:{width:"5rem",height:"5rem",marginTop:200}})}),I&&i&&f(Sn,{annotations:i,annotationSettings:j,defaultLabelId:Y,image:I,isFullscreen:C,isImageJunk:U,isPolygonSelectionMode:k,selectedAnnotation:h,selectedAnnoTool:L,polygonOperationResult:y,possibleLabels:E,uiConfig:dn,onAnnoCreated:n=>{const t=[...i];t.push(n),r(t),v(n),$(n,t)},onAnnoChanged:n=>{const t=i.findIndex(s=>s.internalId===n.internalId);if(t===-1)return;const e=[...i];e[t]=n,r(e),n.status!==K.CREATING&&g(e),nn(n,e)},onAnnoCreationFinished:(n,t)=>{const e=[...i];if(k&&y?.annotationsToDelete!==void 0){y.annotationsToDelete.push(h);for(const s of y.annotationsToDelete){p(s.internalId);const o=e.findIndex(c=>c.internalId===s.internalId);e.splice(o,1)}}if(t)e.push(n);else{const s=i.findIndex(o=>o.internalId===n.internalId);e[s]=n}r(e),g(e),n.status=K.CREATED,O(n,e)},onAnnoEditing:An,onSetIsImageJunk:G,onNotification:on,onRequestNewAnnoId:mn,onSelectAnnotation:n=>{v(n),sn(n)},onSetSelectedTool:P,onShouldDeleteAnno:p,onTraverseAnnotationHistory:hn})]})]})};export{Nn as default};
|