@labelbee/lb-components 1.23.0-alpha.118 → 1.23.0-alpha.119

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
- import{useLatest as G,useMemoizedFn as U}from"ahooks";import{Spin as ie}from"antd/es";import A,{useContext as ce,useRef as H,useState as ue,useMemo as se,useCallback as ae,useEffect as f}from"react";import{connect as de}from"react-redux";import{usePointCloudViews as fe}from"../pointCloudView/hooks/usePointCloudViews.js";import{PointCloudContext as pe}from"../pointCloudView/PointCloudContext.js";import{a2MapStateToProps as me}from"../../store/annotation/map.js";import{LabelBeeContext as ve}from"../../store/ctx.js";import{PointCloud2DRectOperation as ge,ImgUtils as Re}from"@labelbee/lb-annotation";import{selectSpecifiedRectsFromTopViewSelectedIds as _e}from"./util.js";import{useUpdateRectList as he}from"./useUpdateRectList.js";import{useToolStyleContext as De}from"../../hooks/useToolStyle.js";var Ie=Object.defineProperty,be=Object.defineProperties,we=Object.getOwnPropertyDescriptors,K=Object.getOwnPropertySymbols,ye=Object.prototype.hasOwnProperty,Pe=Object.prototype.propertyIsEnumerable,Q=(s,i,c)=>i in s?Ie(s,i,{enumerable:!0,configurable:!0,writable:!0,value:c}):s[i]=c,m=(s,i)=>{for(var c in i||(i={}))ye.call(i,c)&&Q(s,c,i[c]);if(K)for(var c of K(i))Pe.call(i,c)&&Q(s,c,i[c]);return s},I=(s,i)=>be(s,we(i)),T=(s,i,c)=>new Promise((a,v)=>{var _=d=>{try{h(c.next(d))}catch(g){v(g)}},x=d=>{try{h(c.throw(d))}catch(g){v(g)}},h=d=>d.done?a(d.value):Promise.resolve(d.value).then(_,x);h((c=c.apply(s,i)).next())});const Ce=s=>{var i,c;const{mappingData:a,size:v,config:_,checkMode:x,afterImgOnLoad:h,shouldExcludePointCloudBoxListUpdate:d}=s,g=(i=a==null?void 0:a.url)!=null?i:"",b=(c=a==null?void 0:a.fallbackUrl)!=null?c:"",{pointCloudBoxList:S,setPointCloudResult:O,defaultAttribute:L,rectList:V,addRectIn2DView:W,updateRectIn2DView:X,removeRectIn2DView:Y,updateRectListByReducer:Z,selectedIDs:w,setSelectedIDs:j}=ce(pe),{value:E}=De(),ee=G(w),{update2DViewRect:te,remove2DViewRect:ne}=fe(),N=A.useRef(null),o=H(null),F=U(te),y=U(ne),P=H(null),[re,M]=ue(!0),k=se(()=>V==null?void 0:V.filter(e=>e.imageName===(a==null?void 0:a.path)),[a==null?void 0:a.path,V]),C=G(a==null?void 0:a.path),B=ae(e=>T(void 0,null,function*(){try{const r=ee.current.slice(0),t=yield Promise.resolve(e());if(!t||t.length===0)return t;if(r.length){const n=new Set(r),l=t.filter(u=>n.has(u.id)).map(u=>u.id);j(l)}return t}catch(r){}}),[j]),z=e=>{const{boxID:r}=e;if(!d&&r){B(()=>{const t=F==null?void 0:F(e);return t?(P.current=t,O(t),t):null});return}X(e,!0)},J=e=>{C.current&&W(I(m({},e),{imageName:C.current}))},$=e=>{if(e.length===0)return;if(!d){const t=e.find(n=>n.boxID);if(t){B(()=>{const n=y==null?void 0:y(t);return n?(P.current=n,O(n),R(),n):null});return}}const r=e.find(t=>t.extId);r&&B(()=>{const{imageName:t,extId:n}=r,l=y==null?void 0:y({boxID:n,imageName:t});return l?(P.current=l,O(l),l):null}),Y(e)},oe=U(()=>{let e=[];return S.forEach(r=>{const{rects:t=[],id:n,attribute:l,trackID:u}=r,p=t.find(le=>le.imageName===C.current),D=n+"_"+C.current;p&&(e=[...e,I(m({},p),{boxID:n,id:D,attribute:l,order:u})])}),e}),R=he(()=>{var e,r,t;const n=d?[]:oe(),l=(e=o.current)==null?void 0:e.selectedRectID,u=w.slice(0),p=_e(u,n,k);(r=o.current)==null||r.setResult(p),l&&((t=o.current)==null||t.setSelectedRectID(l))}),q=({targetId:e})=>j(e);return f(()=>{if(N.current){const e=new ge({container:N.current,size:v,config:I(m({},_),{isShowOrder:!0,attributeConfigurable:!0}),checkMode:x});return o.current=e,o.current.init(),o.current.on("updateDragResult",z),o.current.on("afterAddingDrawingRect",J),o.current.on("deleteSelectedRects",$),o.current.on("onRightClick",q),()=>{var r,t,n,l,u;(r=o.current)==null||r.unbind("updateDragResult",z),(t=o.current)==null||t.unbind("afterAddingDrawingRect",J),(n=o.current)==null||n.unbind("deleteSelectedRects",$),(l=o.current)==null||l.unbind("onRightClick",q),(u=o.current)==null||u.destroy()}}},[]),f(()=>{const e=t=>T(void 0,null,function*(){try{return yield Re.load(t)}catch(n){return console.error("Error loading image:",n),null}}),r=()=>T(void 0,null,function*(){var t;M(!0);let n=yield e(g);!n&&b&&(n=yield e(b)),n&&((t=o.current)==null||t.setImgNode(n),h(n)),M(!1)});o.current&&(g||b)&&r()},[g,b]),f(()=>{var e;(e=o.current)==null||e.setSize(v)},[v]),f(()=>{S!==P.current&&R()},[S]),f(()=>{var e,r;const t=k.find(n=>n.id===o.current.selectedRectID);(r=(e=o.current)==null?void 0:e.setDefaultAttribute)==null||r.call(e,L),t&&Z(n=>{var l;const u=[];let p=null;return n.forEach(D=>{D.id!==o.current.selectedRectID?u.push(D):p=D}),t.extId===void 0&&(p=(l=o.current)==null?void 0:l.selectedRect),[...u,I(m({},p||{}),{attribute:L})]}),R()},[L]),f(()=>{R()},[k]),f(()=>{R()},[d]),f(()=>{var e,r,t,n;const l=(r=(e=o.current)==null?void 0:e.config)!=null?r:{},u=I(m({},l),{attributeList:(t=_.attributeList)!=null?t:[]});(n=o.current)==null||n.setConfig(JSON.stringify(u))},[_.attributeList]),f(()=>{var e;(e=o.current)==null||e.setEnableAddRect(w.length===0),R()},[w]),f(()=>{const{hiddenText:e}=E||{};if(e===void 0)return;const r=o.current;if(!r)return;const t=m(m({},r.style),E);r.setStyle(t)},[E]),A.createElement(ie,{spinning:re},A.createElement("div",{ref:N,style:m({position:"relative"},v)}))};var xe=de(me,null,null,{context:ve})(Ce);export{xe as default};
1
+ import{useLatest as K,useMemoizedFn as U}from"ahooks";import{Spin as se}from"antd/es";import A,{useContext as ae,useRef as Q,useState as W,useMemo as de,useCallback as fe,useEffect as f}from"react";import{connect as pe}from"react-redux";import{usePointCloudViews as me}from"../pointCloudView/hooks/usePointCloudViews.js";import{PointCloudContext as ve}from"../pointCloudView/PointCloudContext.js";import{a2MapStateToProps as ge}from"../../store/annotation/map.js";import{LabelBeeContext as Re}from"../../store/ctx.js";import{PointCloud2DRectOperation as _e,ImgUtils as he}from"@labelbee/lb-annotation";import{selectSpecifiedRectsFromTopViewSelectedIds as Ie}from"./util.js";import{useUpdateRectList as De}from"./useUpdateRectList.js";import{useToolStyleContext as be}from"../../hooks/useToolStyle.js";var we=Object.defineProperty,ye=Object.defineProperties,Ce=Object.getOwnPropertyDescriptors,X=Object.getOwnPropertySymbols,Pe=Object.prototype.hasOwnProperty,xe=Object.prototype.propertyIsEnumerable,Y=(u,l,i)=>l in u?we(u,l,{enumerable:!0,configurable:!0,writable:!0,value:i}):u[l]=i,p=(u,l)=>{for(var i in l||(l={}))Pe.call(l,i)&&Y(u,i,l[i]);if(X)for(var i of X(l))xe.call(l,i)&&Y(u,i,l[i]);return u},D=(u,l)=>ye(u,Ce(l)),T=(u,l,i)=>new Promise((a,m)=>{var _=d=>{try{h(i.next(d))}catch(v){m(v)}},x=d=>{try{h(i.throw(d))}catch(v){m(v)}},h=d=>d.done?a(d.value):Promise.resolve(d.value).then(_,x);h((i=i.apply(u,l)).next())});const Se=u=>{var l,i;const{mappingData:a,size:m,config:_,checkMode:x,afterImgOnLoad:h,shouldExcludePointCloudBoxListUpdate:d}=u,v=(l=a==null?void 0:a.url)!=null?l:"",b=(i=a==null?void 0:a.fallbackUrl)!=null?i:"",{pointCloudBoxList:S,setPointCloudResult:O,defaultAttribute:L,rectList:V,addRectIn2DView:Z,updateRectIn2DView:ee,removeRectIn2DView:te,updateRectListByReducer:ne,selectedIDs:w,setSelectedIDs:j}=ae(ve),{value:k}=be(),re=K(w),{update2DViewRect:oe,remove2DViewRect:le}=me(),E=A.useRef(null),o=Q(null),F=U(oe),y=U(le),C=Q(null),[ie,M]=W(!0),[z,J]=W(""),N=de(()=>V==null?void 0:V.filter(e=>e.imageName===(a==null?void 0:a.path)),[a==null?void 0:a.path,V]),P=K(a==null?void 0:a.path),B=fe(e=>T(void 0,null,function*(){try{const r=re.current.slice(0),t=yield Promise.resolve(e());if(!t||t.length===0)return t;if(r.length){const n=new Set(r),c=t.filter(s=>n.has(s.id)).map(s=>s.id);j(c)}return t}catch(r){}}),[j]),$=e=>{const{boxID:r}=e;if(!d&&r){B(()=>{const t=F==null?void 0:F(e);return t?(C.current=t,O(t),t):null});return}ee(e,!0)},q=e=>{P.current&&Z(D(p({},e),{imageName:P.current}))},G=e=>{if(e.length===0)return;if(!d){const t=e.find(n=>n.boxID);if(t){B(()=>{const n=y==null?void 0:y(t);return n?(C.current=n,O(n),g(),n):null});return}}const r=e.find(t=>t.extId);r&&B(()=>{const{imageName:t,extId:n}=r,c=y==null?void 0:y({boxID:n,imageName:t});return c?(C.current=c,O(c),c):null}),te(e)},ce=U(()=>{let e=[];return S.forEach(r=>{const{rects:t=[],id:n,attribute:c,trackID:s}=r,R=t.find(ue=>ue.imageName===P.current),I=n+"_"+P.current;R&&(e=[...e,D(p({},R),{boxID:n,id:I,attribute:c,order:s})])}),e}),g=De(()=>{var e,r;const t=d?[]:ce(),n=w.slice(0),c=Ie(n,t,N);(e=o.current)==null||e.setResult(c),z&&((r=o.current)==null||r.setSelectedRectID(z),J(""))}),H=({targetId:e,id:r})=>{j(e),J(r)};return f(()=>{if(E.current){const e=new _e({container:E.current,size:m,config:D(p({},_),{isShowOrder:!0,attributeConfigurable:!0}),checkMode:x});return o.current=e,o.current.init(),o.current.on("updateDragResult",$),o.current.on("afterAddingDrawingRect",q),o.current.on("deleteSelectedRects",G),o.current.on("onRightClick",H),()=>{var r,t,n,c,s;(r=o.current)==null||r.unbind("updateDragResult",$),(t=o.current)==null||t.unbind("afterAddingDrawingRect",q),(n=o.current)==null||n.unbind("deleteSelectedRects",G),(c=o.current)==null||c.unbind("onRightClick",H),(s=o.current)==null||s.destroy()}}},[]),f(()=>{const e=t=>T(void 0,null,function*(){try{return yield he.load(t)}catch(n){return console.error("Error loading image:",n),null}}),r=()=>T(void 0,null,function*(){var t;M(!0);let n=yield e(v);!n&&b&&(n=yield e(b)),n&&((t=o.current)==null||t.setImgNode(n),h(n)),M(!1)});o.current&&(v||b)&&r()},[v,b]),f(()=>{var e;(e=o.current)==null||e.setSize(m)},[m]),f(()=>{S!==C.current&&g()},[S]),f(()=>{var e,r;const t=N.find(n=>n.id===o.current.selectedRectID);(r=(e=o.current)==null?void 0:e.setDefaultAttribute)==null||r.call(e,L),t&&ne(n=>{var c;const s=[];let R=null;return n.forEach(I=>{I.id!==o.current.selectedRectID?s.push(I):R=I}),t.extId===void 0&&(R=(c=o.current)==null?void 0:c.selectedRect),[...s,D(p({},R||{}),{attribute:L})]}),g()},[L]),f(()=>{g()},[N]),f(()=>{g()},[d]),f(()=>{var e,r,t,n;const c=(r=(e=o.current)==null?void 0:e.config)!=null?r:{},s=D(p({},c),{attributeList:(t=_.attributeList)!=null?t:[]});(n=o.current)==null||n.setConfig(JSON.stringify(s))},[_.attributeList]),f(()=>{var e;(e=o.current)==null||e.setEnableAddRect(w.length===0),g()},[w]),f(()=>{const{hiddenText:e}=k||{};if(e===void 0)return;const r=o.current;if(!r)return;const t=p(p({},r.style),k);r.setStyle(t)},[k]),A.createElement(se,{spinning:ie},A.createElement("div",{ref:E,style:p({position:"relative"},m)}))};var Oe=pe(ge,null,null,{context:Re})(Se);export{Oe as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@labelbee/lb-components",
3
- "version": "1.23.0-alpha.118",
3
+ "version": "1.23.0-alpha.119",
4
4
  "description": "Provide a complete library of annotation components",
5
5
  "main": "./dist/index.js",
6
6
  "es": "./es/index.js",
@@ -43,7 +43,7 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@ant-design/icons": "^4.6.2",
46
- "@labelbee/lb-annotation": "1.27.0-alpha.59",
46
+ "@labelbee/lb-annotation": "1.27.0-alpha.60",
47
47
  "@labelbee/lb-utils": "1.19.0-alpha.22",
48
48
  "@labelbee/wavesurfer": "1.1.0-alpha.1",
49
49
  "@types/react-dom": "^18.2.7",