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