@labelbee/lb-components 1.23.0-alpha.136 → 1.23.0-alpha.138

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.
@@ -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 q,useRef as y,useContext as G,useImperativeHandle as J,useEffect as c,useCallback as j}from"react";import{ViewOperation as K,ImgUtils as Q}from"@labelbee/lb-annotation";import{Spin as W}from"antd/es";import X from"../../hooks/useRefCache.js";import Y from"../measureCanvas/index.js";import{PointCloudContext as ee}from"../pointCloudView/PointCloudContext.js";var te=Object.defineProperty,D=Object.getOwnPropertySymbols,ne=Object.prototype.hasOwnProperty,re=Object.prototype.propertyIsEnumerable,N=(n,r,o)=>r in n?te(n,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[r]=o,R=(n,r)=>{for(var o in r||(r={}))ne.call(r,o)&&N(n,o,r[o]);if(D)for(var o of D(r))re.call(r,o)&&N(n,o,r[o]);return n},M=(n,r,o)=>new Promise((g,f)=>{var s=u=>{try{m(o.next(u))}catch(h){f(h)}},d=u=>{try{m(o.throw(u))}catch(h){f(h)}},m=u=>u.done?g(u.value):Promise.resolve(u.value).then(s,d);m((o=o.apply(n,r)).next())});const S={width:455,height:100},oe=n=>{if(!n)return S;if(n.width&&n.height)return n;const r=R({},n);return r.width||(r.width=S.width),r.height||(r.height=S.height),r},ie=(n,r)=>{var o,g;const{src:f,fallbackSrc:s,annotations:d=[],style:m={stroke:"blue",thickness:3},zoomChange:u,backgroundStyle:h={},onChange:I,showLoading:T=!1,globalStyle:U,afterImgOnLoad:Z,measureVisible:P,onRightClick:_,pointCloudBoxList:E=[],hiddenText:L=!1}=n,p=oe(n.size),[B,k]=q(!1),z=y(null),e=y(),x=X(Z),v=y([]),C=y(!0);G(ee),J(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 K({container:z.current,size:p,style:m,annotations:d,config:"{}",zoomInfo:n.zoomInfo,staticMode:n.staticMode}),e.current.init(),_&&e.current.on("onRightClick",_)),()=>{var t,a;_&&((t=e.current)==null||t.unbind("onRightClick",_)),(a=e.current)==null||a.destroy()}),[P]);const O=j(t=>M(void 0,null,function*(){var a,i;try{const l=yield Q.load(t);return(a=e.current)==null||a.setImgNode(l),(i=x.current)==null||i.call(x,l),null}catch(l){return console.error("Error loading image:",l),l}}),[]),A=j(t=>M(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&&A(f)},[f,P,s,A]),c(()=>{(e==null?void 0:e.current)&&e.current.setPointCloudBoxList(E)},[E]),c(()=>{var t;(e==null?void 0:e.current)&&((t=e.current)==null||t.setHiddenText(L))},[L]),c(()=>{if(C.current===!1){v.current.push(d);return}const t=()=>{C.current=!0,v.current=[]},a=()=>{var i;const l=v.current.length;if(l>0){const b=v.current[l-1];v.current=[],(i=e.current)==null||i.updateData(b).then(a).catch(t)}else C.current=!0};e.current&&(C.current=!1,e.current.updateData(d).then(a).catch(t))},[d]),c(()=>{const t=e.current;(t==null?void 0:t.setSize)&&(t.setSize(p),t.initPosition())},[(o=n.size)==null?void 0:o.width,(g=n.size)==null?void 0:g.height]),c(()=>{var t,a;return e.current&&((t=e.current)==null||t.on("onChange",(...i)=>{I==null||I.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,I]);const H=w.createElement("div",{ref:z,style:R(R({position:"relative"},p),h)}),{imgNode:V,zoom:F,currentPos:$}=e.current||{};return w.createElement(W,{spinning:T||B,delay:300,style:U},P&&V?w.createElement(Y,{size:p,imgNode:V,zoom:F,currentPos:$}):H)};var ae=w.forwardRef(ie);export{ae as default};
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{getClassName as w}from"../../utils/dom.js";import s,{useRef as P,useState as G,useContext as J,useMemo as K,useCallback as M,useEffect as Q}from"react";import W from"../AnnotationView/index.js";import X from"../../hooks/useSize.js";import{useSingleBox as Y}from"./hooks/useSingleBox.js";import{useHighlight as Z}from"./hooks/useHighlight.js";import $ from"./components/HighlightVisible/index.js";import{PointCloudContext as oo}from"./PointCloudContext.js";import to from"./hooks/useDataLinkSwitch.js";import eo from"../pointCloud2DRectOperationView/index.js";import{useToolStyleContext as no}from"../../hooks/useToolStyle.js";var io=(o,u,i)=>new Promise((a,r)=>{var h=t=>{try{l(i.next(t))}catch(n){r(n)}},d=t=>{try{l(i.throw(t))}catch(n){r(n)}},l=t=>t.done?a(t.value):Promise.resolve(t.value).then(h,d);l((i=i.apply(o,u)).next())});const lo=({view2dData:o,setSelectedID:u,currentData:i,showEnlarge:a,checkMode:r=!1,measureVisible:h})=>{var d,l;const t=P(null),n=P(),{selectedBox:m}=Y(),p=X(t),{url:x,fallbackUrl:k,calib:C,path:v}=o,{toggle2dVisible:B,isHighlightVisible:I}=Z({currentData:i}),[_,b]=G(!1),{highlight2DLoading:z,setHighlight2DLoading:S,cuboidBoxIn2DView:f,cacheImageNodeSize:O,setSelectedIDs:R,pointCloudBoxList:H}=J(oo),{value:E}=no(),{hiddenText:N}=E||{},T=!o,U=K(()=>({zIndex:a?-1:101,is2DView:!f,imageName:o.path}),[a,f,o.path]),{rendered:A,isLinking:D}=to(U),L=e=>{g(),O({path:v,imgNode:e})},g=M(()=>{var e,y;const V=(e=n.current)==null?void 0:e.toolInstance;if(u(""),!m||!V)return;const c=o.annotations.find(q=>q.annotation.id===m.info.id);let j="";c&&((y=c==null?void 0:c.annotation.pointList)==null?void 0:y.length)>0&&(V.focusPositionByPointList(c==null?void 0:c.annotation.pointList),j=m.info.id,u(j))},[m,n.current,o.annotations]);Q(()=>{g()},[g]);const F=()=>io(void 0,null,function*(){b(!0),S(!0);try{yield B(x,k!=null?k:"",C)}catch(e){console.error("highlightOnClick error:",e)}finally{b(!1),S(!1)}});return s.createElement("div",{className:w("point-cloud-2d-image"),ref:t},f?s.createElement(W,{src:(d=o==null?void 0:o.url)!=null?d:"",fallbackSrc:(l=o==null?void 0:o.fallbackUrl)!=null?l:"",annotations:o.annotations,size:p,ref:n,globalStyle:{display:T?"none":"block"},afterImgOnLoad:L,zoomInfo:{min:.01,max:1e3,ratio:.4},measureVisible:h,onRightClick:({targetId:e})=>R(e),pointCloudBoxList:H,hiddenText:N}):s.createElement(s.Fragment,null,s.createElement(eo,{shouldExcludePointCloudBoxListUpdate:!D,mappingData:o,size:p,checkMode:r,afterImgOnLoad:L}),!r&&A),C&&s.createElement($,{visible:I(x),onClick:F,loading:_,disabled:z,style:{position:"absolute",right:16,top:16,zIndex:a?-1:101}}))};export{lo as default};
1
+ import{getClassName as w}from"../../utils/dom.js";import s,{useRef as j,useState as G,useContext as J,useMemo as K,useCallback as M,useEffect as Q}from"react";import W from"../AnnotationView/index.js";import X from"../../hooks/useSize.js";import{useSingleBox as Y}from"./hooks/useSingleBox.js";import{EPointCloudName as Z}from"@labelbee/lb-annotation";import{useHighlight as $}from"./hooks/useHighlight.js";import oo from"./components/HighlightVisible/index.js";import{PointCloudContext as to}from"./PointCloudContext.js";import eo from"./hooks/useDataLinkSwitch.js";import no from"../pointCloud2DRectOperationView/index.js";import{useToolStyleContext as io}from"../../hooks/useToolStyle.js";var lo=(o,u,i)=>new Promise((a,r)=>{var f=t=>{try{l(i.next(t))}catch(n){r(n)}},d=t=>{try{l(i.throw(t))}catch(n){r(n)}},l=t=>t.done?a(t.value):Promise.resolve(t.value).then(f,d);l((i=i.apply(o,u)).next())});const so=({view2dData:o,setSelectedID:u,currentData:i,showEnlarge:a,checkMode:r=!1,measureVisible:f})=>{var d,l;const t=j(null),n=j(),{selectedBox:m}=Y(),p=X(t),{url:b,fallbackUrl:x,calib:C,path:v}=o,{toggle2dVisible:B,isHighlightVisible:I}=$({currentData:i}),[_,k]=G(!1),{highlight2DLoading:z,setHighlight2DLoading:S,cuboidBoxIn2DView:h,cacheImageNodeSize:N,setSelectedIDs:O,pointCloudBoxList:R}=J(to),{value:E}=io(),{hiddenText:H}=E||{},T=!o,U=K(()=>({zIndex:a?-1:101,is2DView:!h,imageName:o.path}),[a,h,o.path]),{rendered:A,isLinking:D}=eo(U),L=e=>{g(),N({path:v,imgNode:e})},g=M(()=>{var e,y;const P=(e=n.current)==null?void 0:e.toolInstance;if(u(""),!m||!P)return;const c=o.annotations.find(q=>q.annotation.id===m.info.id);let V="";c&&((y=c==null?void 0:c.annotation.pointList)==null?void 0:y.length)>0&&(P.focusPositionByPointList(c==null?void 0:c.annotation.pointList),V=m.info.id,u(V))},[m,n.current,o.annotations]);Q(()=>{g()},[g]);const F=()=>lo(void 0,null,function*(){k(!0),S(!0);try{yield B(b,x!=null?x:"",C)}catch(e){console.error("highlightOnClick error:",e)}finally{k(!1),S(!1)}});return s.createElement("div",{className:w("point-cloud-2d-image"),ref:t},h?s.createElement(W,{src:(d=o==null?void 0:o.url)!=null?d:"",fallbackSrc:(l=o==null?void 0:o.fallbackUrl)!=null?l:"",annotations:o.annotations,size:p,ref:n,globalStyle:{display:T?"none":"block"},afterImgOnLoad:L,zoomInfo:{min:.01,max:1e3,ratio:.4},measureVisible:f,onRightClick:({targetId:e})=>O(e),pointCloudBoxList:R,hiddenText:H,renderToolName:Z.PointCloud}):s.createElement(s.Fragment,null,s.createElement(no,{shouldExcludePointCloudBoxListUpdate:!D,mappingData:o,size:p,checkMode:r,afterImgOnLoad:L}),!r&&A),C&&s.createElement(oo,{visible:I(b),onClick:F,loading:_,disabled:z,style:{position:"absolute",right:16,top:16,zIndex:a?-1:101}}))};export{so as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@labelbee/lb-components",
3
- "version": "1.23.0-alpha.136",
3
+ "version": "1.23.0-alpha.138",
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.67",
47
- "@labelbee/lb-utils": "1.19.0-alpha.26",
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",