@labelbee/lb-components 1.23.0-alpha.8 → 1.23.0-alpha.9
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"),reactRedux=require("react-redux"),ctx=require("../../store/ctx.js"),index$3=require("../../constant/index.js"),index$2=require("./textContent/index.js"),index$1=require("../../views/MainView/annotationTips/index.js"),reducer=require("../../store/annotation/reducer.js"),index=require("../../utils/index.js"),data=require("../LLMToolView/utils/data.js"),annotation=require("../../hooks/annotation.js"),lbAnnotation=require("@labelbee/lb-annotation");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,n,
|
|
1
|
+
"use strict";var React=require("react"),reactRedux=require("react-redux"),ctx=require("../../store/ctx.js"),index$3=require("../../constant/index.js"),index$2=require("./textContent/index.js"),index$1=require("../../views/MainView/annotationTips/index.js"),reducer=require("../../store/annotation/reducer.js"),index=require("../../utils/index.js"),data=require("../LLMToolView/utils/data.js"),annotation=require("../../hooks/annotation.js"),lbAnnotation=require("@labelbee/lb-annotation");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,n,i)=>n in e?__defProp(e,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[n]=i,__spreadValues=(e,n)=>{for(var i in n||(n={}))__hasOwnProp.call(n,i)&&__defNormalProp(e,i,n[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(n))__propIsEnum.call(n,i)&&__defNormalProp(e,i,n[i]);return e},__spreadProps=(e,n)=>__defProps(e,__getOwnPropDescs(n));const NLPViewCls=`${index$3.prefix}-NLPView`,NLPToolView=e=>{const{annotation:n,checkMode:i,tips:q,showTips:T,extraLayer:V,extraData:E,onChangeAnnotation:h,customAnnotationData:M}=e,{imgIndex:c,imgList:p,stepList:g,step:b}=n,{highlightKey:$,setHighlightKey:I}=React.useContext(ctx.NLPContext),{toolInstanceRef:a}=annotation.useCustomToolInstance(),[L,k]=React.useState(""),[m,B]=React.useState([]),[A,K]=React.useState(void 0),[H,F]=React.useState([{content:""}]),[r,d]=React.useState({id:1,newText:"",indicatorDetermine:{},textAnnotation:[]}),z=React.useMemo(()=>(r==null?void 0:r.textAnnotation)?(A&&(r.textAnnotation=A),r.textAnnotation.filter(t=>m.length===0||m.includes(t.attribute))):[],[r,m,A]),l=React.useMemo(()=>{var t;if(g&&b){const o=(t=reducer.getStepConfig(g,b))==null?void 0:t.config;return index.jsonParser(o)}},[g,b]);React.useEffect(()=>{var t;if(!p[c])return;const o=(t=p[c])==null?void 0:t.textData;F(o),(l==null?void 0:l.attributeConfigurable)||x([])},[c,l]),React.useEffect(()=>{var t;if(!p[c])return;const o=(t=p[c])!=null?t:{},u=data.getCurrentResultFromResultList(o==null?void 0:o.result);d(u)},[c]),React.useEffect(()=>{a.current.exportData=()=>[[r],{}],a.current.setResult=()=>{},a.current.updateResult=t=>{d(t)},a.current.clearResult=Q,a.current.setDefaultAttribute=G,a.current.setHighlightKey=I,a.current.deleteTextAnnotation=U,a.current.setAttributeLockList=J,a.current.setVisibleResult=x,_()},[r]);const _=()=>{a.current.emit("changeAttributeSidebar"),a.current.emit("changeIndicatorDetermine")},G=t=>{a.current.defaultAttribute=t,k(t),_()},J=t=>{B(t)},x=t=>{K(t)},Q=()=>{d({id:1,newText:"",indicatorDetermine:{},textAnnotation:[]}),x([]),_()},U=t=>{const o=r.textAnnotation.filter(u=>u.id!==t);d(__spreadProps(__spreadValues({},r),{textAnnotation:o})),x(o)},W=(t,o)=>{var u,f;if(o===""||!t)return;const s=window.getSelection(),{anchorOffset:P=0,focusOffset:w=0,anchorNode:Y,focusNode:Z}=s||{};if(Y===Z){const S=Math.min(P,w),y=Math.max(P,w);let C;if((t==null?void 0:t.current)&&s){const v=(u=t.current)==null?void 0:u.getBoundingClientRect(),R=s.getRangeAt(0).getBoundingClientRect(),j=R.right-v.left,N=R.top-v.top;j&&N&&(C={left:j,top:N})}const D={id:lbAnnotation.uuid(8,62),start:S,end:y,text:o};if(typeof h=="function"){h(__spreadProps(__spreadValues({},D),{endPosition:C}));return}if(X(S,y,L,r==null?void 0:r.textAnnotation)||i)return;if(l==null?void 0:l.attributeConfigurable){const v=(r==null?void 0:r.textAnnotation)||[];v.push(__spreadProps(__spreadValues({},D),{attribute:L}));const O=__spreadProps(__spreadValues({},r),{textAnnotation:v});d(O)}(f=window.getSelection())==null||f.empty()}},X=(t,o,u,f)=>f==null?void 0:f.some(s=>(s==null?void 0:s.start)===t&&(s==null?void 0:s.end)===o&&(s==null?void 0:s.attribute)===u);return React__default.default.createElement("div",{className:NLPViewCls,id:"NLPView"},React__default.default.createElement("div",{className:`${NLPViewCls}-question`},T===!0&&React__default.default.createElement(index$1,{tips:q}),React__default.default.createElement(index$2,{highlightKey:$,textData:H,NLPConfig:l,textAnnotation:z,onSelectionChange:W,extraLayer:V,extraData:E,customAnnotationData:M})))},mapStateToProps=e=>({annotation:e.annotation});var NLPToolView$1=reactRedux.connect(mapStateToProps,null,null,{context:ctx.LabelBeeContext})(NLPToolView);module.exports=NLPToolView$1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import x,{useContext as ut,useState as m,useMemo as k,useEffect as C}from"react";import{connect as lt}from"react-redux";import{LabelBeeContext as dt,NLPContext as ft}from"../../store/ctx.js";import{prefix as pt}from"../../constant/index.js";import mt from"./textContent/index.js";import gt from"../../views/MainView/annotationTips/index.js";import{getStepConfig as vt}from"../../store/annotation/reducer.js";import{jsonParser as xt}from"../../utils/index.js";import{getCurrentResultFromResultList as bt}from"../LLMToolView/utils/data.js";import{useCustomToolInstance as At}from"../../hooks/annotation.js";import{uuid as _t}from"@labelbee/lb-annotation";var ht=Object.defineProperty,wt=Object.defineProperties,Pt=Object.getOwnPropertyDescriptors,B=Object.getOwnPropertySymbols,Lt=Object.prototype.hasOwnProperty,Ct=Object.prototype.propertyIsEnumerable,K=(r,e,i)=>e in r?ht(r,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):r[e]=i,b=(r,e)=>{for(var i in e||(e={}))Lt.call(e,i)&&K(r,i,e[i]);if(B)for(var i of B(e))Ct.call(e,i)&&K(r,i,e[i]);return r},A=(r,e)=>wt(r,Pt(e));const $=`${pt}-NLPView`,yt=r=>{const{annotation:e,checkMode:i,tips:H,showTips:q,extraLayer:F,extraData:Q,onChangeAnnotation:y,customAnnotationData:W}=r,{imgIndex:u,imgList:g,stepList:_,step:h}=e,{highlightKey:z,setHighlightKey:G}=ut(ft),{toolInstanceRef:s}=At(),[D,J]=m(""),[w,U]=m([]),[P,X]=m(void 0),[Y,Z]=m([{content:""}]),[n,d]=m({id:1,newText:"",indicatorDetermine:{},textAnnotation:[]}),tt=k(()=>(n==null?void 0:n.textAnnotation)?(P&&(n.textAnnotation=P),n.textAnnotation.filter(t=>w.length===0||w.includes(t.attribute))):[],[n,w,P]),l=k(()=>{var t;if(_&&h){const o=(t=vt(_,h))==null?void 0:t.config;return xt(o)}},[_,h]);C(()=>{var t;if(!g[u])return;const o=(t=g[u])==null?void 0:t.textData;Z(o),(l==null?void 0:l.attributeConfigurable)||v([])},[u,l]),C(()=>{var t;if(!g[u])return;const o=(t=g[u])!=null?t:{},c=bt(o==null?void 0:o.result);d(c)},[u]),C(()=>{s.current.exportData=()=>[[n],{}],s.current.setResult=()=>{},s.current.updateResult=t=>{d(t)},s.current.clearResult=ot,s.current.setDefaultAttribute=et,s.current.setHighlightKey=G,s.current.deleteTextAnnotation=rt,s.current.setAttributeLockList=nt,s.current.setVisibleResult=v,L()},[n]);const L=()=>{s.current.emit("changeAttributeSidebar"),s.current.emit("changeIndicatorDetermine")},et=t=>{s.current.defaultAttribute=t,J(t),L()},nt=t=>{U(t)},v=t=>{X(t)},ot=()=>{d({id:1,newText:"",indicatorDetermine:{},textAnnotation:[]}),v([]),L()},rt=t=>{const o=n.textAnnotation.filter(c=>c.id!==t);d(A(b({},n),{textAnnotation:o})),v(o)},it=(t,o)=>{var c,f;if(o===""||!t)return;const a=window.getSelection(),{anchorOffset:O=0,focusOffset:S=0,anchorNode:at,focusNode:ct}=a||{};if(at===ct){const j=Math.min(O,S),N=Math.max(O,S);let R;if((t==null?void 0:t.current)&&a){const p=(c=t.current)==null?void 0:c.getBoundingClientRect(),E=a.getRangeAt(0).getBoundingClientRect(),I=E.right-p.left,M=E.top-p.top;I&&M&&(R={left:I,top:M})}const T={id:_t(8,62),start:j,end:N,text:o};if(typeof y=="function"){y(A(b({},T),{endPosition:R}));return}if(st(j,N,D,n==null?void 0:n.textAnnotation)||i)return;if(l==null?void 0:l.attributeConfigurable){const p=(n==null?void 0:n.textAnnotation)||[];p.push(A(b({},T),{attribute:D}));const V=A(b({},n),{textAnnotation:p});d(V)}(f=window.getSelection())==null||f.empty()}},st=(t,o,c,f)=>f==null?void 0:f.some(a=>(a==null?void 0:a.start)===t&&(a==null?void 0:a.end)===o&&(a==null?void 0:a.attribute)===c);return x.createElement("div",{className:$,id:"NLPView"},x.createElement("div",{className:`${$}-question`},q===!0&&x.createElement(gt,{tips:H}),x.createElement(mt,{highlightKey:z,textData:Y,NLPConfig:l,textAnnotation:tt,onSelectionChange:it,extraLayer:F,extraData:Q,customAnnotationData:W})))},Dt=r=>({annotation:r.annotation});var Ot=lt(Dt,null,null,{context:dt})(yt);export{Ot as default};
|