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