@labelbee/lb-components 1.23.0-alpha.137 → 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 G,useRef as y,useContext as J,useImperativeHandle as K,useEffect as c,useCallback as j}from"react";import{ViewOperation as Q,ImgUtils as W}from"@labelbee/lb-annotation";import{Spin as X}from"antd/es";import Y from"../../hooks/useRefCache.js";import ee from"../measureCanvas/index.js";import{PointCloudContext as te}from"../pointCloudView/PointCloudContext.js";var ne=Object.defineProperty,N=Object.getOwnPropertySymbols,re=Object.prototype.hasOwnProperty,oe=Object.prototype.propertyIsEnumerable,D=(n,r,o)=>r in n?ne(n,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[r]=o,R=(n,r)=>{for(var o in r||(r={}))re.call(r,o)&&D(n,o,r[o]);if(N)for(var o of N(r))oe.call(r,o)&&D(n,o,r[o]);return n},T=(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},ie=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},ae=(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:M=!1,globalStyle:U,afterImgOnLoad:Z,measureVisible:P,onRightClick:_,pointCloudBoxList:E=[],hiddenText:L=!1,renderToolName:B}=n,p=ie(n.size),[H,k]=G(!1),z=y(null),e=y(),x=Y(Z),v=y([]),C=y(!0);J(te),K(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 Q({container:z.current,size:p,style:m,annotations:d,config:"{}",zoomInfo:n.zoomInfo,staticMode:n.staticMode,renderToolName:B}),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=>T(void 0,null,function*(){var a,i;try{const l=yield W.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=>T(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 F=w.createElement("div",{ref:z,style:R(R({position:"relative"},p),h)}),{imgNode:V,zoom:$,currentPos:q}=e.current||{};return w.createElement(X,{spinning:M||H,delay:300,style:U},P&&V?w.createElement(ee,{size:p,imgNode:V,zoom:$,currentPos:q}):F)};var le=w.forwardRef(ae);export{le 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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@labelbee/lb-components",
3
- "version": "1.23.0-alpha.137",
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.68",
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",