@labelbee/lb-components 1.23.0-alpha.137 → 1.23.0-alpha.139
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/_virtual/2DViewWorker.js +1 -1
- package/dist/components/AnnotationView/hooks/useFilterAnnotations.js +1 -0
- package/dist/components/AnnotationView/index.js +1 -1
- package/dist/components/pointCloud2DRectOperationView/index.js +1 -1
- package/dist/types/components/AnnotationView/hooks/useFilterAnnotations.d.ts +2 -0
- package/es/_virtual/2DViewWorker.js +1 -1
- package/es/components/AnnotationView/hooks/useFilterAnnotations.js +1 -0
- package/es/components/AnnotationView/index.js +1 -1
- package/es/components/pointCloud2DRectOperationView/index.js +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useMemo as u}from"react";const a=(n=[],t,r)=>u(()=>r&&(t==null?void 0:t.length)?n.filter(o=>t.includes(o.annotation.id)):n,[n,t,r]);export{a as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import w,{useState as
|
|
1
|
+
import w,{useState as Q,useRef as y,useContext as W,useImperativeHandle as X,useEffect as c,useCallback as D}from"react";import{ViewOperation as Y,ImgUtils as ee}from"@labelbee/lb-annotation";import{Spin as te}from"antd/es";import ne from"../../hooks/useRefCache.js";import re from"../measureCanvas/index.js";import{PointCloudContext as oe}from"../pointCloudView/PointCloudContext.js";import ie from"./hooks/useFilterAnnotations.js";import ae from"../../store/toolConfig/index.js";var le=Object.defineProperty,N=Object.getOwnPropertySymbols,ue=Object.prototype.hasOwnProperty,ce=Object.prototype.propertyIsEnumerable,T=(n,r,o)=>r in n?le(n,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[r]=o,R=(n,r)=>{for(var o in r||(r={}))ue.call(r,o)&&T(n,o,r[o]);if(N)for(var o of N(r))ce.call(r,o)&&T(n,o,r[o]);return n},B=(n,r,o)=>new Promise((v,d)=>{var s=u=>{try{f(o.next(u))}catch(m){d(m)}},I=u=>{try{f(o.throw(u))}catch(m){d(m)}},f=u=>u.done?v(u.value):Promise.resolve(u.value).then(s,I);f((o=o.apply(n,r)).next())});const x={width:455,height:100},se=n=>{if(!n)return x;if(n.width&&n.height)return n;const r=R({},n);return r.width||(r.width=x.width),r.height||(r.height=x.height),r},de=(n,r)=>{var o,v;const{src:d,fallbackSrc:s,annotations:I=[],style:f={stroke:"blue",thickness:3},zoomChange:u,backgroundStyle:m={},onChange:P,showLoading:F=!1,globalStyle:M,afterImgOnLoad:U,measureVisible:S,onRightClick:g,pointCloudBoxList:A=[],hiddenText:E=!1,renderToolName:Z}=n,p=se(n.size),[H,k]=Q(!1),z=y(null),e=y(),L=ne(U),h=y([]),_=y(!0),{selectedIDs:$}=W(oe),{selectBoxVisibleSwitch:q}=ae(),C=ie(I,$,q);X(r,()=>{const t=e.current;return t?{zoomIn:()=>t.zoomChanged(!0),zoomOut:()=>t.zoomChanged(!1),initImgPos:()=>t.initImgPos(),toolInstance:t}:{}},[e.current]),c(()=>(z.current&&(e.current=new Y({container:z.current,size:p,style:f,annotations:C,config:"{}",zoomInfo:n.zoomInfo,staticMode:n.staticMode,renderToolName:Z}),e.current.init(),g&&e.current.on("onRightClick",g)),()=>{var t,a;g&&((t=e.current)==null||t.unbind("onRightClick",g)),(a=e.current)==null||a.destroy()}),[S]);const O=D(t=>B(void 0,null,function*(){var a,i;try{const l=yield ee.load(t);return(a=e.current)==null||a.setImgNode(l),(i=L.current)==null||i.call(L,l),null}catch(l){return console.error("Error loading image:",l),l}}),[]),j=D(t=>B(void 0,null,function*(){var a,i;if(k(!0),(a=e.current)==null||a.setLoading(!0),(yield O(t))&&s){const b=yield O(s);b&&console.error("Error loading fallback image:",b)}(i=e.current)==null||i.setLoading(!1),k(!1)}),[O,s]);c(()=>{e.current&&j(d)},[d,S,s,j]),c(()=>{(e==null?void 0:e.current)&&e.current.setPointCloudBoxList(A)},[A]),c(()=>{var t;(e==null?void 0:e.current)&&((t=e.current)==null||t.setHiddenText(E))},[E]),c(()=>{if(_.current===!1){h.current.push(C);return}const t=()=>{_.current=!0,h.current=[]},a=()=>{var i;const l=h.current.length;if(l>0){const b=h.current[l-1];h.current=[],(i=e.current)==null||i.updateData(b).then(a).catch(t)}else _.current=!0};e.current&&(_.current=!1,e.current.updateData(C).then(a).catch(t))},[C]),c(()=>{const t=e.current;(t==null?void 0:t.setSize)&&(t.setSize(p),t.initPosition())},[(o=n.size)==null?void 0:o.width,(v=n.size)==null?void 0:v.height]),c(()=>{var t,a;return e.current&&((t=e.current)==null||t.on("onChange",(...i)=>{P==null||P.apply(null,i)}),(a=e.current)==null||a.on("renderZoom",i=>{u&&u(i)})),()=>{var i,l;(i=e.current)==null||i.unbindAll("onChange"),(l=e.current)==null||l.unbindAll("renderZoom")}},[u,P]);const G=w.createElement("div",{ref:z,style:R(R({position:"relative"},p),m)}),{imgNode:V,zoom:J,currentPos:K}=e.current||{};return w.createElement(te,{spinning:F||H,delay:300,style:M},S&&V?w.createElement(re,{size:p,imgNode:V,zoom:J,currentPos:K}):G)};var fe=w.forwardRef(de);export{fe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useLatest as oe,useMemoizedFn as q}from"ahooks";import{Spin as
|
|
1
|
+
import{useLatest as oe,useMemoizedFn as q,useDebounceEffect as he}from"ahooks";import{Spin as Ie}from"antd/es";import J,{useContext as _e,useRef as $,useState as O,useMemo as De,useCallback as be,useEffect as p}from"react";import{connect as Ce}from"react-redux";import{usePointCloudViews as we}from"../pointCloudView/hooks/usePointCloudViews.js";import{PointCloudContext as xe}from"../pointCloudView/PointCloudContext.js";import{a2MapStateToProps as ye}from"../../store/annotation/map.js";import{LabelBeeContext as Pe}from"../../store/ctx.js";import{PointCloud2DRectOperation as Se,MathUtils as Le,ImgUtils as Oe}from"@labelbee/lb-annotation";import{selectSpecifiedRectsFromTopViewSelectedIds as Ve}from"./util.js";import{useUpdateRectList as Ee}from"./useUpdateRectList.js";import je from"lodash";import{useToolStyleContext as ke}from"../../hooks/useToolStyle.js";import Be from"../../store/toolConfig/index.js";var Ne=Object.defineProperty,Ue=Object.defineProperties,Me=Object.getOwnPropertyDescriptors,ie=Object.getOwnPropertySymbols,ze=Object.prototype.hasOwnProperty,Ae=Object.prototype.propertyIsEnumerable,le=(d,c,s)=>c in d?Ne(d,c,{enumerable:!0,configurable:!0,writable:!0,value:s}):d[c]=s,v=(d,c)=>{for(var s in c||(c={}))ze.call(c,s)&&le(d,s,c[s]);if(ie)for(var s of ie(c))Ae.call(c,s)&&le(d,s,c[s]);return d},C=(d,c)=>Ue(d,Me(c)),G=(d,c,s)=>new Promise((a,g)=>{var D=f=>{try{b(s.next(f))}catch(R){g(R)}},V=f=>{try{b(s.throw(f))}catch(R){g(R)}},b=f=>f.done?a(f.value):Promise.resolve(f.value).then(D,V);b((s=s.apply(d,c)).next())});const Te=d=>{var c,s;const{mappingData:a,size:g,config:D,checkMode:V,afterImgOnLoad:b,shouldExcludePointCloudBoxListUpdate:f}=d,{selectBoxVisibleSwitch:R}=Be(),E=(c=a==null?void 0:a.url)!=null?c:"",w=(s=a==null?void 0:a.fallbackUrl)!=null?s:"",{pointCloudBoxList:j,setPointCloudResult:k,defaultAttribute:B,rectList:N,addRectIn2DView:ce,updateRectIn2DView:se,removeRectIn2DView:ue,updateRectListByReducer:de,selectedIDs:m,setSelectedIDs:U,selectedID:x}=_e(xe),{value:M}=ke(),ae=oe(m),{update2DViewRect:fe,remove2DViewRect:pe}=we(),z=J.useRef(null),n=$(null),K=q(fe),y=q(pe),P=$(null),[me,Q]=O(!0),[W,X]=O(""),[ve,A]=O(!1),[ge,S]=O(!0),h=De(()=>N==null?void 0:N.filter(e=>e.imageName===(a==null?void 0:a.path)),[a==null?void 0:a.path,N]),Y=$(h),L=oe(a==null?void 0:a.path),T=be(e=>G(void 0,null,function*(){try{const o=ae.current.slice(0),r=yield Promise.resolve(e());if(!r||r.length===0)return r;if(o.length){const t=new Set(o),i=r.filter(l=>t.has(l.id)).map(l=>l.id);U(i)}return r}catch(o){}}),[U]),Z=e=>{const{boxID:o}=e;if(S(!1),!f&&o){T(()=>{const r=K==null?void 0:K(e);return r?(P.current=r,k(r),r):null});return}se(e,!0)},ee=e=>{L.current&&ce(C(v({},e),{imageName:L.current}))},te=e=>{if(e.length===0)return;if(!f){const r=e.find(t=>t.boxID);if(r){T(()=>{const t=y==null?void 0:y(r);return t?(P.current=t,k(t),I(),t):null});return}}const o=e.find(r=>r.extId);o&&T(()=>{const{imageName:r,extId:t}=o,i=y==null?void 0:y({boxID:t,imageName:r});return i?(P.current=i,k(i),i):null}),ue(e)},Re=q(()=>{let e=[];return j.forEach(o=>{const{rects:r=[],id:t,attribute:i,trackID:l}=o,u=r.find(F=>F.imageName===L.current),_=t+"_"+L.current;u&&(e=[...e,C(v({},u),{boxID:t,id:_,attribute:i,order:l})])}),e}),I=Ee(()=>{var e,o,r,t,i;const l=f?[]:Re(),u=(e=n.current)==null?void 0:e.selectedRectID,_=m.slice(0),F=R?Ve(_,l,h):[...l,...h];let ne=[];!R&&(m==null?void 0:m.length)&&(ne=l.filter(H=>u?m.includes(H.boxID)&&!u.includes(H.boxID):m.includes(H.boxID))),(o=n.current)==null||o.setHighLightRectList(ne),(r=n.current)==null||r.setResult(F),W?((t=n.current)==null||t.setSelectedRectID(W),X("")):ve&&u&&((i=n.current)==null||i.setSelectedRectID(u),A(!1))}),re=({targetId:e,id:o})=>{S(!1),U(e),X(o)};return p(()=>{if(z.current){const e=new Se({container:z.current,size:g,config:C(v({},D),{isShowOrder:!0,attributeConfigurable:!0}),checkMode:V});return n.current=e,n.current.init(),n.current.on("updateDragResult",Z),n.current.on("afterAddingDrawingRect",ee),n.current.on("deleteSelectedRects",te),n.current.on("onRightClick",re),()=>{var o,r,t,i,l;(o=n.current)==null||o.unbind("updateDragResult",Z),(r=n.current)==null||r.unbind("afterAddingDrawingRect",ee),(t=n.current)==null||t.unbind("deleteSelectedRects",te),(i=n.current)==null||i.unbind("onRightClick",re),(l=n.current)==null||l.destroy()}}},[]),p(()=>{const e=r=>G(void 0,null,function*(){try{return yield Oe.load(r)}catch(t){return console.error("Error loading image:",t),null}}),o=()=>G(void 0,null,function*(){var r;Q(!0);let t=yield e(E);!t&&w&&(t=yield e(w)),t&&((r=n.current)==null||r.setImgNode(t),b(t)),Q(!1)});n.current&&(E||w)&&o()},[E,w]),p(()=>{var e;(e=n.current)==null||e.setSize(g)},[g]),p(()=>{j!==P.current&&I()},[j]),p(()=>{var e,o;const r=h.find(t=>t.id===n.current.selectedRectID);(o=(e=n.current)==null?void 0:e.setDefaultAttribute)==null||o.call(e,B),r&&de(t=>{var i;const l=[];let u=null;return t.forEach(_=>{_.id!==n.current.selectedRectID?l.push(_):u=_}),r.extId===void 0&&(u=(i=n.current)==null?void 0:i.selectedRect),[...l,C(v({},u||{}),{attribute:B})]}),A(!0),I()},[B]),p(()=>{const e=Y.current;je.isEqual(e,h)||(A(!0),I(),Y.current=h)},[h]),p(()=>{I()},[f]),p(()=>{var e,o,r,t;const i=(o=(e=n.current)==null?void 0:e.config)!=null?o:{},l=C(v({},i),{attributeList:(r=D.attributeList)!=null?r:[]});(t=n.current)==null||t.setConfig(JSON.stringify(l))},[D.attributeList]),p(()=>{var e;(e=n.current)==null||e.setEnableAddRect(m.length===0),I()},[m]),he(()=>{if(!x||!ge){S(!0);return}const{rectList:e,size:o,zoom:r}=n.current,t=e.find(u=>u.boxID===x||u.extId===x);if(!t){S(!0);return}const i={x:t.x+t.width/2,y:t.y+t.height/2},l=Le.getCurrentPosFromRectCenter(o,i,r);n.current.setHoverRectID(t.id),n.current.setCurrentPos(l),n.current.renderBasicCanvas(),n.current.render()},[x],{wait:200}),p(()=>{const{hiddenText:e}=M||{};if(e===void 0)return;const o=n.current;if(!o)return;const r=v(v({},o.style),M);o.setStyle(r)},[M]),p(()=>{I()},[R]),J.createElement(Ie,{spinning:me},J.createElement("div",{ref:z,style:v({position:"relative"},g)}))};var Fe=Ce(ye,null,null,{context:Pe})(Te);export{Fe as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@labelbee/lb-components",
|
|
3
|
-
"version": "1.23.0-alpha.
|
|
3
|
+
"version": "1.23.0-alpha.139",
|
|
4
4
|
"description": "Provide a complete library of annotation components",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"es": "./es/index.js",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@ant-design/icons": "^4.6.2",
|
|
46
|
-
"@labelbee/lb-annotation": "1.27.0-alpha.
|
|
47
|
-
"@labelbee/lb-utils": "1.19.0-alpha.
|
|
46
|
+
"@labelbee/lb-annotation": "1.27.0-alpha.69",
|
|
47
|
+
"@labelbee/lb-utils": "1.19.0-alpha.27",
|
|
48
48
|
"@labelbee/wavesurfer": "1.1.0-alpha.1",
|
|
49
49
|
"@types/react-dom": "^18.2.7",
|
|
50
50
|
"@types/react-transition-group": "^4.4.9",
|