@labelbee/lb-components 1.23.0-alpha.64 → 1.23.0-alpha.65

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.
@@ -1 +1 @@
1
- "use strict";var React=require("react"),ahooks=require("ahooks"),PointCloudContext=require("../PointCloudContext.js"),icon_link=require("../../../assets/annotation/icon_link.svg.js"),icon_unlink=require("../../../assets/annotation/icon_unlink.svg.js"),BatchSwitchConnectIn2DView=require("../../../views/MainView/toolFooter/BatchSwitchConnectIn2DView/BatchSwitchConnectIn2DView.js"),lbAnnotation=require("@labelbee/lb-annotation"),usePointCloudViews=require("./usePointCloudViews.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React);const useShownIcon=e=>{const{imageNamePointCloudBoxMap:i,linkageImageNameRectMap:s}=React.useContext(PointCloudContext.PointCloudContext),o=React.useMemo(()=>e?i.has(e):(console.error("Missing image name"),!1),[e,i]),a=React.useMemo(()=>{var c,u;return e?((u=(c=s.get(e))==null?void 0:c.size)!=null?u:0)>0:!1},[s,e]),r=React.useMemo(()=>o||a,[o,a]),d=ahooks.useLatest(r);return{visible:r,visibleRef:d}},iconSize={width:16,height:16},useDataLinkSwitch=e=>{e.imageName||console.warn("missing imageName");const[i,s]=React.useState(!0),o=ahooks.useLatest(e.imageName),{addRectFromPointCloudBoxByImageName:a,removeRectByPointCloudBoxId:r,linkageImageNameRectMap:d,pointCloudBoxList:c,rectList:u}=React.useContext(PointCloudContext.PointCloudContext),{visible:g,visibleRef:h}=useShownIcon(e.imageName),{syncToPointCloudBoxList:C}=usePointCloudViews.useSyncRectPositionDimensionToPointCloudList(),I=ahooks.useLatest(a),w=ahooks.useLatest(r),k=ahooks.useLatest(()=>C()),m=React.useCallback(n=>{if(!h.current)return;const t=o.current;if(!t){console.warn("invalid image name");return}s(n),n?w.current(t):I.current(t)},[]),b=ahooks.useLatest(n=>{n&&k.current(),m(n)}),x=React.useMemo(()=>{var n;if(!e.is2DView||!g)return null;const l={zIndex:(n=e.zIndex)!=null?n:999,position:"absolute",top:16,right:16+28+12,background:"rgba(0, 0, 0, 0.74)",color:"white",borderRadius:2,padding:6,display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28};return React__default.default.createElement("div",{style:l},i&&React__default.default.createElement("img",{src:icon_link,style:iconSize}),!i&&React__default.default.createElement("img",{src:icon_unlink,style:iconSize}))},[i,e.is2DView,e.zIndex,g]),R=ahooks.useLatest(d),f=React.useCallback(()=>{var n,t;if(!e.is2DView)return;const l=o.current;if(!l){console.warn("invalid image name");return}const L=[...(t=(n=R.current.get(l))==null?void 0:n.keys())!=null?t:[]];let v=!0;L.length&&(v=!1),m(v)},[e.is2DView,m]);return React.useEffect(()=>{f()},[f,c,u]),React.useEffect(()=>{const n=t=>{b.current(t)};return lbAnnotation.EventBus.on(BatchSwitchConnectIn2DView.EventBusEvent.switchConnect,n),()=>lbAnnotation.EventBus.unbind(BatchSwitchConnectIn2DView.EventBusEvent.switchConnect,n)},[]),{rendered:x,isLinking:i}};module.exports=useDataLinkSwitch;
1
+ "use strict";var React=require("react"),ahooks=require("ahooks"),PointCloudContext=require("../PointCloudContext.js"),icon_link=require("../../../assets/annotation/icon_link.svg.js"),icon_unlink=require("../../../assets/annotation/icon_unlink.svg.js"),BatchSwitchConnectIn2DView=require("../../../views/MainView/toolFooter/BatchSwitchConnectIn2DView/BatchSwitchConnectIn2DView.js"),lbAnnotation=require("@labelbee/lb-annotation"),usePointCloudViews=require("./usePointCloudViews.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React);const useShownIcon=e=>{const{imageNamePointCloudBoxMap:s,linkageImageNameRectMap:l}=React.useContext(PointCloudContext.PointCloudContext),a=React.useMemo(()=>e?s.has(e):(console.error("Missing image name"),!1),[e,s]),d=React.useMemo(()=>{var o,f;return e?((f=(o=l.get(e))==null?void 0:o.size)!=null?f:0)>0:!1},[l,e]),m=React.useMemo(()=>a||d,[a,d]),g=ahooks.useLatest(m);return{visible:m,visibleRef:g}},iconSize={width:16,height:16},useDataLinkSwitch=e=>{e.imageName||console.warn("missing imageName");const[s,l]=React.useState(!0),a=ahooks.useLatest(e.imageName),{addRectFromPointCloudBoxByImageName:d,removeRectByPointCloudBoxId:m,linkageImageNameRectMap:g,pointCloudBoxList:o,rectList:f,updateRectListByReducer:k}=React.useContext(PointCloudContext.PointCloudContext),{visible:v,visibleRef:x}=useShownIcon(e.imageName),{syncToPointCloudBoxList:b}=usePointCloudViews.useSyncRectPositionDimensionToPointCloudList(),R=ahooks.useLatest(d),L=ahooks.useLatest(m),B=ahooks.useLatest(()=>b()),h=React.useCallback(t=>{if(!x.current)return;const n=a.current;if(!n){console.warn("invalid image name");return}l(t),t?L.current(n):R.current(n)},[]),y=ahooks.useLatest(t=>{t&&B.current(),h(t)}),E=React.useMemo(()=>{var t;if(!e.is2DView||!v)return null;const i={zIndex:(t=e.zIndex)!=null?t:999,position:"absolute",top:16,right:16+28+12,background:"rgba(0, 0, 0, 0.74)",color:"white",borderRadius:2,padding:6,display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28};return React__default.default.createElement("div",{style:i},s&&React__default.default.createElement("img",{src:icon_link,style:iconSize}),!s&&React__default.default.createElement("img",{src:icon_unlink,style:iconSize}))},[s,e.is2DView,e.zIndex,v]),M=ahooks.useLatest(g),I=React.useCallback(()=>{var t,n;if(!e.is2DView)return;const i=a.current;if(!i){console.warn("invalid image name");return}const r=[...(n=(t=M.current.get(i))==null?void 0:t.keys())!=null?n:[]];let c=!0;r.length&&(c=!1),h(c)},[e.is2DView,h]);return React.useEffect(()=>{I()},[I,o,f]),React.useEffect(()=>{const t=o.map(i=>i.id),n=new Set(t);k((i,C)=>{const r=[],c=[];return i.forEach(u=>{const w=u.extId;w!==void 0&&n.has(w)===!1?r.push(u):c.push(u)}),r.length?[...r.map(u=>C(u)),...c]:i})},[o]),React.useEffect(()=>{const t=n=>{y.current(n)};return lbAnnotation.EventBus.on(BatchSwitchConnectIn2DView.EventBusEvent.switchConnect,t),()=>lbAnnotation.EventBus.unbind(BatchSwitchConnectIn2DView.EventBusEvent.switchConnect,t)},[]),{rendered:E,isLinking:s}};module.exports=useDataLinkSwitch;
@@ -1 +1 @@
1
- import h,{useState as V,useContext as C,useCallback as R,useMemo as d,useEffect as b}from"react";import{useLatest as o}from"ahooks";import{PointCloudContext as k}from"../PointCloudContext.js";import j from"../../../assets/annotation/icon_link.svg.js";import z from"../../../assets/annotation/icon_unlink.svg.js";import{EventBusEvent as x}from"../../../views/MainView/toolFooter/BatchSwitchConnectIn2DView/BatchSwitchConnectIn2DView.js";import{EventBus as p}from"@labelbee/lb-annotation";import{useSyncRectPositionDimensionToPointCloudList as F}from"./usePointCloudViews.js";const T=e=>{const{imageNamePointCloudBoxMap:i,linkageImageNameRectMap:a}=C(k),s=d(()=>e?i.has(e):(console.error("Missing image name"),!1),[e,i]),r=d(()=>{var l,u;return e?((u=(l=a.get(e))==null?void 0:l.size)!=null?u:0)>0:!1},[a,e]),c=d(()=>s||r,[s,r]),g=o(c);return{visible:c,visibleRef:g}},B={width:16,height:16},$=e=>{e.imageName||console.warn("missing imageName");const[i,a]=V(!0),s=o(e.imageName),{addRectFromPointCloudBoxByImageName:r,removeRectByPointCloudBoxId:c,linkageImageNameRectMap:g,pointCloudBoxList:l,rectList:u}=C(k),{visible:I,visibleRef:y}=T(e.imageName),{syncToPointCloudBoxList:L}=F(),M=o(r),N=o(c),P=o(()=>L()),f=R(n=>{if(!y.current)return;const t=s.current;if(!t){console.warn("invalid image name");return}a(n),n?N.current(t):M.current(t)},[]),D=o(n=>{n&&P.current(),f(n)}),_=d(()=>{var n;if(!e.is2DView||!I)return null;const m={zIndex:(n=e.zIndex)!=null?n:999,position:"absolute",top:16,right:16+28+12,background:"rgba(0, 0, 0, 0.74)",color:"white",borderRadius:2,padding:6,display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28};return h.createElement("div",{style:m},i&&h.createElement("img",{src:j,style:B}),!i&&h.createElement("img",{src:z,style:B}))},[i,e.is2DView,e.zIndex,I]),E=o(g),v=R(()=>{var n,t;if(!e.is2DView)return;const m=s.current;if(!m){console.warn("invalid image name");return}const S=[...(t=(n=E.current.get(m))==null?void 0:n.keys())!=null?t:[]];let w=!0;S.length&&(w=!1),f(w)},[e.is2DView,f]);return b(()=>{v()},[v,l,u]),b(()=>{const n=t=>{D.current(t)};return p.on(x.switchConnect,n),()=>p.unbind(x.switchConnect,n)},[]),{rendered:_,isLinking:i}};export{$ as default};
1
+ import v,{useState as T,useContext as p,useCallback as B,useMemo as h,useEffect as C}from"react";import{useLatest as s}from"ahooks";import{PointCloudContext as y}from"../PointCloudContext.js";import U from"../../../assets/annotation/icon_link.svg.js";import $ from"../../../assets/annotation/icon_unlink.svg.js";import{EventBusEvent as L}from"../../../views/MainView/toolFooter/BatchSwitchConnectIn2DView/BatchSwitchConnectIn2DView.js";import{EventBus as M}from"@labelbee/lb-annotation";import{useSyncRectPositionDimensionToPointCloudList as q}from"./usePointCloudViews.js";const A=e=>{const{imageNamePointCloudBoxMap:o,linkageImageNameRectMap:m}=p(y),r=h(()=>e?o.has(e):(console.error("Missing image name"),!1),[e,o]),d=h(()=>{var a,f;return e?((f=(a=m.get(e))==null?void 0:a.size)!=null?f:0)>0:!1},[m,e]),g=h(()=>r||d,[r,d]),I=s(g);return{visible:g,visibleRef:I}},N={width:16,height:16},G=e=>{e.imageName||console.warn("missing imageName");const[o,m]=T(!0),r=s(e.imageName),{addRectFromPointCloudBoxByImageName:d,removeRectByPointCloudBoxId:g,linkageImageNameRectMap:I,pointCloudBoxList:a,rectList:f,updateRectListByReducer:P}=p(y),{visible:R,visibleRef:D}=A(e.imageName),{syncToPointCloudBoxList:E}=q(),S=s(d),_=s(g),V=s(()=>E()),w=B(n=>{if(!D.current)return;const t=r.current;if(!t){console.warn("invalid image name");return}m(n),n?_.current(t):S.current(t)},[]),j=s(n=>{n&&V.current(),w(n)}),z=h(()=>{var n;if(!e.is2DView||!R)return null;const i={zIndex:(n=e.zIndex)!=null?n:999,position:"absolute",top:16,right:16+28+12,background:"rgba(0, 0, 0, 0.74)",color:"white",borderRadius:2,padding:6,display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28};return v.createElement("div",{style:i},o&&v.createElement("img",{src:U,style:N}),!o&&v.createElement("img",{src:$,style:N}))},[o,e.is2DView,e.zIndex,R]),F=s(I),k=B(()=>{var n,t;if(!e.is2DView)return;const i=r.current;if(!i){console.warn("invalid image name");return}const c=[...(t=(n=F.current.get(i))==null?void 0:n.keys())!=null?t:[]];let l=!0;c.length&&(l=!1),w(l)},[e.is2DView,w]);return C(()=>{k()},[k,a,f]),C(()=>{const n=a.map(i=>i.id),t=new Set(n);P((i,x)=>{const c=[],l=[];return i.forEach(u=>{const b=u.extId;b!==void 0&&t.has(b)===!1?c.push(u):l.push(u)}),c.length?[...c.map(u=>x(u)),...l]:i})},[a]),C(()=>{const n=t=>{j.current(t)};return M.on(L.switchConnect,n),()=>M.unbind(L.switchConnect,n)},[]),{rendered:z,isLinking:o}};export{G as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@labelbee/lb-components",
3
- "version": "1.23.0-alpha.64",
3
+ "version": "1.23.0-alpha.65",
4
4
  "description": "Provide a complete library of annotation components",
5
5
  "main": "./dist/index.js",
6
6
  "es": "./es/index.js",