@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,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:h,customAnnotationData:M}=e,{imgIndex:c,imgList:p,stepList:x,step:g}=n,{highlightKey:$,setHighlightKey:I}=React.useContext(ctx.NLPContext),{toolInstanceRef:i}=annotation.useCustomToolInstance(),[L,k]=React.useState(""),[b,B]=React.useState([]),[m,K]=React.useState(void 0),[H,F]=React.useState([{content:""}]),[a,d]=React.useState({id:1,newText:"",indicatorDetermine:{},textAnnotation:[]}),z=React.useMemo(()=>(a==null?void 0:a.textAnnotation)?(m&&(a.textAnnotation=m),a.textAnnotation.filter(t=>b.length===0||b.includes(t.attribute))):[],[a,b,m]),l=React.useMemo(()=>{var t;if(x&&g){const r=(t=reducer.getStepConfig(x,g))==null?void 0:t.config;return index.jsonParser(r)}},[x,g]);React.useEffect(()=>{var t;if(!p[c])return;const r=(t=p[c])==null?void 0:t.textData;F(r),(l==null?void 0:l.attributeConfigurable)||_([])},[c,l]),React.useEffect(()=>{var t;if(!p[c])return;const r=(t=p[c])!=null?t:{},u=data.getCurrentResultFromResultList(r==null?void 0:r.result);d(u)},[c]),React.useEffect(()=>{i.current.exportData=()=>[[a],{}],i.current.setResult=()=>{},i.current.updateResult=t=>{d(t)},i.current.clearResult=Q,i.current.setDefaultAttribute=G,i.current.setHighlightKey=I,i.current.deleteTextAnnotation=U,i.current.setAttributeLockList=J,i.current.setVisibleResult=_,A()},[a]);const A=()=>{i.current.emit("changeAttributeSidebar"),i.current.emit("changeIndicatorDetermine")},G=t=>{i.current.defaultAttribute=t,k(t),A()},J=t=>{B(t)},_=t=>{K(t)},Q=()=>{d({id:1,newText:"",indicatorDetermine:{},textAnnotation:[]}),_([]),A()},U=t=>{d(r=>__spreadProps(__spreadValues({},r),{textAnnotation:r.textAnnotation.filter(u=>u.id!==t)}))},W=(t,r)=>{var u,f;if(r===""||!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:r};if(typeof h=="function"){h(__spreadProps(__spreadValues({},D),{endPosition:C}));return}if(X(S,y,L,a==null?void 0:a.textAnnotation)||o)return;if(l==null?void 0:l.attributeConfigurable){const v=(a==null?void 0:a.textAnnotation)||[];v.push(__spreadProps(__spreadValues({},D),{attribute:L}));const O=__spreadProps(__spreadValues({},a),{textAnnotation:v});d(O)}(f=window.getSelection())==null||f.empty()}},X=(t,r,u,f)=>f==null?void 0:f.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: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
+ "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 v,{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=(o,e,r)=>e in o?ht(o,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[e]=r,x=(o,e)=>{for(var r in e||(e={}))Lt.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},b=(o,e)=>wt(o,Pt(e));const $=`${pt}-NLPView`,yt=o=>{const{annotation:e,checkMode:r,tips:H,showTips:q,extraLayer:F,extraData:Q,onChangeAnnotation:y,customAnnotationData:W}=o,{imgIndex:u,imgList:g,stepList:A,step:_}=e,{highlightKey:z,setHighlightKey:G}=ut(ft),{toolInstanceRef:i}=At(),[D,J]=m(""),[h,U]=m([]),[w,X]=m(void 0),[Y,Z]=m([{content:""}]),[s,d]=m({id:1,newText:"",indicatorDetermine:{},textAnnotation:[]}),tt=k(()=>(s==null?void 0:s.textAnnotation)?(w&&(s.textAnnotation=w),s.textAnnotation.filter(t=>h.length===0||h.includes(t.attribute))):[],[s,h,w]),l=k(()=>{var t;if(A&&_){const n=(t=vt(A,_))==null?void 0:t.config;return xt(n)}},[A,_]);C(()=>{var t;if(!g[u])return;const n=(t=g[u])==null?void 0:t.textData;Z(n),(l==null?void 0:l.attributeConfigurable)||L([])},[u,l]),C(()=>{var t;if(!g[u])return;const n=(t=g[u])!=null?t:{},c=bt(n==null?void 0:n.result);d(c)},[u]),C(()=>{i.current.exportData=()=>[[s],{}],i.current.setResult=()=>{},i.current.updateResult=t=>{d(t)},i.current.clearResult=ot,i.current.setDefaultAttribute=et,i.current.setHighlightKey=G,i.current.deleteTextAnnotation=rt,i.current.setAttributeLockList=nt,i.current.setVisibleResult=L,P()},[s]);const P=()=>{i.current.emit("changeAttributeSidebar"),i.current.emit("changeIndicatorDetermine")},et=t=>{i.current.defaultAttribute=t,J(t),P()},nt=t=>{U(t)},L=t=>{X(t)},ot=()=>{d({id:1,newText:"",indicatorDetermine:{},textAnnotation:[]}),L([]),P()},rt=t=>{d(n=>b(x({},n),{textAnnotation:n.textAnnotation.filter(c=>c.id!==t)}))},it=(t,n)=>{var c,f;if(n===""||!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:n};if(typeof y=="function"){y(b(x({},T),{endPosition:R}));return}if(st(j,N,D,s==null?void 0:s.textAnnotation)||r)return;if(l==null?void 0:l.attributeConfigurable){const p=(s==null?void 0:s.textAnnotation)||[];p.push(b(x({},T),{attribute:D}));const V=b(x({},s),{textAnnotation:p});d(V)}(f=window.getSelection())==null||f.empty()}},st=(t,n,c,f)=>f==null?void 0:f.some(a=>(a==null?void 0:a.start)===t&&(a==null?void 0:a.end)===n&&(a==null?void 0:a.attribute)===c);return v.createElement("div",{className:$,id:"NLPView"},v.createElement("div",{className:`${$}-question`},q===!0&&v.createElement(gt,{tips:H}),v.createElement(mt,{highlightKey:z,textData:Y,NLPConfig:l,textAnnotation:tt,onSelectionChange:it,extraLayer:F,extraData:Q,customAnnotationData:W})))},Dt=o=>({annotation:o.annotation});var Ot=lt(Dt,null,null,{context:dt})(yt);export{Ot as default};
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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@labelbee/lb-components",
3
- "version": "1.23.0-alpha.8",
3
+ "version": "1.23.0-alpha.9",
4
4
  "description": "Provide a complete library of annotation components",
5
5
  "main": "./dist/index.js",
6
6
  "es": "./es/index.js",