@labelbee/lb-components 1.23.0-alpha.130 → 1.23.0-alpha.132

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 l,{useState as M,useRef as Dt,useMemo as G,useEffect as V}from"react";import{LabelBeeContext as It}from"../../../store/ctx.js";import{connect as Ot}from"react-redux";import{prefix as Vt}from"../../../constant/index.js";import{getStepConfig as Nt}from"../../../store/annotation/reducer.js";import{jsonParser as ut}from"../../../utils/index.js";import Bt,{getSorts as dt}from"../../LLMToolView/sidebar/components/modelAnswerSort/index.js";import{useTranslation as $t}from"react-i18next";import{useCustomToolInstance as Wt}from"../../../hooks/annotation.js";import{isBoolean as Ft,isString as qt,isNumber as kt,isObject as Gt,isArray as Kt}from"lodash";import{PageForward as N}from"../../../store/annotation/actionCreators.js";import{cKeyCode as zt,EToolName as Ut}from"@labelbee/lb-annotation";import{getLLMIsNoConfig as Qt,EmptyConfig as Jt}from"../../LLMToolView/sidebar/index.js";import Ht from"../../LLMToolView/sidebar/components/textInputBox/index.js";import{Button as ct}from"antd";import Xt from"../../LLMToolView/sidebar/components/answerList/index.js";import Yt from"../../../store/LLMMultiWheel/index.js";import Zt from"../../../utils/StepUtils.js";import{getCurrentResultFromResultList as te,getRenderDataByResult as ee}from"../../LLMToolView/utils/data.js";import{useMemoizedFn as K}from"ahooks";import ne from"../../LLMToolView/sidebar/components/answerSort/index.js";var oe=Object.defineProperty,re=Object.defineProperties,le=Object.getOwnPropertyDescriptors,pt=Object.getOwnPropertySymbols,ie=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable,mt=(c,s,p)=>s in c?oe(c,s,{enumerable:!0,configurable:!0,writable:!0,value:p}):c[s]=p,i=(c,s)=>{for(var p in s||(s={}))ie.call(s,p)&&mt(c,p,s[p]);if(pt)for(var p of pt(s))se.call(s,p)&&mt(c,p,s[p]);return c},a=(c,s)=>re(c,le(s));const ae=zt.default,ft=`${Vt}-sidebar`,ue={sort:[],answerSort:{},textAttribute:[]},de=c=>{var s,p,z,U,Q,J,H;const{annotation:vt,dispatch:C,checkMode:Lt}=c,{imgIndex:S,imgList:B,stepList:A,step:h,skipBeforePageTurning:j}=vt,[m,xt]=M(),{t:T}=$t(),r=(s=B[S])!=null?s:{},X=ut(r==null?void 0:r.result),{toolInstanceRef:v}=Wt({basicInfo:X}),[$,gt]=M(!0),[R,Y]=M({}),[P,Z]=M(ue),W=Dt(),[x,F]=M({}),{selectedID:D,setNewAnswerListMap:tt,newAnswerListMap:et}=Yt(),g=G(()=>R[D],[D,R]),b=!v.current.valid||Lt;V(()=>{var t;if(A&&h){const e=(t=Nt(A,h))==null?void 0:t.config;xt(ut(e))}},[h,JSON.stringify(A)]),V(()=>{!r||S===-1||(v.current.setValid=nt,v.current.clearResult=wt,nt(),ot())},[S,m,r==null?void 0:r.id]);const wt=()=>{var t,e,n,u,f;ot((t=r==null?void 0:r.questionList)==null?void 0:t.textList),((e=W.current)==null?void 0:e.clearValue)&&((n=W.current)==null||n.clearValue());const{waitSorts:o}=dt({selectedSort:(f=(u=I())==null?void 0:u.sort)!=null?f:[],initSelected:[],modelList:E?O!=null?O:[]:[]});F(a(i({},x),{waitSorts:o,newSort:[]}))},nt=t=>{var e;const n=t!=null?t:X.valid;Ft(n)&&(gt(n),v.current.valid=n,(e=v.current)==null||e.emit("validUpdated"))},I=()=>{const t=Zt.getCurrentStepInfo(h,A);return te(r==null?void 0:r.result,t.step)},ot=K(t=>{var e,n,u,f,o,L,y;const d=I();let w=(e=r==null?void 0:r.questionList)==null?void 0:e.textList;((n=d==null?void 0:d.modelData)==null?void 0:n.length)&&v.current.valid&&(w=d==null?void 0:d.modelData),t&&(w=t,d.sort=[],d.textAttribute=[],d.answerSort=[]);let st={};w==null||w.forEach((_,Tt)=>{var at;const Rt=ee(m,a(i({},_),{answerList:(at=_==null?void 0:_.answerList)==null?void 0:at.map((k,Pt)=>(tt(a(i({},et),{[`${_.id}-${k.id}`]:k.answer})),a(i({},k),{order:Pt+1})))}));st[_.id]=a(i({},Rt),{order:Tt+1,id:_.id})});const{waitSorts:ht,newSort:jt}=dt({selectedSort:(f=(u=I())==null?void 0:u.sort)!=null?f:[],modelList:E?O!=null?O:[]:[]});F({waitSorts:ht,newSort:jt}),Z({sort:(o=d==null?void 0:d.sort)!=null?o:[],textAttribute:(L=d==null?void 0:d.textAttribute)!=null?L:[],answerSort:(y=d==null?void 0:d.answerSort)!=null?y:{}}),Y(st)});V(()=>{_t()},[R,$,P]),V(()=>(window.addEventListener("keydown",rt),()=>{window.removeEventListener("keydown",rt)}),[]);const _t=K(()=>{var t,e;const n=(e=(t=r==null?void 0:r.questionList)==null?void 0:t.textList)==null?void 0:e.map(f=>{var o;const L=(o=R[f.id])!=null?o:{};return{id:f.id,answerList:L.answerList}}),u=a(i({},P),{modelData:n});v.current.exportData=()=>[[u],{valid:$}],v.current.currentPageResult=a(i({},u),{toolName:Ut.LLMMultiWheel,valid:$})}),rt=t=>{if(t.ctrlKey&&t.keyCode===ae.Enter){if(j){j(()=>C(N()));return}C(N())}},St=K(({order:t,value:e,key:n})=>{const{answerList:u}=g,f=u==null?void 0:u.map(o=>{var L,y;if((o==null?void 0:o.order)===t){if(n==="textEdit"&&qt(e))return tt(a(i({},et),{[`${D}-${(L=o==null?void 0:o.id)!=null?L:""}`]:e})),a(i({},o),{newAnswer:e});if(kt(e))return a(i({},o),{score:e});if(Gt(e)&&n){const d={[e==null?void 0:e.key]:e.value},w=(y=o[n])!=null?y:{};return a(i({},o),{[n]:i(i({},w),d)})}}return o});Y(o=>a(i({},o),{[D]:a(i({},g),{answerList:f})}))}),q=(t,e)=>{Z(n=>a(i({},n),{[t]:e}))},{indicatorScore:lt=[],indicatorDetermine:it=[],isTextEdit:bt,dialogSort:E=!1,inputList:Et=[],tagInputListConfigurable:yt,enableSort:Mt=!1}=m||{},O=G(()=>{var t,e,n;return E?(n=(e=(t=r==null?void 0:r.questionList)==null?void 0:t.textList)==null?void 0:e.map((u,f)=>a(i({},u),{title:f+1})))!=null?n:[]:[]},[r,E]);if(G(()=>Qt(m),[m]))return l.createElement(Jt,null);const Ct=yt&&((p=Et.filter(t=>!t.isOverall))==null?void 0:p.length)>0,At=(it==null?void 0:it.length)>0||(lt==null?void 0:lt.length)>0||bt||Ct;return l.createElement("div",{className:`${ft}`},l.createElement("div",{className:`${ft}__content`},l.createElement("div",{style:{fontSize:"18px",fontWeight:500,padding:"0px 16px",marginTop:"16px"}},T("GlobalAnnotation")),E&&l.createElement(ne,{waitSortList:(x==null?void 0:x.waitSorts)||[],sortList:(x==null?void 0:x.newSort)||[],setSortList:t=>{const e=t.map(n=>n.map(u=>u.id));q("sort",e),F(a(i({},x),{newSort:t}))},disabeledAll:b,title:T("SortConversationQuality"),prefixId:"model"}),(m==null?void 0:m.text)&&l.createElement("div",{style:{padding:"0px 16px",marginTop:"16px"}},l.createElement(Ht,{textAttribute:(z=P==null?void 0:P.textAttribute)!=null?z:[],textConfig:(m==null?void 0:m.text)&&Kt(m.text)?m==null?void 0:m.text:[],setText:t=>q("textAttribute",t),disabeledAll:b})),Mt&&l.createElement(Bt,{modelData:(Q=(U=r==null?void 0:r.questionList)==null?void 0:U.textList)!=null?Q:[],selectedAnswerSort:t=>q("answerSort",t),selectedSort:(H=(J=I())==null?void 0:J.answerSort)!=null?H:[],ref:W,disabeledAll:b,imgIndex:S}),g&&l.createElement(l.Fragment,null,l.createElement("div",{style:{fontSize:"18px",fontWeight:500,padding:"0px 16px",marginTop:"16px"}},T("QualifiedAnnotation")),l.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center"}},l.createElement(ct,{type:"primary",danger:!0},"\u6B63\u5728\u6807\u6CE8"),l.createElement("div",{style:{padding:16}},"\u7EC4\uFF1A",g.order)),l.createElement("div",null,At&&l.createElement(Xt,{list:(g==null?void 0:g.answerList)||[],LLMConfig:m,updateValue:St,disabeledAll:b})))),l.createElement("div",{style:{margin:"24px 16px",display:"flex"}},(B==null?void 0:B.length)-1!==S&&l.createElement(ct,{type:"primary",style:{marginLeft:"auto"},onClick:()=>{if(j){j(()=>C(N()));return}C(N())},disabled:b},T("Save"))))},ce=c=>({annotation:c.annotation});var pe=Ot(ce,null,null,{context:It})(de);export{pe as default};
1
+ import r,{useState as j,useRef as Dt,useMemo as N,useEffect as B}from"react";import{LabelBeeContext as Pt}from"../../../store/ctx.js";import{connect as Ot}from"react-redux";import{prefix as It}from"../../../constant/index.js";import{getStepConfig as Vt}from"../../../store/annotation/reducer.js";import{jsonParser as ut}from"../../../utils/index.js";import Nt,{getSorts as dt}from"../../LLMToolView/sidebar/components/modelAnswerSort/index.js";import{useTranslation as Bt}from"react-i18next";import{useCustomToolInstance as $t}from"../../../hooks/annotation.js";import{isBoolean as Wt,isString as Ft,isNumber as kt,isObject as qt,isArray as Gt}from"lodash";import{PageForward as $}from"../../../store/annotation/actionCreators.js";import{cKeyCode as Kt,EToolName as zt}from"@labelbee/lb-annotation";import{getLLMIsNoConfig as Ut,EmptyConfig as Qt}from"../../LLMToolView/sidebar/index.js";import Jt from"../../LLMToolView/sidebar/components/textInputBox/index.js";import{Button as ct}from"antd";import Ht from"../../LLMToolView/sidebar/components/answerList/index.js";import Xt from"../../../store/LLMMultiWheel/index.js";import Yt from"../../../utils/StepUtils.js";import{getRenderDataByResult as Zt,getCurrentResultFromResultList as te}from"../../LLMToolView/utils/data.js";import{useMemoizedFn as z}from"ahooks";import ee from"../../LLMToolView/sidebar/components/answerSort/index.js";import ne from"../../tagList/components/overall/index.js";var oe=Object.defineProperty,re=Object.defineProperties,le=Object.getOwnPropertyDescriptors,pt=Object.getOwnPropertySymbols,ie=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable,mt=(c,d,p)=>d in c?oe(c,d,{enumerable:!0,configurable:!0,writable:!0,value:p}):c[d]=p,l=(c,d)=>{for(var p in d||(d={}))ie.call(d,p)&&mt(c,p,d[p]);if(pt)for(var p of pt(d))se.call(d,p)&&mt(c,p,d[p]);return c},u=(c,d)=>re(c,le(d));const ae=Kt.default,ft=`${It}-sidebar`,ue={sort:[],answerSort:{},textAttribute:[],tagList:{}},de=c=>{var d,p,U,Q,J,H;const{annotation:vt,dispatch:A,checkMode:Lt}=c,{imgIndex:y,imgList:W,stepList:M,step:C,skipBeforePageTurning:T}=vt,[m,gt]=j(),{t:R}=Bt(),o=(d=W[y])!=null?d:{},X=ut(o==null?void 0:o.result),{toolInstanceRef:v}=$t({basicInfo:X}),[F,xt]=j(!0),[D,Y]=j({}),[L,Z]=j(ue),k=Dt(),[w,q]=j({}),{selectedID:P,setNewAnswerListMap:tt,newAnswerListMap:et}=Xt(),S=N(()=>D[P],[P,D]),_=!v.current.valid||Lt;B(()=>{var t;if(M&&C){const e=(t=Vt(M,C))==null?void 0:t.config;gt(ut(e))}},[C,JSON.stringify(M)]),B(()=>{!o||y===-1||(v.current.setValid=nt,v.current.clearResult=wt,nt(),ot())},[y,m,o==null?void 0:o.id]);const wt=()=>{var t,e,n,s;ot((t=o==null?void 0:o.questionList)==null?void 0:t.textList),((e=k.current)==null?void 0:e.clearValue)&&((n=k.current)==null||n.clearValue());const{waitSorts:f}=dt({selectedSort:(s=g==null?void 0:g.sort)!=null?s:[],initSelected:[],modelList:h?I!=null?I:[]:[]});q(u(l({},w),{waitSorts:f,newSort:[]}))},nt=t=>{var e;const n=t!=null?t:X.valid;Wt(n)&&(xt(n),v.current.valid=n,(e=v.current)==null||e.emit("validUpdated"))},St=()=>{const t=Yt.getCurrentStepInfo(C,M);return te(o==null?void 0:o.result,t.step)},g=N(()=>St(),[C,M,o]),ot=z(t=>{var e,n,s,f,a,x;const i=g;let b=(e=o==null?void 0:o.questionList)==null?void 0:e.textList;((n=i==null?void 0:i.modelData)==null?void 0:n.length)&&v.current.valid&&(b=i==null?void 0:i.modelData),t&&(b=t,i.sort=[],i.textAttribute=[],i.answerSort=[]);let V={};b==null||b.forEach((E,At)=>{var at;const Tt=Zt(m,u(l({},E),{answerList:(at=E==null?void 0:E.answerList)==null?void 0:at.map((K,Rt)=>(tt(u(l({},et),{[`${E.id}-${K.id}`]:K.answer})),u(l({},K),{order:Rt+1})))}));V[E.id]=u(l({},Tt),{order:At+1,id:E.id})});const{waitSorts:ht,newSort:jt}=dt({selectedSort:(s=g==null?void 0:g.sort)!=null?s:[],modelList:h?I!=null?I:[]:[]});q({waitSorts:ht,newSort:jt}),Z({sort:(f=i==null?void 0:i.sort)!=null?f:[],textAttribute:(a=i==null?void 0:i.textAttribute)!=null?a:[],answerSort:(x=i==null?void 0:i.answerSort)!=null?x:{},tagList:i==null?void 0:i.tagList}),Y(V)});B(()=>{_t()},[D,F,L]),B(()=>(window.addEventListener("keydown",rt),()=>{window.removeEventListener("keydown",rt)}),[]);const _t=z(()=>{var t,e;const n=(e=(t=o==null?void 0:o.questionList)==null?void 0:t.textList)==null?void 0:e.map(f=>{var a;const x=(a=D[f.id])!=null?a:{};return{id:f.id,answerList:x.answerList}}),s=u(l({},L),{modelData:n});v.current.exportData=()=>[[s],{valid:F}],v.current.currentPageResult=u(l({},s),{toolName:zt.LLMMultiWheel,valid:F})}),rt=t=>{if(t.ctrlKey&&t.keyCode===ae.Enter){if(T){T(()=>A($()));return}A($())}},bt=z(({order:t,value:e,key:n})=>{const{answerList:s}=S,f=s==null?void 0:s.map(a=>{var x,i;if((a==null?void 0:a.order)===t){if(n==="textEdit"&&Ft(e))return tt(u(l({},et),{[`${P}-${(x=a==null?void 0:a.id)!=null?x:""}`]:e})),u(l({},a),{newAnswer:e});if(kt(e))return u(l({},a),{score:e});if(qt(e)&&n){const b={[e==null?void 0:e.key]:e.value},V=(i=a[n])!=null?i:{};return u(l({},a),{[n]:l(l({},V),b)})}}return a});Y(a=>u(l({},a),{[P]:u(l({},S),{answerList:f})}))}),O=(t,e)=>{Z(n=>u(l({},n),{[t]:e}))},{indicatorScore:lt=[],indicatorDetermine:it=[],isTextEdit:Et,dialogSort:h=!1,inputList:G=[],tagInputListConfigurable:st,enableSort:yt=!1}=m||{},I=N(()=>{var t,e,n;return h?(n=(e=(t=o==null?void 0:o.questionList)==null?void 0:t.textList)==null?void 0:e.map((s,f)=>u(l({},s),{title:f+1})))!=null?n:[]:[]},[o,h]);if(N(()=>Ut(m),[m]))return r.createElement(Qt,null);const Mt=st&&((p=G.filter(t=>!t.isOverall))==null?void 0:p.length)>0,Ct=(it==null?void 0:it.length)>0||(lt==null?void 0:lt.length)>0||Et||Mt;return r.createElement("div",{className:`${ft}`},r.createElement("div",{className:`${ft}__content`},r.createElement("div",{style:{fontSize:"18px",fontWeight:500,padding:"0px 16px",marginTop:"16px"}},R("GlobalAnnotation")),h&&r.createElement(ee,{waitSortList:(w==null?void 0:w.waitSorts)||[],sortList:(w==null?void 0:w.newSort)||[],setSortList:t=>{const e=t.map(n=>n.map(s=>s.id));O("sort",e),q(u(l({},w),{newSort:t}))},disabeledAll:_,title:R("SortConversationQuality"),prefixId:"model"}),(m==null?void 0:m.text)&&r.createElement("div",{style:{padding:"0px 16px",marginTop:"16px"}},r.createElement(Jt,{textAttribute:(U=L==null?void 0:L.textAttribute)!=null?U:[],textConfig:(m==null?void 0:m.text)&&Gt(m.text)?m==null?void 0:m.text:[],setText:t=>O("textAttribute",t),disabeledAll:_})),yt&&r.createElement(Nt,{modelData:(J=(Q=o==null?void 0:o.questionList)==null?void 0:Q.textList)!=null?J:[],selectedAnswerSort:t=>O("answerSort",t),selectedSort:(H=g==null?void 0:g.answerSort)!=null?H:[],ref:k,disabeledAll:_,imgIndex:y}),st&&G.length&&r.createElement(ne,{inputList:G,selectedTags:(L==null?void 0:L.tagList)||{},updateValue:t=>{const{key:e,value:n}=t,s=(L==null?void 0:L.tagList)||{};O("tagList",u(l({},s),{[e]:n}))},disabeledAll:_}),S&&r.createElement(r.Fragment,null,r.createElement("div",{style:{fontSize:"18px",fontWeight:500,padding:"0px 16px",marginTop:"16px"}},R("QualifiedAnnotation")),r.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center"}},r.createElement(ct,{type:"primary",danger:!0},"\u6B63\u5728\u6807\u6CE8"),r.createElement("div",{style:{padding:16}},"\u7EC4\uFF1A",S.order)),r.createElement("div",null,Ct&&r.createElement(Ht,{list:(S==null?void 0:S.answerList)||[],LLMConfig:m,updateValue:bt,disabeledAll:_})))),r.createElement("div",{style:{margin:"24px 16px",display:"flex"}},(W==null?void 0:W.length)-1!==y&&r.createElement(ct,{type:"primary",style:{marginLeft:"auto"},onClick:()=>{if(T){T(()=>A($()));return}A($())},disabled:_},R("Save"))))},ce=c=>({annotation:c.annotation});var pe=Ot(ce,null,null,{context:Pt})(de);export{pe as default};
@@ -1 +1 @@
1
- import{useLatest as oe,useMemoizedFn as H}from"ahooks";import{Spin as he}from"antd/es";import J,{useContext as Ie,useRef as $,useState as S,useMemo as _e,useCallback as De,useEffect as p}from"react";import{connect as be}from"react-redux";import{usePointCloudViews as Ce}from"../pointCloudView/hooks/usePointCloudViews.js";import{PointCloudContext as we}from"../pointCloudView/PointCloudContext.js";import{a2MapStateToProps as ye}from"../../store/annotation/map.js";import{LabelBeeContext as xe}from"../../store/ctx.js";import{PointCloud2DRectOperation as Pe,MathUtils as Se,ImgUtils as Le}from"@labelbee/lb-annotation";import{selectSpecifiedRectsFromTopViewSelectedIds as Oe}from"./util.js";import{useUpdateRectList as Ve}from"./useUpdateRectList.js";import je from"lodash";import{useToolStyleContext as Ee}from"../../hooks/useToolStyle.js";import ke from"../../store/toolConfig/index.js";var Ne=Object.defineProperty,Ue=Object.defineProperties,Be=Object.getOwnPropertyDescriptors,ie=Object.getOwnPropertySymbols,Me=Object.prototype.hasOwnProperty,ze=Object.prototype.propertyIsEnumerable,le=(u,c,s)=>c in u?Ne(u,c,{enumerable:!0,configurable:!0,writable:!0,value:s}):u[c]=s,v=(u,c)=>{for(var s in c||(c={}))Me.call(c,s)&&le(u,s,c[s]);if(ie)for(var s of ie(c))ze.call(c,s)&&le(u,s,c[s]);return u},C=(u,c)=>Ue(u,Be(c)),G=(u,c,s)=>new Promise((a,g)=>{var D=f=>{try{b(s.next(f))}catch(R){g(R)}},L=f=>{try{b(s.throw(f))}catch(R){g(R)}},b=f=>f.done?a(f.value):Promise.resolve(f.value).then(D,L);b((s=s.apply(u,c)).next())});const Ae=u=>{var c,s;const{mappingData:a,size:g,config:D,checkMode:L,afterImgOnLoad:b,shouldExcludePointCloudBoxListUpdate:f}=u,{selectBoxVisibleSwitch:R}=ke(),O=(c=a==null?void 0:a.url)!=null?c:"",w=(s=a==null?void 0:a.fallbackUrl)!=null?s:"",{pointCloudBoxList:V,setPointCloudResult:j,defaultAttribute:E,rectList:k,addRectIn2DView:ce,updateRectIn2DView:se,removeRectIn2DView:ue,updateRectListByReducer:de,selectedIDs:m,setSelectedIDs:N,selectedID:U}=Ie(we),{value:B}=Ee(),ae=oe(m),{update2DViewRect:fe,remove2DViewRect:pe}=Ce(),M=J.useRef(null),o=$(null),K=H(fe),y=H(pe),x=$(null),[me,Q]=S(!0),[W,X]=S(""),[ve,z]=S(!1),[ge,A]=S(!0),h=_e(()=>k==null?void 0:k.filter(e=>e.imageName===(a==null?void 0:a.path)),[a==null?void 0:a.path,k]),Y=$(h),P=oe(a==null?void 0:a.path),T=De(e=>G(void 0,null,function*(){try{const n=ae.current.slice(0),r=yield Promise.resolve(e());if(!r||r.length===0)return r;if(n.length){const t=new Set(n),i=r.filter(l=>t.has(l.id)).map(l=>l.id);N(i)}return r}catch(n){}}),[N]),Z=e=>{const{boxID:n}=e;if(!f&&n){T(()=>{const r=K==null?void 0:K(e);return r?(x.current=r,j(r),r):null});return}se(e,!0)},ee=e=>{P.current&&ce(C(v({},e),{imageName:P.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?(x.current=t,j(t),I(),t):null});return}}const n=e.find(r=>r.extId);n&&T(()=>{const{imageName:r,extId:t}=n,i=y==null?void 0:y({boxID:t,imageName:r});return i?(x.current=i,j(i),i):null}),ue(e)},Re=H(()=>{let e=[];return V.forEach(n=>{const{rects:r=[],id:t,attribute:i,trackID:l}=n,d=r.find(F=>F.imageName===P.current),_=t+"_"+P.current;d&&(e=[...e,C(v({},d),{boxID:t,id:_,attribute:i,order:l})])}),e}),I=Ve(()=>{var e,n,r,t,i;const l=f?[]:Re(),d=(e=o.current)==null?void 0:e.selectedRectID,_=m.slice(0),F=R?Oe(_,l,h):[...l,...h];let ne=[];!R&&(m==null?void 0:m.length)&&(ne=l.filter(q=>d?m.includes(q.boxID)&&!d.includes(q.boxID):m.includes(q.boxID))),(n=o.current)==null||n.setHighLightRectList(ne),(r=o.current)==null||r.setResult(F),W?((t=o.current)==null||t.setSelectedRectID(W),X("")):ve&&d&&((i=o.current)==null||i.setSelectedRectID(d),z(!1))}),re=({targetId:e,id:n})=>{A(!1),N(e),X(n)};return p(()=>{if(M.current){const e=new Pe({container:M.current,size:g,config:C(v({},D),{isShowOrder:!0,attributeConfigurable:!0}),checkMode:L});return o.current=e,o.current.init(),o.current.on("updateDragResult",Z),o.current.on("afterAddingDrawingRect",ee),o.current.on("deleteSelectedRects",te),o.current.on("onRightClick",re),()=>{var n,r,t,i,l;(n=o.current)==null||n.unbind("updateDragResult",Z),(r=o.current)==null||r.unbind("afterAddingDrawingRect",ee),(t=o.current)==null||t.unbind("deleteSelectedRects",te),(i=o.current)==null||i.unbind("onRightClick",re),(l=o.current)==null||l.destroy()}}},[]),p(()=>{const e=r=>G(void 0,null,function*(){try{return yield Le.load(r)}catch(t){return console.error("Error loading image:",t),null}}),n=()=>G(void 0,null,function*(){var r;Q(!0);let t=yield e(O);!t&&w&&(t=yield e(w)),t&&((r=o.current)==null||r.setImgNode(t),b(t)),Q(!1)});o.current&&(O||w)&&n()},[O,w]),p(()=>{var e;(e=o.current)==null||e.setSize(g)},[g]),p(()=>{V!==x.current&&I()},[V]),p(()=>{var e,n;const r=h.find(t=>t.id===o.current.selectedRectID);(n=(e=o.current)==null?void 0:e.setDefaultAttribute)==null||n.call(e,E),r&&de(t=>{var i;const l=[];let d=null;return t.forEach(_=>{_.id!==o.current.selectedRectID?l.push(_):d=_}),r.extId===void 0&&(d=(i=o.current)==null?void 0:i.selectedRect),[...l,C(v({},d||{}),{attribute:E})]}),z(!0),I()},[E]),p(()=>{const e=Y.current;je.isEqual(e,h)||(z(!0),I(),Y.current=h)},[h]),p(()=>{I()},[f]),p(()=>{var e,n,r,t;const i=(n=(e=o.current)==null?void 0:e.config)!=null?n:{},l=C(v({},i),{attributeList:(r=D.attributeList)!=null?r:[]});(t=o.current)==null||t.setConfig(JSON.stringify(l))},[D.attributeList]),p(()=>{var e;(e=o.current)==null||e.setEnableAddRect(m.length===0),I()},[m]),p(()=>{if(!U||!ge){A(!0);return}const{rectList:e,size:n,zoom:r}=o.current,t=e.find(d=>d.boxID===U);if(!t){A(!0);return}const i={x:t.x+t.width/2,y:t.y+t.height/2},l=Se.getCurrentPosFromRectCenter(n,i,r);o.current.setCurrentPos(l),o.current.render()},[U]),p(()=>{const{hiddenText:e}=B||{};if(e===void 0)return;const n=o.current;if(!n)return;const r=v(v({},n.style),B);n.setStyle(r)},[B]),p(()=>{I()},[R]),J.createElement(he,{spinning:me},J.createElement("div",{ref:M,style:v({position:"relative"},g)}))};var Te=be(ye,null,null,{context:xe})(Ae);export{Te as default};
1
+ import{useLatest as oe,useMemoizedFn as H}from"ahooks";import{Spin as he}from"antd/es";import J,{useContext as Ie,useRef as $,useState as S,useMemo as _e,useCallback as De,useEffect as p}from"react";import{connect as be}from"react-redux";import{usePointCloudViews as Ce}from"../pointCloudView/hooks/usePointCloudViews.js";import{PointCloudContext as we}from"../pointCloudView/PointCloudContext.js";import{a2MapStateToProps as ye}from"../../store/annotation/map.js";import{LabelBeeContext as xe}from"../../store/ctx.js";import{PointCloud2DRectOperation as Pe,MathUtils as Se,ImgUtils as Le}from"@labelbee/lb-annotation";import{selectSpecifiedRectsFromTopViewSelectedIds as Oe}from"./util.js";import{useUpdateRectList as Ve}from"./useUpdateRectList.js";import je from"lodash";import{useToolStyleContext as Ee}from"../../hooks/useToolStyle.js";import ke from"../../store/toolConfig/index.js";var Be=Object.defineProperty,Ne=Object.defineProperties,Ue=Object.getOwnPropertyDescriptors,ie=Object.getOwnPropertySymbols,Me=Object.prototype.hasOwnProperty,ze=Object.prototype.propertyIsEnumerable,le=(u,c,s)=>c in u?Be(u,c,{enumerable:!0,configurable:!0,writable:!0,value:s}):u[c]=s,v=(u,c)=>{for(var s in c||(c={}))Me.call(c,s)&&le(u,s,c[s]);if(ie)for(var s of ie(c))ze.call(c,s)&&le(u,s,c[s]);return u},C=(u,c)=>Ne(u,Ue(c)),G=(u,c,s)=>new Promise((a,g)=>{var D=f=>{try{b(s.next(f))}catch(R){g(R)}},L=f=>{try{b(s.throw(f))}catch(R){g(R)}},b=f=>f.done?a(f.value):Promise.resolve(f.value).then(D,L);b((s=s.apply(u,c)).next())});const Ae=u=>{var c,s;const{mappingData:a,size:g,config:D,checkMode:L,afterImgOnLoad:b,shouldExcludePointCloudBoxListUpdate:f}=u,{selectBoxVisibleSwitch:R}=ke(),O=(c=a==null?void 0:a.url)!=null?c:"",w=(s=a==null?void 0:a.fallbackUrl)!=null?s:"",{pointCloudBoxList:V,setPointCloudResult:j,defaultAttribute:E,rectList:k,addRectIn2DView:ce,updateRectIn2DView:se,removeRectIn2DView:ue,updateRectListByReducer:de,selectedIDs:m,setSelectedIDs:B,selectedID:N}=Ie(we),{value:U}=Ee(),ae=oe(m),{update2DViewRect:fe,remove2DViewRect:pe}=Ce(),M=J.useRef(null),o=$(null),K=H(fe),y=H(pe),x=$(null),[me,Q]=S(!0),[W,X]=S(""),[ve,z]=S(!1),[ge,A]=S(!0),h=_e(()=>k==null?void 0:k.filter(e=>e.imageName===(a==null?void 0:a.path)),[a==null?void 0:a.path,k]),Y=$(h),P=oe(a==null?void 0:a.path),T=De(e=>G(void 0,null,function*(){try{const n=ae.current.slice(0),r=yield Promise.resolve(e());if(!r||r.length===0)return r;if(n.length){const t=new Set(n),i=r.filter(l=>t.has(l.id)).map(l=>l.id);B(i)}return r}catch(n){}}),[B]),Z=e=>{const{boxID:n}=e;if(!f&&n){T(()=>{const r=K==null?void 0:K(e);return r?(x.current=r,j(r),r):null});return}se(e,!0)},ee=e=>{P.current&&ce(C(v({},e),{imageName:P.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?(x.current=t,j(t),I(),t):null});return}}const n=e.find(r=>r.extId);n&&T(()=>{const{imageName:r,extId:t}=n,i=y==null?void 0:y({boxID:t,imageName:r});return i?(x.current=i,j(i),i):null}),ue(e)},Re=H(()=>{let e=[];return V.forEach(n=>{const{rects:r=[],id:t,attribute:i,trackID:l}=n,d=r.find(F=>F.imageName===P.current),_=t+"_"+P.current;d&&(e=[...e,C(v({},d),{boxID:t,id:_,attribute:i,order:l})])}),e}),I=Ve(()=>{var e,n,r,t,i;const l=f?[]:Re(),d=(e=o.current)==null?void 0:e.selectedRectID,_=m.slice(0),F=R?Oe(_,l,h):[...l,...h];let ne=[];!R&&(m==null?void 0:m.length)&&(ne=l.filter(q=>d?m.includes(q.boxID)&&!d.includes(q.boxID):m.includes(q.boxID))),(n=o.current)==null||n.setHighLightRectList(ne),(r=o.current)==null||r.setResult(F),W?((t=o.current)==null||t.setSelectedRectID(W),X("")):ve&&d&&((i=o.current)==null||i.setSelectedRectID(d),z(!1))}),re=({targetId:e,id:n})=>{A(!1),B(e),X(n)};return p(()=>{if(M.current){const e=new Pe({container:M.current,size:g,config:C(v({},D),{isShowOrder:!0,attributeConfigurable:!0}),checkMode:L});return o.current=e,o.current.init(),o.current.on("updateDragResult",Z),o.current.on("afterAddingDrawingRect",ee),o.current.on("deleteSelectedRects",te),o.current.on("onRightClick",re),()=>{var n,r,t,i,l;(n=o.current)==null||n.unbind("updateDragResult",Z),(r=o.current)==null||r.unbind("afterAddingDrawingRect",ee),(t=o.current)==null||t.unbind("deleteSelectedRects",te),(i=o.current)==null||i.unbind("onRightClick",re),(l=o.current)==null||l.destroy()}}},[]),p(()=>{const e=r=>G(void 0,null,function*(){try{return yield Le.load(r)}catch(t){return console.error("Error loading image:",t),null}}),n=()=>G(void 0,null,function*(){var r;Q(!0);let t=yield e(O);!t&&w&&(t=yield e(w)),t&&((r=o.current)==null||r.setImgNode(t),b(t)),Q(!1)});o.current&&(O||w)&&n()},[O,w]),p(()=>{var e;(e=o.current)==null||e.setSize(g)},[g]),p(()=>{V!==x.current&&I()},[V]),p(()=>{var e,n;const r=h.find(t=>t.id===o.current.selectedRectID);(n=(e=o.current)==null?void 0:e.setDefaultAttribute)==null||n.call(e,E),r&&de(t=>{var i;const l=[];let d=null;return t.forEach(_=>{_.id!==o.current.selectedRectID?l.push(_):d=_}),r.extId===void 0&&(d=(i=o.current)==null?void 0:i.selectedRect),[...l,C(v({},d||{}),{attribute:E})]}),z(!0),I()},[E]),p(()=>{const e=Y.current;je.isEqual(e,h)||(z(!0),I(),Y.current=h)},[h]),p(()=>{I()},[f]),p(()=>{var e,n,r,t;const i=(n=(e=o.current)==null?void 0:e.config)!=null?n:{},l=C(v({},i),{attributeList:(r=D.attributeList)!=null?r:[]});(t=o.current)==null||t.setConfig(JSON.stringify(l))},[D.attributeList]),p(()=>{var e;(e=o.current)==null||e.setEnableAddRect(m.length===0),I()},[m]),p(()=>{if(!N||!ge){A(!0);return}const{rectList:e,size:n,zoom:r}=o.current,t=e.find(d=>d.boxID===N);if(!t){A(!0);return}const i={x:t.x+t.width/2,y:t.y+t.height/2},l=Se.getCurrentPosFromRectCenter(n,i,r);o.current.setCurrentPos(l),o.current.renderBasicCanvas(),o.current.render()},[N]),p(()=>{const{hiddenText:e}=U||{};if(e===void 0)return;const n=o.current;if(!n)return;const r=v(v({},n.style),U);n.setStyle(r)},[U]),p(()=>{I()},[R]),J.createElement(he,{spinning:me},J.createElement("div",{ref:M,style:v({position:"relative"},g)}))};var Te=be(ye,null,null,{context:xe})(Ae);export{Te as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@labelbee/lb-components",
3
- "version": "1.23.0-alpha.130",
3
+ "version": "1.23.0-alpha.132",
4
4
  "description": "Provide a complete library of annotation components",
5
5
  "main": "./dist/index.js",
6
6
  "es": "./es/index.js",