@labelbee/lb-components 1.23.0-alpha.20 → 1.23.0-alpha.21
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.
- package/dist/App.js +1 -1
- package/dist/assets/annotation/pointCloudTool/leftArrow.svg.js +1 -1
- package/dist/assets/annotation/pointCloudTool/rightArrow.svg.js +1 -1
- package/dist/components/videoAnnotate/videoClipTool/index.js +1 -1
- package/dist/components/videoAnnotate/videoTagTool/TagToolInstanceAdaptor.js +1 -1
- package/dist/types/App.d.ts +1 -0
- package/dist/types/components/videoAnnotate/index.d.ts +1 -0
- package/dist/types/components/videoAnnotate/videoClipTool/index.d.ts +1 -0
- package/dist/types/components/videoAnnotate/videoTagTool/TagToolInstanceAdaptor.d.ts +1 -1
- package/dist/views/MainView/index.js +1 -1
- package/dist/views/MainView/sidebar/TagSidebar/index.js +1 -1
- package/dist/views/MainView/sidebar/TextToolSidebar/index.js +1 -1
- package/es/App.js +1 -1
- package/es/assets/annotation/pointCloudTool/leftArrow.svg.js +1 -1
- package/es/assets/annotation/pointCloudTool/rightArrow.svg.js +1 -1
- package/es/components/videoAnnotate/videoClipTool/index.js +1 -1
- package/es/components/videoAnnotate/videoTagTool/TagToolInstanceAdaptor.js +1 -1
- package/es/views/MainView/index.js +1 -1
- package/es/views/MainView/sidebar/TagSidebar/index.js +1 -1
- package/es/views/MainView/sidebar/TextToolSidebar/index.js +1 -1
- package/package.json +1 -1
package/dist/App.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var index$1=require("./views/MainView/index.js"),lbUtils=require("@labelbee/lb-utils"),React=require("react"),reactRedux=require("react-redux"),index=require("./index.js"),ctx=require("./store/ctx.js"),Actions=require("./store/Actions.js"),actionCreators=require("./store/annotation/actionCreators.js"),reducer=require("./store/annotation/reducer.js"),es=require("antd/es"),zhCN=require("antd/es/locale/zh_CN"),enUS=require("antd/es/locale/en_US");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),zhCN__default=_interopDefaultLegacy(zhCN),enUS__default=_interopDefaultLegacy(enUS),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,a)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,__spreadValues=(e,t)=>{for(var a in t||(t={}))__hasOwnProp.call(t,a)&&__defNormalProp(e,a,t[a]);if(__getOwnPropSymbols)for(var a of __getOwnPropSymbols(t))__propIsEnum.call(t,a)&&__defNormalProp(e,a,t[a]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t));const App=e=>{const[t,a]=React.useState(0),{imgList:o,step:i=1,stepList:s,onSubmit:l,onSave:c,onPageChange:u,onStepChange:d,initialIndex:p=0,toolInstance:P,setToolInstance:S,getFileData:f,pageSize:g=10,loadFileList:r,defaultLang:_="cn",skipBeforePageTurning:m,beforeRotate:v,checkMode:O=!1,intelligentFit:A=!0,highlightAttribute:h="",preDataProcess:I,getImgIndexByExternal:x}=e;React.useEffect(()=>{index.store.dispatch(actionCreators.InitTaskData({onSubmit:l,stepList:s,step:i,getFileData:f,pageSize:g,loadFileList:r,onSave:c,onPageChange:u,onStepChange:d,skipBeforePageTurning:m,beforeRotate:v,checkMode:O,highlightAttribute:h,preDataProcess:I,getImgIndexByExternal:x})),
|
|
1
|
+
"use strict";var index$1=require("./views/MainView/index.js"),lbUtils=require("@labelbee/lb-utils"),React=require("react"),reactRedux=require("react-redux"),index=require("./index.js"),ctx=require("./store/ctx.js"),Actions=require("./store/Actions.js"),actionCreators=require("./store/annotation/actionCreators.js"),reducer=require("./store/annotation/reducer.js"),es=require("antd/es"),zhCN=require("antd/es/locale/zh_CN"),enUS=require("antd/es/locale/en_US");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),zhCN__default=_interopDefaultLegacy(zhCN),enUS__default=_interopDefaultLegacy(enUS),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,a)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,__spreadValues=(e,t)=>{for(var a in t||(t={}))__hasOwnProp.call(t,a)&&__defNormalProp(e,a,t[a]);if(__getOwnPropSymbols)for(var a of __getOwnPropSymbols(t))__propIsEnum.call(t,a)&&__defNormalProp(e,a,t[a]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t));const App=e=>{const[t,a]=React.useState(0),{imgList:o,step:i=1,stepList:s,onSubmit:l,onSave:c,onPageChange:u,onStepChange:d,initialIndex:p=0,toolInstance:P,setToolInstance:S,getFileData:f,pageSize:g=10,loadFileList:r,defaultLang:_="cn",skipBeforePageTurning:m,beforeRotate:v,checkMode:O=!1,intelligentFit:A=!0,highlightAttribute:h="",preDataProcess:I,getImgIndexByExternal:x,annotationBefore:y}=e;React.useEffect(()=>{index.store.dispatch(actionCreators.InitTaskData({onSubmit:l,stepList:s,step:i,getFileData:f,pageSize:g,loadFileList:r,onSave:c,onPageChange:u,onStepChange:d,skipBeforePageTurning:m,beforeRotate:v,checkMode:O,highlightAttribute:h,preDataProcess:I,getImgIndexByExternal:x,annotationBefore:y})),C(),lbUtils.i18n.changeLanguage(_);const n=()=>{a(L=>L+1)};return lbUtils.i18n.on("languageChanged",n),()=>{lbUtils.i18n.off("languageChanged",n),actionCreators.InitAnnotationState(index.store.dispatch)}},[]),React.useEffect(()=>{index.store.dispatch(actionCreators.UpdateInjectFunc({onSubmit:l,stepList:s,getFileData:f,pageSize:g,loadFileList:r,onSave:c,onPageChange:u,onStepChange:d,beforeRotate:v,highlightAttribute:h,preDataProcess:I})),lbUtils.i18n.changeLanguage(_)},[l,s,f,g,r,c,u,d,_,v,h,I]),React.useEffect(()=>{S==null||S(P)},[P]),React.useEffect(()=>{index.store.dispatch({type:Actions.ANNOTATION_ACTIONS.SET_STEP,payload:{toStep:i}})},[i]);const C=()=>{r?actionCreators.loadImgList(index.store.dispatch,index.store.getState,p,!0).then(n=>{n&&index.store.dispatch(reducer.LoadFileAndFileData(p))}):o&&o.length>0&&(index.store.dispatch({type:Actions.ANNOTATION_ACTIONS.UPDATE_IMG_LIST,payload:{imgList:o}}),index.store.dispatch(reducer.LoadFileAndFileData(p)))};return React__default.default.createElement("div",null,React__default.default.createElement(es.ConfigProvider,{locale:lbUtils.i18n.language==="en"?enUS__default.default:zhCN__default.default},React__default.default.createElement(index$1,__spreadProps(__spreadValues({},e),{intelligentFit:A,checkMode:O}))))},mapStateToProps=e=>({toolInstance:e.annotation.toolInstance});var App$1=reactRedux.connect(mapStateToProps,null,null,{context:ctx.LabelBeeContext})(App);module.exports=App$1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react");function _interopNamespace(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if(r!=="default"){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,Object.freeze(t)}var React__namespace=_interopNamespace(React),_path;function _extends(){return _extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},_extends.apply(this,arguments)}var SvgLeftArrow=function(t){return React__namespace.createElement("svg",_extends({xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react");function _interopNamespace(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if(r!=="default"){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,Object.freeze(t)}var React__namespace=_interopNamespace(React),_path;function _extends(){return _extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},_extends.apply(this,arguments)}var SvgLeftArrow=function(t){return React__namespace.createElement("svg",_extends({xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"currentColor","aria-hidden":"true","data-icon":"left",viewBox:"64 64 896 896"},t),_path||(_path=React__namespace.createElement("path",{d:"M724 218.3V141c0-6.7-7.7-10.4-12.9-6.3L260.3 486.8a31.86 31.86 0 0 0 0 50.3l450.8 352.1c5.3 4.1 12.9.4 12.9-6.3v-77.3c0-4.9-2.3-9.6-6.1-12.6l-360-281 360-281.1c3.8-3 6.1-7.7 6.1-12.6"})))};exports.ReactComponent=SvgLeftArrow;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react");function _interopNamespace(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if(r!=="default"){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,Object.freeze(t)}var React__namespace=_interopNamespace(React),_path;function _extends(){return _extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},_extends.apply(this,arguments)}var SvgRightArrow=function(t){return React__namespace.createElement("svg",_extends({xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react");function _interopNamespace(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if(r!=="default"){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,Object.freeze(t)}var React__namespace=_interopNamespace(React),_path;function _extends(){return _extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},_extends.apply(this,arguments)}var SvgRightArrow=function(t){return React__namespace.createElement("svg",_extends({xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"currentColor","aria-hidden":"true","data-icon":"right",viewBox:"64 64 896 896"},t),_path||(_path=React__namespace.createElement("path",{d:"M765.7 486.8 314.9 134.7A7.97 7.97 0 0 0 302 141v77.3c0 4.9 2.3 9.6 6.1 12.6l360 281.1-360 281.1c-3.9 3-6.1 7.7-6.1 12.6V883c0 6.7 7.7 10.4 12.9 6.3l450.8-352.1a31.96 31.96 0 0 0 0-50.4"})))};exports.ReactComponent=SvgRightArrow;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var lbAnnotation=require("@labelbee/lb-annotation"),index$2=require("../../../utils/index.js"),audio=require("../../../utils/audio.js"),antd=require("antd"),_=require("lodash"),React=require("react"),index_module=require("./index.module.scss.js"),VideoClipToolContext=require("./VideoClipToolContext.js"),constant=require("./constant.js"),index=require("../../videoPlayer/index.js"),index$1=require("./components/videoTimeSlicesOverVideo/index.js"),icon_videoCutting=require("../../../assets/annotation/video/icon_videoCutting.svg.js"),utils=require("../../videoPlayer/utils.js");function _interopDefaultLegacy(S){return S&&typeof S=="object"&&"default"in S?S:{default:S}}var ___default=_interopDefaultLegacy(_),React__default=_interopDefaultLegacy(React);class VideoClipTool extends React__default.default.Component{constructor(r){super(r);this.fns=new Map,this.throttledUpdateTime=___default.default.throttle(t=>{this.videoPlayer.currentTime=t},100,{trailing:!0}),this.stepInfo=()=>this.props.stepInfo,this.emitEvent=t=>{const e=this.fns.get(t);e&&e.forEach(i=>{i&&i()})},this.setValid=t=>{this.setState({valid:t}),t===!1&&(this.clearResult(),this.updateSidebar())},this.updateSidebar=()=>{this.emitEvent("changeClipSidebar"),this.emitEvent("updateTextAttribute"),this.emitEvent("changeAttributeSidebar")},this.exportData=()=>{var t,e;const i=(e=(t=this.videoRef)==null?void 0:t.duration)!=null?e:0;return[this.state.result.filter(s=>s.end!==null),{valid:this.state.valid,duration:i}]},this.updateSelectedSliceTimeStartByPer=t=>{var e,i;if(this.state.clipStatus===constant.EClipStatus.Clipping){antd.message.info("\u622A\u53D6\u4E2D\u4E0D\u652F\u6301\u8C03\u6574\u5F00\u59CB\u65F6\u95F4");return}if(this.selectedSliceIndex>-1){const s=(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0,{end:a,start:n,type:l}=this.state.result[this.selectedSliceIndex],u=lbAnnotation.MathUtils.withinRange(audio.precisionAdd(n,t),[0,audio.precisionMinus(l===constant.ETimeSliceType.Time?s:a,constant.PER_SLICE_CHANGE)]);this.updateSelectedSliceTimeProperty(u,"start")}},this.updateSelectedSliceTimeEndByPer=t=>{var e,i;if(this.state.clipStatus===constant.EClipStatus.Clipping){antd.message.info("\u622A\u53D6\u4E2D\u4E0D\u652F\u6301\u8C03\u6574\u7ED3\u675F\u65F6\u95F4");return}if(this.selectedSliceIndex>-1){const s=this.state.result[this.selectedSliceIndex],a=(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0;if(s.type===constant.ETimeSliceType.Time){antd.message.info("\u65F6\u95F4\u70B9\u4EC5\u652F\u6301\u8C03\u6574\u5F00\u59CB\u65F6\u95F4");return}const{end:n,start:l}=s,u=lbAnnotation.MathUtils.withinRange(audio.precisionAdd(n,t),[audio.precisionAdd(l,constant.PER_SLICE_CHANGE),a]);this.updateSelectedSliceTimeProperty(u,"end")}},this.updateSelectedSliceTimeProperty=(t,e)=>{if(this.selectedSliceIndex>-1){const{result:i}=this.state;i[this.selectedSliceIndex][e]=t,this.setState({result:___default.default.cloneDeep(i)}),this.updateSidebar()}},this.keyDownEvents=t=>{if(!lbAnnotation.CommonToolUtils.hotkeyFilter(t))return;const e=t.target;switch(e&&(e==null?void 0:e.tag)==="INPUT"&&(e==null?void 0:e.type)==="radio"&&t.preventDefault(),t.key.toLocaleLowerCase()){case"x":this.toggleClipStatus();break;case"e":this.addTime();break;case"escape":this.cancelClipped();break;case"-":this.updateSelectedSliceTimeStartByPer(-constant.PER_SLICE_CHANGE);break;case"=":this.updateSelectedSliceTimeStartByPer(constant.PER_SLICE_CHANGE);break;case"[":this.updateSelectedSliceTimeEndByPer(-constant.PER_SLICE_CHANGE);break;case"]":this.updateSelectedSliceTimeEndByPer(constant.PER_SLICE_CHANGE);break}},this.setVideoError=(t,e,i)=>{if(t){const{clipStatus:s}=this.state;s===constant.EClipStatus.Clipping&&this.toggleClipStatus(i)}this.setState({videoError:t,loading:!1})},this.clearResult=()=>{this.setState({result:[],selectedID:"",textValue:""}),this.updateSidebar()},this.cancelClipped=()=>{const{result:t,selectedID:e,clipStatus:i}=this.state;if(i!==constant.EClipStatus.Clipping)return;const s=t.findIndex(a=>a.id===e);s>-1&&(t.splice(s,1),this.setState({result:t,selectedID:"",clipStatus:constant.EClipStatus.Stop}),this.updateSidebar())},this.toggleClipStatus=t=>{var e,i,s;if(this.disabled)return;const{clipStatus:a,selectedAttribute:n}=this.state,l=a!==constant.EClipStatus.Clipping;let u=l?constant.EClipStatus.Clipping:constant.EClipStatus.Stop,{result:d,selectedID:o,textValue:p}=this.state;const c=___default.default.cloneDeep(d),h=t||((e=this.videoPlayer)==null?void 0:e.currentTime),f=(i=this.videoPlayer)==null?void 0:i.duration;if(f===void 0||h===void 0)return;const C=utils.decimalReserved(h,2);if(l){const m=lbAnnotation.uuid();o=m,c.push({start:C,end:null,attribute:n,textAttribute:this.defaultTextAttribute,duration:f,id:m,type:constant.ETimeSliceType.Period}),p=this.defaultTextAttribute}else{const m=c.findIndex(v=>v.id===o),g=c[m];g&&(h-g.start<constant.SLICE_MIN_TIME?(c.splice(m,1),antd.message.info(`\u622A\u53D6\u7247\u6BB5\u4E0D\u80FD\u77ED\u4E8E${constant.SLICE_MIN_TIME}s`),u=constant.EClipStatus.Stop,o="",p=""):(c[m].end=utils.decimalReserved(h,2),(s=this.videoPlayer)==null||s.pause(),antd.message.success(`\u5DF2\u622A\u53D6\u7247\u6BB5${d.length}`)))}this.setState({clipStatus:u,result:c,selectedID:o,textValue:p}),this.updateSidebar()},this.addTime=()=>{var t,e,i,s;if(this.disabled)return;const{result:a,selectedAttribute:n,selectedID:l}=this.state,u=lbAnnotation.uuid(),d=___default.default.cloneDeep(a),o=((t=this.videoPlayer)==null?void 0:t.currentTime)||0;d.push({start:o,end:o,attribute:n,textAttribute:this.defaultTextAttribute,id:u,type:constant.ETimeSliceType.Time,duration:(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0});const p={result:d,selectedID:u,textValue:this.defaultTextAttribute},c=d.find(h=>h.id===l);this.isClipping&&c?(delete p.selectedID,delete p.textValue,antd.message.success(`\u5DF2\u622A\u53D6\u65F6\u95F4\u70B9${d.length-1}`)):(s=this.videoPlayer)==null||s.pause(),this.setState(p),this.updateSidebar()},this.updateCurrentTime=t=>{this.setState({currentTime:t})},this.contextToCancel=t=>{this.state.clipStatus===constant.EClipStatus.Stop&&(t.preventDefault(),this.setState({selectedID:""}),this.updateSidebar())},this.onTrackResize=(t,e,i)=>{var s,a;const{result:n}=this.state,l=n.find(u=>u.id===t);if(l){const u=l.duration,d=e==="left",o=d?"start":"end",p=d?-u*i:u*i,c=d?[0,Math.max(((s=l.end)!=null?s:0)-constant.SLICE_MIN_TIME,0)]:[l.start+constant.SLICE_MIN_TIME,u],h=lbAnnotation.MathUtils.withinRange(p+((a=l==null?void 0:l[o])!=null?a:0),c);l[o]=h,this.throttledUpdateTime(h)}this.setState({result:[...n]}),this.updateSidebar()},this.renderMediaContent=()=>{var t;const{pageForward:e,pageJump:i,pageBackward:s}=this.props,{result:a,videoError:n,valid:l,currentTime:u}=this.state;return React__default.default.createElement("div",{className:index_module.clipContainer},React__default.default.createElement(index.VideoPlayer,{imgIndex:this.props.imgIndex,imgList:this.props.imgList,pageBackward:s,pageForward:e,pageJump:i,valid:l,setVideoRef:d=>{this.videoPlayer=d},showVideoTrack:!n,onTrackResize:this.onTrackResize,drawLayerSlot:this.props.drawLayerSlot,footer:this.props.footer,dataLoaded:this.props.onVideoLoaded,toggleClipStatus:this.toggleClipStatus,addTime:this.addTime,updateCurrentTime:this.updateCurrentTime}),React__default.default.createElement(index$1,{key:(t=this.videoPlayer)==null?void 0:t.currentTime,result:a,currentTime:u,attributeList:this.props.config.attributeList,extraStyle:{top:this.props.drawLayerSlot?40:0}}),this.isClipping&&React__default.default.createElement("i",{className:index_module.clipping,style:{backgroundImage:icon_videoCutting}}))},this.onSelectedTimeSlice=t=>{var e;this.isClipping||(this.setState({selectedID:t.id,selectedAttribute:t.attribute,textValue:t.textAttribute,currentTime:t.start}),this.updateSidebar(),(e=this.videoPlayer)==null||e.pause(),this.videoPlayer.currentTime=t.start)},this.removeTimeSlice=t=>{const{result:e}=this.state,i=this.state.selectedID===t.id?"":this.state.selectedID,s=e.findIndex(a=>a.id===t.id);s>-1&&(e.splice(s,1),this.setState({result:[...e],selectedID:i}),this.updateSidebar())},this.setResult=(t=!0,e=this.props)=>{try{const{imgIndex:i,imgList:s}=e;if(!s[i])return;const n=index$2.jsonParser(s[i].result)[`step_${this.stepInfo().step}`],l=(n==null?void 0:n.result)||[],u=audio.isImageValue(s[i].result||"[]");this.setState({result:l,loading:t,selectedID:"",textValue:"",selectedAttribute:"",clipStatus:constant.EClipStatus.Stop,valid:u},()=>{this.updateSidebar(),u||antd.message.info("\u65E0\u6548\u89C6\u9891\uFF0C\u8BF7\u8DF3\u8FC7")})}catch(i){console.error("\u6570\u636E\u89E3\u6790\u5931\u8D25"),this.setState({result:[],loading:!1,selectedID:"",textValue:"",selectedAttribute:"",valid:!0},()=>{this.updateSidebar()})}},this.setDefaultAttribute=t=>{const{result:e,selectedID:i}=this.state,s=e.find(a=>a.id===i);s&&i&&(s.attribute=t),this.setState({selectedAttribute:t,result:[...e]}),this.updateSidebar()},this.textChange=t=>{const{result:e,selectedID:i}=this.state;if(this.setState({textValue:t}),i){const s=e.find(a=>a.id===i);s&&(s.textAttribute=t,this.setState({result:[...e]}),this.updateSidebar())}},this.state={result:[],selectedAttribute:"",textValue:"",clipStatus:constant.EClipStatus.Stop,selectedID:"",loading:!1,videoError:!1,remainingTime:0,currentTime:0,configLoading:!1,valid:!0}}get videoUrl(){var r;const{imgIndex:t,imgList:e}=this.props;return((r=e[t])==null?void 0:r.url)||""}get isClipping(){return this.state.clipStatus===constant.EClipStatus.Clipping}get resultJSON(){const{imgIndex:r,imgList:t}=this.props;return t.length===0||!t[r]?"[]":t[r].result}get disabled(){return!this.state.valid||this.state.videoError}get loading(){return this.state.loading||this.state.configLoading}get defaultTextAttribute(){return lbAnnotation.AttributeUtils.getTextAttribute(this.state.result,this.props.config.textCheckType)}get defaultAttribute(){return this.state.selectedAttribute}get selectedID(){return this.state.selectedID}get selectedSliceIndex(){return this.state.result.findIndex(r=>r.id===this.state.selectedID)}get exportContext(){return{selectedID:this.state.selectedID,result:this.state.result,clipStatus:this.state.clipStatus,videoPlayer:this.videoPlayer,attributeList:this.props.config.attributeList,onSelectedTimeSlice:this.onSelectedTimeSlice,removeTimeSlice:this.removeTimeSlice,updateSelectedSliceTimeProperty:this.updateSelectedSliceTimeProperty}}get valid(){return this.state.valid}get config(){var r;return index$2.jsonParser((r=this.props.stepInfo)==null?void 0:r.config)}get selectedText(){var r,t;return(t=(r=this.state.result)==null?void 0:r[this.selectedSliceIndex])==null?void 0:t.textAttribute}componentDidMount(){this.setState({loading:!1}),this.setResult(!1),this.props.onMounted(this),window.addEventListener("keydown",this.keyDownEvents)}componentWillUnmount(){this.props.onUnmounted(),window.removeEventListener("keydown",this.keyDownEvents)}shouldComponentUpdate(r,t){const e=r.imgIndex-this.props.imgIndex,i=r.step-this.props.step;return(e!==0||i!==0)&&(this.setResult(!0,r),i!==0&&this.setState({loading:!1})),!0}singleOn(r,t){this.fns.set(r,[t])}on(r,t){this.singleOn(r,t)}unbindAll(r){this.fns.delete(r)}render(){const{selectedID:r,result:t,clipStatus:e,selectedAttribute:i}=this.state;return React__default.default.createElement(VideoClipToolContext.VideoClipToolContextProvider,{value:{videoPlayer:this.videoPlayer,result:t,selectedID:r,attributeList:this.props.config.attributeList,clipStatus:e,selectedAttribute:i,contextToCancel:this.contextToCancel}},this.renderMediaContent())}}module.exports=VideoClipTool;
|
|
1
|
+
"use strict";var lbAnnotation=require("@labelbee/lb-annotation"),index$2=require("../../../utils/index.js"),audio=require("../../../utils/audio.js"),antd=require("antd"),_=require("lodash"),React=require("react"),index_module=require("./index.module.scss.js"),VideoClipToolContext=require("./VideoClipToolContext.js"),constant=require("./constant.js"),index=require("../../videoPlayer/index.js"),index$1=require("./components/videoTimeSlicesOverVideo/index.js"),icon_videoCutting=require("../../../assets/annotation/video/icon_videoCutting.svg.js"),utils=require("../../videoPlayer/utils.js");function _interopDefaultLegacy(S){return S&&typeof S=="object"&&"default"in S?S:{default:S}}var ___default=_interopDefaultLegacy(_),React__default=_interopDefaultLegacy(React);class VideoClipTool extends React__default.default.Component{constructor(r){super(r);this.fns=new Map,this.throttledUpdateTime=___default.default.throttle(t=>{this.videoPlayer.currentTime=t},100,{trailing:!0}),this.stepInfo=()=>this.props.stepInfo,this.emitEvent=t=>{const e=this.fns.get(t);e&&e.forEach(i=>{i&&i()})},this.setValid=t=>{this.setState({valid:t}),t===!1&&(this.clearResult(),this.updateSidebar())},this.updateSidebar=()=>{this.emitEvent("changeClipSidebar"),this.emitEvent("updateTextAttribute"),this.emitEvent("changeAttributeSidebar")},this.exportData=()=>{var t,e;const i=(e=(t=this.videoRef)==null?void 0:t.duration)!=null?e:0;return[this.state.result.filter(s=>s.end!==null),{valid:this.state.valid,duration:i}]},this.updateSelectedSliceTimeStartByPer=t=>{var e,i;if(this.state.clipStatus===constant.EClipStatus.Clipping){antd.message.info("\u622A\u53D6\u4E2D\u4E0D\u652F\u6301\u8C03\u6574\u5F00\u59CB\u65F6\u95F4");return}if(this.selectedSliceIndex>-1){const s=(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0,{end:a,start:n,type:l}=this.state.result[this.selectedSliceIndex],u=lbAnnotation.MathUtils.withinRange(audio.precisionAdd(n,t),[0,audio.precisionMinus(l===constant.ETimeSliceType.Time?s:a,constant.PER_SLICE_CHANGE)]);this.updateSelectedSliceTimeProperty(u,"start")}},this.updateSelectedSliceTimeEndByPer=t=>{var e,i;if(this.state.clipStatus===constant.EClipStatus.Clipping){antd.message.info("\u622A\u53D6\u4E2D\u4E0D\u652F\u6301\u8C03\u6574\u7ED3\u675F\u65F6\u95F4");return}if(this.selectedSliceIndex>-1){const s=this.state.result[this.selectedSliceIndex],a=(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0;if(s.type===constant.ETimeSliceType.Time){antd.message.info("\u65F6\u95F4\u70B9\u4EC5\u652F\u6301\u8C03\u6574\u5F00\u59CB\u65F6\u95F4");return}const{end:n,start:l}=s,u=lbAnnotation.MathUtils.withinRange(audio.precisionAdd(n,t),[audio.precisionAdd(l,constant.PER_SLICE_CHANGE),a]);this.updateSelectedSliceTimeProperty(u,"end")}},this.updateSelectedSliceTimeProperty=(t,e)=>{if(this.selectedSliceIndex>-1){const{result:i}=this.state;i[this.selectedSliceIndex][e]=t,this.setState({result:___default.default.cloneDeep(i)}),this.updateSidebar()}},this.keyDownEvents=t=>{if(!lbAnnotation.CommonToolUtils.hotkeyFilter(t))return;const e=t.target;switch(e&&(e==null?void 0:e.tag)==="INPUT"&&(e==null?void 0:e.type)==="radio"&&t.preventDefault(),t.key.toLocaleLowerCase()){case"x":this.toggleClipStatus();break;case"e":this.addTime();break;case"escape":this.cancelClipped();break;case"-":this.updateSelectedSliceTimeStartByPer(-constant.PER_SLICE_CHANGE);break;case"=":this.updateSelectedSliceTimeStartByPer(constant.PER_SLICE_CHANGE);break;case"[":this.updateSelectedSliceTimeEndByPer(-constant.PER_SLICE_CHANGE);break;case"]":this.updateSelectedSliceTimeEndByPer(constant.PER_SLICE_CHANGE);break}},this.setVideoError=(t,e,i)=>{if(t){const{clipStatus:s}=this.state;s===constant.EClipStatus.Clipping&&this.toggleClipStatus(i)}this.setState({videoError:t,loading:!1})},this.clearResult=()=>{this.setState({result:[],selectedID:"",textValue:""}),this.updateSidebar()},this.cancelClipped=()=>{const{result:t,selectedID:e,clipStatus:i}=this.state;if(i!==constant.EClipStatus.Clipping)return;const s=t.findIndex(a=>a.id===e);s>-1&&(t.splice(s,1),this.setState({result:t,selectedID:"",clipStatus:constant.EClipStatus.Stop}),this.updateSidebar())},this.toggleClipStatus=t=>{var e,i;if(typeof((e=this.props)==null?void 0:e.annotationBefore)=="function"){(i=this.props)==null||i.annotationBefore(()=>this.setClipResult(t));return}this.setClipResult(t)},this.setClipResult=t=>{var e,i,s;if(this.disabled)return;const{clipStatus:a,selectedAttribute:n}=this.state,l=a!==constant.EClipStatus.Clipping;let u=l?constant.EClipStatus.Clipping:constant.EClipStatus.Stop,{result:d,selectedID:o,textValue:p}=this.state;const c=___default.default.cloneDeep(d),h=t||((e=this.videoPlayer)==null?void 0:e.currentTime),v=(i=this.videoPlayer)==null?void 0:i.duration;if(v===void 0||h===void 0)return;const C=utils.decimalReserved(h,2);if(l){const f=lbAnnotation.uuid();o=f,c.push({start:C,end:null,attribute:n,textAttribute:this.defaultTextAttribute,duration:v,id:f,type:constant.ETimeSliceType.Period}),p=this.defaultTextAttribute}else{const f=c.findIndex(g=>g.id===o),m=c[f];m&&(h-m.start<constant.SLICE_MIN_TIME?(c.splice(f,1),antd.message.info(`\u622A\u53D6\u7247\u6BB5\u4E0D\u80FD\u77ED\u4E8E${constant.SLICE_MIN_TIME}s`),u=constant.EClipStatus.Stop,o="",p=""):(c[f].end=utils.decimalReserved(h,2),(s=this.videoPlayer)==null||s.pause(),antd.message.success(`\u5DF2\u622A\u53D6\u7247\u6BB5${d.length}`)))}this.setState({clipStatus:u,result:c,selectedID:o,textValue:p}),this.updateSidebar()},this.addTime=()=>{var t,e,i,s;if(this.disabled)return;const{result:a,selectedAttribute:n,selectedID:l}=this.state,u=lbAnnotation.uuid(),d=___default.default.cloneDeep(a),o=((t=this.videoPlayer)==null?void 0:t.currentTime)||0;d.push({start:o,end:o,attribute:n,textAttribute:this.defaultTextAttribute,id:u,type:constant.ETimeSliceType.Time,duration:(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0});const p={result:d,selectedID:u,textValue:this.defaultTextAttribute},c=d.find(h=>h.id===l);this.isClipping&&c?(delete p.selectedID,delete p.textValue,antd.message.success(`\u5DF2\u622A\u53D6\u65F6\u95F4\u70B9${d.length-1}`)):(s=this.videoPlayer)==null||s.pause(),this.setState(p),this.updateSidebar()},this.updateCurrentTime=t=>{this.setState({currentTime:t})},this.contextToCancel=t=>{this.state.clipStatus===constant.EClipStatus.Stop&&(t.preventDefault(),this.setState({selectedID:""}),this.updateSidebar())},this.onTrackResize=(t,e,i)=>{var s,a;const{result:n}=this.state,l=n.find(u=>u.id===t);if(l){const u=l.duration,d=e==="left",o=d?"start":"end",p=d?-u*i:u*i,c=d?[0,Math.max(((s=l.end)!=null?s:0)-constant.SLICE_MIN_TIME,0)]:[l.start+constant.SLICE_MIN_TIME,u],h=lbAnnotation.MathUtils.withinRange(p+((a=l==null?void 0:l[o])!=null?a:0),c);l[o]=h,this.throttledUpdateTime(h)}this.setState({result:[...n]}),this.updateSidebar()},this.renderMediaContent=()=>{var t;const{pageForward:e,pageJump:i,pageBackward:s}=this.props,{result:a,videoError:n,valid:l,currentTime:u}=this.state;return React__default.default.createElement("div",{className:index_module.clipContainer},React__default.default.createElement(index.VideoPlayer,{imgIndex:this.props.imgIndex,imgList:this.props.imgList,pageBackward:s,pageForward:e,pageJump:i,valid:l,setVideoRef:d=>{this.videoPlayer=d},showVideoTrack:!n,onTrackResize:this.onTrackResize,drawLayerSlot:this.props.drawLayerSlot,footer:this.props.footer,dataLoaded:this.props.onVideoLoaded,toggleClipStatus:this.toggleClipStatus,addTime:this.addTime,updateCurrentTime:this.updateCurrentTime}),React__default.default.createElement(index$1,{key:(t=this.videoPlayer)==null?void 0:t.currentTime,result:a,currentTime:u,attributeList:this.props.config.attributeList,extraStyle:{top:this.props.drawLayerSlot?40:0}}),this.isClipping&&React__default.default.createElement("i",{className:index_module.clipping,style:{backgroundImage:icon_videoCutting}}))},this.onSelectedTimeSlice=t=>{var e;this.isClipping||(this.setState({selectedID:t.id,selectedAttribute:t.attribute,textValue:t.textAttribute,currentTime:t.start}),this.updateSidebar(),(e=this.videoPlayer)==null||e.pause(),this.videoPlayer.currentTime=t.start)},this.removeTimeSlice=t=>{const{result:e}=this.state,i=this.state.selectedID===t.id?"":this.state.selectedID,s=e.findIndex(a=>a.id===t.id);s>-1&&(e.splice(s,1),this.setState({result:[...e],selectedID:i}),this.updateSidebar())},this.setResult=(t=!0,e=this.props)=>{try{const{imgIndex:i,imgList:s}=e;if(!s[i])return;const n=index$2.jsonParser(s[i].result)[`step_${this.stepInfo().step}`],l=(n==null?void 0:n.result)||[],u=audio.isImageValue(s[i].result||"[]");this.setState({result:l,loading:t,selectedID:"",textValue:"",selectedAttribute:"",clipStatus:constant.EClipStatus.Stop,valid:u},()=>{this.updateSidebar(),u||antd.message.info("\u65E0\u6548\u89C6\u9891\uFF0C\u8BF7\u8DF3\u8FC7")})}catch(i){console.error("\u6570\u636E\u89E3\u6790\u5931\u8D25"),this.setState({result:[],loading:!1,selectedID:"",textValue:"",selectedAttribute:"",valid:!0},()=>{this.updateSidebar()})}},this.setDefaultAttribute=t=>{const{result:e,selectedID:i}=this.state,s=e.find(a=>a.id===i);s&&i&&(s.attribute=t),this.setState({selectedAttribute:t,result:[...e]}),this.updateSidebar()},this.textChange=t=>{const{result:e,selectedID:i}=this.state;if(this.setState({textValue:t}),i){const s=e.find(a=>a.id===i);s&&(s.textAttribute=t,this.setState({result:[...e]}),this.updateSidebar())}},this.state={result:[],selectedAttribute:"",textValue:"",clipStatus:constant.EClipStatus.Stop,selectedID:"",loading:!1,videoError:!1,remainingTime:0,currentTime:0,configLoading:!1,valid:!0}}get videoUrl(){var r;const{imgIndex:t,imgList:e}=this.props;return((r=e[t])==null?void 0:r.url)||""}get isClipping(){return this.state.clipStatus===constant.EClipStatus.Clipping}get resultJSON(){const{imgIndex:r,imgList:t}=this.props;return t.length===0||!t[r]?"[]":t[r].result}get disabled(){return!this.state.valid||this.state.videoError}get loading(){return this.state.loading||this.state.configLoading}get defaultTextAttribute(){return lbAnnotation.AttributeUtils.getTextAttribute(this.state.result,this.props.config.textCheckType)}get defaultAttribute(){return this.state.selectedAttribute}get selectedID(){return this.state.selectedID}get selectedSliceIndex(){return this.state.result.findIndex(r=>r.id===this.state.selectedID)}get exportContext(){return{selectedID:this.state.selectedID,result:this.state.result,clipStatus:this.state.clipStatus,videoPlayer:this.videoPlayer,attributeList:this.props.config.attributeList,onSelectedTimeSlice:this.onSelectedTimeSlice,removeTimeSlice:this.removeTimeSlice,updateSelectedSliceTimeProperty:this.updateSelectedSliceTimeProperty}}get valid(){return this.state.valid}get config(){var r;return index$2.jsonParser((r=this.props.stepInfo)==null?void 0:r.config)}get selectedText(){var r,t;return(t=(r=this.state.result)==null?void 0:r[this.selectedSliceIndex])==null?void 0:t.textAttribute}componentDidMount(){this.setState({loading:!1}),this.setResult(!1),this.props.onMounted(this),window.addEventListener("keydown",this.keyDownEvents)}componentWillUnmount(){this.props.onUnmounted(),window.removeEventListener("keydown",this.keyDownEvents)}shouldComponentUpdate(r,t){const e=r.imgIndex-this.props.imgIndex,i=r.step-this.props.step;return(e!==0||i!==0)&&(this.setResult(!0,r),i!==0&&this.setState({loading:!1})),!0}singleOn(r,t){this.fns.set(r,[t])}on(r,t){this.singleOn(r,t)}unbindAll(r){this.fns.delete(r)}render(){const{selectedID:r,result:t,clipStatus:e,selectedAttribute:i}=this.state;return React__default.default.createElement(VideoClipToolContext.VideoClipToolContextProvider,{value:{videoPlayer:this.videoPlayer,result:t,selectedID:r,attributeList:this.props.config.attributeList,clipStatus:e,selectedAttribute:i,contextToCancel:this.contextToCancel}},this.renderMediaContent())}}module.exports=VideoClipTool;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),lbAnnotation=require("@labelbee/lb-annotation"),index=require("../../../utils/index.js"),index$1=require("../../videoPlayer/index.js"),VideoTagLayer=require("../../videoPlayer/VideoTagLayer.js"),_=require("lodash"),utils=require("../../videoPlayer/utils.js");function _interopDefaultLegacy(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),lbAnnotation=require("@labelbee/lb-annotation"),index=require("../../../utils/index.js"),index$1=require("../../videoPlayer/index.js"),VideoTagLayer=require("../../videoPlayer/VideoTagLayer.js"),_=require("lodash"),utils=require("../../videoPlayer/utils.js");function _interopDefaultLegacy(h){return h&&typeof h=="object"&&"default"in h?h:{default:h}}var React__default=_interopDefaultLegacy(React),___default=_interopDefaultLegacy(_);class TagToolInstanceAdaptor extends React__default.default.Component{constructor(e){super(e);this.fns={},this.labelSelectedList=[],this.clearResult=(t=!0,s)=>{const n=s?this.state.tagResult.map(i=>((i==null?void 0:i.result[s])&&delete i.result[s],i)):[];this.setState({tagResult:n},()=>this.emitEvent("render"))},this.exportData=()=>{var t,s;const n=(s=(t=this.videoPlayer)==null?void 0:t.duration)!=null?s:0;return[this.state.tagResult,{valid:this.state.valid,duration:n}]},this.emitEvent=t=>{this.fns[t]&&this.fns[t]()},this.combineResult=(t,s={})=>{var n,i;const l=_.cloneDeep(s),{isMulti:o}=t,{key:a,value:u}=t.value;if(o){let r=(i=(n=l[a])==null?void 0:n.split(";"))!=null?i:[];r.includes(u)?r=r.filter(c=>c!==u):r.push(u);const d=new Set(r);return l[a]=Array.from(d).join(";"),___default.default.pickBy(l,c=>c)}return l[a]=l[a]===u?void 0:u,___default.default.pickBy(l,r=>r)},this.setResult=t=>{this.setState({tagResult:t}),this.fns.render&&this.fns.render()},this.setLabel=(t,s)=>{this.setLabelBySelectedList(t,s)},this.keydown=t=>{var s;const n=utils.getKeyCodeNumber(t.keyCode);if(n){const i=n-1;if(((s=this.config.inputList)==null?void 0:s.length)===1){this.labelSelectedList=[0,i],this.setLabel(0,i),setTimeout(()=>{this.labelSelectedList=[],this.emitEvent("render")},500);return}this.labelSelectedList.length===1?(this.labelSelectedList=[this.labelSelectedList[0],i],this.setLabel(this.labelSelectedList[0],i),setTimeout(()=>{this.labelSelectedList=[],this.emitEvent("render")},500)):(this.labelSelectedList=[i],this.emitEvent("expend"))}},this.setValid=t=>{this.setState({valid:t}),t===!1&&this.setState({tagResult:[]}),this.emitEvent("render")},this.setResultFromImgList=t=>{const{imgList:s,imgIndex:n,stepInfo:i}=t;if(!s[n])return;const l=index.jsonParser(s[n].result),o=l[`step_${i.step}`],a=this.getInitResultList();this.setState({tagResult:o?o==null?void 0:o.result:a,valid:(l==null?void 0:l.valid)===void 0?!0:l.valid},()=>this.emitEvent("render"))},this.getInitResultList=()=>{var t;return lbAnnotation.TagUtils.getDefaultTagResult((t=this.config.inputList)!=null?t:[],[])},this.state={tagResult:[],labelSelectedList:[],valid:!0}}get config(){var e;return index.jsonParser((e=this.props.stepInfo)==null?void 0:e.config)}get history(){return{initRecord:()=>{},pushHistory:()=>{}}}get currentTagResult(){var e;return(e=this.state.tagResult[0])!=null?e:{}}get valid(){return this.state.valid}singleOn(e,t){this.fns[e]=t}on(e,t){this.singleOn(e,t)}unbindAll(e){delete this.fns[e]}getTagResultByCode(e,t){var s,n,i;try{const l=(n=(s=this.config)==null?void 0:s.inputList)!=null?n:[],o=(l==null?void 0:l.length)>1,a=t!==void 0?e:0,u=t!==void 0?t:e,r=o?l[a]:l[0],d=((i=r.subSelected)!=null?i:[])[u];if(r&&d)return{value:{key:r.value,value:d.value},isMulti:r.isMulti}}catch(l){return}}setLabelBySelectedList(e,t){var s,n,i,l,o,a;const u=this.getTagResultByCode(e,t);if(u){const r=this.combineResult(u,(n=(s=this.state.tagResult[0])==null?void 0:s.result)!=null?n:{}),d=[{sourceID:lbAnnotation.CommonToolUtils.getSourceID(),id:(l=(i=this.currentTagResult)==null?void 0:i.id)!=null?l:lbAnnotation.uuid(8,62),result:r}];if(typeof((o=this.props)==null?void 0:o.annotationBefore)=="function"){(a=this.props)==null||a.annotationBefore(()=>this.setState({tagResult:d},()=>this.emitEvent("render")));return}this.setState({tagResult:d},()=>this.emitEvent("render"))}}componentDidMount(){document.addEventListener("keydown",this.keydown),this.props.onMounted(this),this.setResultFromImgList(this.props)}componentWillUnmount(){document.addEventListener("keydown",this.keydown),this.props.onUnmounted()}shouldComponentUpdate(e){return e.imgIndex!==this.props.imgIndex&&this.setResultFromImgList(e),!0}render(){var e;const{imgIndex:t,imgList:s,pageForward:n,pageJump:i,pageBackward:l}=this.props,{tagResult:o,valid:a}=this.state;return React__default.default.createElement("div",{style:{height:"100%",width:"100%",position:"relative",display:"flex",flexDirection:"column"}},React__default.default.createElement(index$1.VideoPlayer,{imgIndex:t,imgList:s,pageBackward:l,pageForward:n,pageJump:i,valid:a,setVideoRef:u=>{this.videoPlayer=u},dataLoaded:this.props.onVideoLoaded,drawLayerSlot:this.props.drawLayerSlot,footer:this.props.footer}),React__default.default.createElement(VideoTagLayer.VideoTagLayer,{result:o,inputList:(e=this.config)==null?void 0:e.inputList,hasPromptLayer:!!this.props.drawLayerSlot}))}}exports.TagToolInstanceAdaptor=TagToolInstanceAdaptor;
|
package/dist/types/App.d.ts
CHANGED
|
@@ -78,6 +78,7 @@ export interface AppProps {
|
|
|
78
78
|
preDataProcess?: (params: IPreDataProcessParams) => IPointCloudBox[];
|
|
79
79
|
auditContext?: any;
|
|
80
80
|
getImgIndexByExternal: GetImgIndexByExternal;
|
|
81
|
+
annotationBefore?: (setAnnotationData: Function) => void;
|
|
81
82
|
}
|
|
82
83
|
declare const _default: import("react-redux").ConnectedComponent<React.FC<AppProps>, import("react-redux").Omit<AppProps & {
|
|
83
84
|
children?: React.ReactNode;
|
|
@@ -20,6 +20,7 @@ export interface IVideoAnnotateProps {
|
|
|
20
20
|
drawLayerSlot?: DrawLayerSlot;
|
|
21
21
|
footer?: any;
|
|
22
22
|
skipBeforePageTurning?: (pageTurning: Function) => void;
|
|
23
|
+
annotationBefore?: (setAnnotationData: Function) => void;
|
|
23
24
|
}
|
|
24
25
|
declare const _default: import("react-redux").ConnectedComponent<React.FC<IVideoAnnotateProps>, import("react-redux").Omit<IVideoAnnotateProps & {
|
|
25
26
|
children?: React.ReactNode;
|
|
@@ -65,7 +65,7 @@ export declare class TagToolInstanceAdaptor extends React.Component<IVideoTagIns
|
|
|
65
65
|
value: string;
|
|
66
66
|
};
|
|
67
67
|
isMulti: boolean;
|
|
68
|
-
},
|
|
68
|
+
}, existData?: ObjectString) => _.Dictionary<string | undefined>;
|
|
69
69
|
setResult: (tagResult: any[]) => void;
|
|
70
70
|
setLabel: (num1: number, num2: number) => void;
|
|
71
71
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var index$7=require("../../components/customResizeHook/index.js"),index$5=require("../../constant/index.js"),antd=require("antd"),es=require("antd/es"),React=require("react"),index$b=require("./annotationOperation/index.js"),index$a=require("./annotationTips/index.js"),index$4=require("./sidebar/index.js"),index$c=require("./toolFooter/index.js"),index$9=require("./toolHeader/index.js"),reducer=require("../../store/annotation/reducer.js"),index$6=require("../../components/videoAnnotate/index.js"),reactRedux=require("react-redux"),ToolUtils=require("../../utils/ToolUtils.js"),index$d=require("../../components/pointCloudView/index.js"),dom=require("../../utils/dom.js"),index$8=require("../../utils/index.js"),index$3=require("../../components/predictTracking/previewResult/index.js"),ctx=require("../../store/ctx.js"),ToolType=require("../../data/enums/ToolType.js"),index=require("./LLMLayout/index.js"),index$1=require("./NLPLayout/index.js"),index$2=require("../../components/audioAnnotate/index.js"),icons=require("@ant-design/icons"),reactI18next=require("react-i18next"),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,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,a)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,__spreadValues=(e,t)=>{for(var a in t||(t={}))__hasOwnProp.call(t,a)&&__defNormalProp(e,a,t[a]);if(__getOwnPropSymbols)for(var a of __getOwnPropSymbols(t))__propIsEnum.call(t,a)&&__defNormalProp(e,a,t[a]);return e};const{Sider,Content}=es.Layout,layoutCls=`${index$5.prefix}-layout`,ImageAnnotate=e=>{var t;return React__default.default.createElement(React__default.default.Fragment,null,e.showTips===!0&&React__default.default.createElement(index$a,{path:e.path,tips:e.tips}),React__default.default.createElement(index$b,__spreadValues({},e)),React__default.default.createElement(index$c.default,{style:(t=e.style)==null?void 0:t.footer,mode:e.mode,footer:e==null?void 0:e.footer}))},PointCloudAnnotate=e=>{var t;return React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(index$d,{drawLayerSlot:e.drawLayerSlot,checkMode:e.checkMode,intelligentFit:e.intelligentFit,measureVisible:e.measureVisible}),React__default.default.createElement(index$c.default,{style:(t=e.style)==null?void 0:t.footer,mode:e.mode,footer:e==null?void 0:e.footer}))},AnnotatedArea=e=>{var t;const{stepList:a,step:l}=e,r=(t=reducer.getStepConfig(a,l))==null?void 0:t.tool,i=ToolUtils.isPointCloudTool(r),n=ToolUtils.isVideoTool(r);return i?React__default.default.createElement(PointCloudAnnotate,__spreadValues({},e)):n?React__default.default.createElement(index$6,{drawLayerSlot:e.drawLayerSlot,footer:e.footer}):React__default.default.createElement(ImageAnnotate,__spreadValues({},e))},ViewportProviderLayout=e=>{var t,a,l;const{t:r}=reactI18next.useTranslation(),{stepList:i,step:n}=e,o=(t=reducer.getStepConfig(i,n))==null?void 0:t.tool,d=![ToolType.EToolName.LLM,ToolType.EToolName.NLP].includes(o),u=![ToolType.EToolName.LLM,ToolType.EToolName.NLP].includes(o),c=[lbAnnotation.EPointCloudName.PointCloud].includes(o);return React__default.default.createElement(index$7.ViewportProvider,null,React__default.default.createElement(antd.Spin,{spinning:e.loading,indicator:React__default.default.createElement(icons.LoadingOutlined,null),tip:React__default.default.createElement("span",{style:{marginTop:200}},r("LoadingTips")),delay:500},React__default.default.createElement(es.Layout,{className:index$8.classnames([layoutCls,e.className]),style:(a=e.style)==null?void 0:a.layout},React__default.default.createElement("header",{className:`${layoutCls}__header`,style:(l=e.style)==null?void 0:l.header},React__default.default.createElement(index$9,{header:e==null?void 0:e.header,headerName:e.headerName,goBack:e.goBack,exportData:e.exportData,hasLangNode:d,hasHeaderOption:u,hasPredictTrackingIcon:c})),e.children)))},MainView=e=>{var t,a,l,r,i,n,o;const[d,u]=React.useState(void 0),c=(a=(t=e.style)==null?void 0:t.sider)==null?void 0:a.width,{stepList:m,step:f}=e,s=(l=reducer.getStepConfig(m,f))==null?void 0:l.tool,v=ToolType.EToolName.LLM===s,x=ToolType.EToolName.NLP===s,E=ToolUtils.isAudioTool(s);return v?React__default.default.createElement(ViewportProviderLayout,__spreadValues({},e),React__default.default.createElement(index,__spreadValues({},e))):x?React__default.default.createElement(ViewportProviderLayout,__spreadValues({},e),React__default.default.createElement(index$1,__spreadValues({},e))):E?React__default.default.createElement(ViewportProviderLayout,__spreadValues({},e),React__default.default.createElement(index$2,__spreadValues({},e))):React__default.default.createElement(ViewportProviderLayout,__spreadValues({},e),React__default.default.createElement(es.Layout,{className:dom.getClassName("layout","container")},e==null?void 0:e.leftSider,React__default.default.createElement(Content,{className:`${layoutCls}__content`},React__default.default.createElement(AnnotatedArea,__spreadValues({},e)),React__default.default.createElement(index$3,null)),React__default.default.createElement(Sider,{className:`${layoutCls}__side`,width:(r=d!=null?d:c)!=null?r:240,style:(i=e.style)==null?void 0:i.sider},React__default.default.createElement(index$4.default,{sider:e==null?void 0:e.sider,enableColorPicker:e==null?void 0:e.enableColorPicker,setSiderWidth:u,propsSiderWidth:(o=(n=e.style)==null?void 0:n.sider)==null?void 0:o.width}))))},mapStateToProps=({annotation:e})=>{var t,a,l;const{imgList:r,loading:i}=e,n=(t=r[e.imgIndex])!=null?t:{};return{path:(l=(a=n==null?void 0:n.path)!=null?a:n==null?void 0:n.url)!=null?l:"",loading:i}};var MainView$1=reactRedux.connect(mapStateToProps,null,null,{context:ctx.LabelBeeContext})(MainView);module.exports=MainView$1;
|
|
1
|
+
"use strict";var index$7=require("../../components/customResizeHook/index.js"),index$5=require("../../constant/index.js"),antd=require("antd"),es=require("antd/es"),React=require("react"),index$b=require("./annotationOperation/index.js"),index$a=require("./annotationTips/index.js"),index$4=require("./sidebar/index.js"),index$c=require("./toolFooter/index.js"),index$9=require("./toolHeader/index.js"),reducer=require("../../store/annotation/reducer.js"),index$6=require("../../components/videoAnnotate/index.js"),reactRedux=require("react-redux"),ToolUtils=require("../../utils/ToolUtils.js"),index$d=require("../../components/pointCloudView/index.js"),dom=require("../../utils/dom.js"),index$8=require("../../utils/index.js"),index$3=require("../../components/predictTracking/previewResult/index.js"),ctx=require("../../store/ctx.js"),ToolType=require("../../data/enums/ToolType.js"),index=require("./LLMLayout/index.js"),index$1=require("./NLPLayout/index.js"),index$2=require("../../components/audioAnnotate/index.js"),icons=require("@ant-design/icons"),reactI18next=require("react-i18next"),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,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,a)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,__spreadValues=(e,t)=>{for(var a in t||(t={}))__hasOwnProp.call(t,a)&&__defNormalProp(e,a,t[a]);if(__getOwnPropSymbols)for(var a of __getOwnPropSymbols(t))__propIsEnum.call(t,a)&&__defNormalProp(e,a,t[a]);return e};const{Sider,Content}=es.Layout,layoutCls=`${index$5.prefix}-layout`,ImageAnnotate=e=>{var t;return React__default.default.createElement(React__default.default.Fragment,null,e.showTips===!0&&React__default.default.createElement(index$a,{path:e.path,tips:e.tips}),React__default.default.createElement(index$b,__spreadValues({},e)),React__default.default.createElement(index$c.default,{style:(t=e.style)==null?void 0:t.footer,mode:e.mode,footer:e==null?void 0:e.footer}))},PointCloudAnnotate=e=>{var t;return React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(index$d,{drawLayerSlot:e.drawLayerSlot,checkMode:e.checkMode,intelligentFit:e.intelligentFit,measureVisible:e.measureVisible}),React__default.default.createElement(index$c.default,{style:(t=e.style)==null?void 0:t.footer,mode:e.mode,footer:e==null?void 0:e.footer}))},AnnotatedArea=e=>{var t;const{stepList:a,step:l}=e,r=(t=reducer.getStepConfig(a,l))==null?void 0:t.tool,i=ToolUtils.isPointCloudTool(r),n=ToolUtils.isVideoTool(r);return i?React__default.default.createElement(PointCloudAnnotate,__spreadValues({},e)):n?React__default.default.createElement(index$6,{drawLayerSlot:e.drawLayerSlot,footer:e.footer,annotationBefore:e==null?void 0:e.annotationBefore}):React__default.default.createElement(ImageAnnotate,__spreadValues({},e))},ViewportProviderLayout=e=>{var t,a,l;const{t:r}=reactI18next.useTranslation(),{stepList:i,step:n}=e,o=(t=reducer.getStepConfig(i,n))==null?void 0:t.tool,d=![ToolType.EToolName.LLM,ToolType.EToolName.NLP].includes(o),u=![ToolType.EToolName.LLM,ToolType.EToolName.NLP].includes(o),c=[lbAnnotation.EPointCloudName.PointCloud].includes(o);return React__default.default.createElement(index$7.ViewportProvider,null,React__default.default.createElement(antd.Spin,{spinning:e.loading,indicator:React__default.default.createElement(icons.LoadingOutlined,null),tip:React__default.default.createElement("span",{style:{marginTop:200}},r("LoadingTips")),delay:500},React__default.default.createElement(es.Layout,{className:index$8.classnames([layoutCls,e.className]),style:(a=e.style)==null?void 0:a.layout},React__default.default.createElement("header",{className:`${layoutCls}__header`,style:(l=e.style)==null?void 0:l.header},React__default.default.createElement(index$9,{header:e==null?void 0:e.header,headerName:e.headerName,goBack:e.goBack,exportData:e.exportData,hasLangNode:d,hasHeaderOption:u,hasPredictTrackingIcon:c})),e.children)))},MainView=e=>{var t,a,l,r,i,n,o;const[d,u]=React.useState(void 0),c=(a=(t=e.style)==null?void 0:t.sider)==null?void 0:a.width,{stepList:m,step:f}=e,s=(l=reducer.getStepConfig(m,f))==null?void 0:l.tool,v=ToolType.EToolName.LLM===s,x=ToolType.EToolName.NLP===s,E=ToolUtils.isAudioTool(s);return v?React__default.default.createElement(ViewportProviderLayout,__spreadValues({},e),React__default.default.createElement(index,__spreadValues({},e))):x?React__default.default.createElement(ViewportProviderLayout,__spreadValues({},e),React__default.default.createElement(index$1,__spreadValues({},e))):E?React__default.default.createElement(ViewportProviderLayout,__spreadValues({},e),React__default.default.createElement(index$2,__spreadValues({},e))):React__default.default.createElement(ViewportProviderLayout,__spreadValues({},e),React__default.default.createElement(es.Layout,{className:dom.getClassName("layout","container")},e==null?void 0:e.leftSider,React__default.default.createElement(Content,{className:`${layoutCls}__content`},React__default.default.createElement(AnnotatedArea,__spreadValues({},e)),React__default.default.createElement(index$3,null)),React__default.default.createElement(Sider,{className:`${layoutCls}__side`,width:(r=d!=null?d:c)!=null?r:240,style:(i=e.style)==null?void 0:i.sider},React__default.default.createElement(index$4.default,{sider:e==null?void 0:e.sider,enableColorPicker:e==null?void 0:e.enableColorPicker,setSiderWidth:u,propsSiderWidth:(o=(n=e.style)==null?void 0:n.sider)==null?void 0:o.width}))))},mapStateToProps=({annotation:e})=>{var t,a,l;const{imgList:r,loading:i}=e,n=(t=r[e.imgIndex])!=null?t:{};return{path:(l=(a=n==null?void 0:n.path)!=null?a:n==null?void 0:n.url)!=null?l:"",loading:i}};var MainView$1=reactRedux.connect(mapStateToProps,null,null,{context:ctx.LabelBeeContext})(MainView);module.exports=MainView$1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var index$1=require("../../../../components/attributeList/index.js"),index=require("../../../../components/checkboxList/index.js"),icons=require("@ant-design/icons"),es=require("antd/es"),_=require("lodash"),React=require("react"),icon_clearSmall=require("../../../../assets/annotation/common/icon_clearSmall.svg.js"),icon_clearSmall_a=require("../../../../assets/annotation/common/icon_clearSmall_a.svg.js"),lbAnnotation=require("@labelbee/lb-annotation"),reactRedux=require("react-redux"),reactI18next=require("react-i18next"),ctx=require("../../../../store/ctx.js");function _interopDefaultLegacy(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var index$1=require("../../../../components/attributeList/index.js"),index=require("../../../../components/checkboxList/index.js"),icons=require("@ant-design/icons"),es=require("antd/es"),_=require("lodash"),React=require("react"),icon_clearSmall=require("../../../../assets/annotation/common/icon_clearSmall.svg.js"),icon_clearSmall_a=require("../../../../assets/annotation/common/icon_clearSmall_a.svg.js"),lbAnnotation=require("@labelbee/lb-annotation"),reactRedux=require("react-redux"),reactI18next=require("react-i18next"),ctx=require("../../../../store/ctx.js");function _interopDefaultLegacy(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var React__default=_interopDefaultLegacy(React);const{Panel}=es.Collapse,expandIconFuc=({isActive:t})=>React__default.default.createElement(icons.CaretRightOutlined,{rotate:t?90:0}),TagSidebar=({toolInstance:t,imgIndex:C})=>{const[u,v]=React.useState([]),s=React.useRef(null),[,q]=React.useState(0),[R,f]=React.useState(-1),{t:m}=reactI18next.useTranslation();React.useEffect(()=>{var r,a;t&&(v((a=(r=t.config)==null?void 0:r.inputList)==null?void 0:a.map(e=>e.value)),t.singleOn("render",()=>{q(e=>e+1)}))},[t]),React.useEffect(()=>{var r;if(t&&(t.singleOn("expend",T),((r=t==null?void 0:t.labelSelectedList)==null?void 0:r.length)===1)){let a=0;for(let e=0;e<t.labelSelectedList[0];e++)a+=46,n[e]&&u[e]!==""&&n[e].subSelected.forEach(l=>{a+=40});s.current&&(s.current.children[0].scrollTop=a)}}),React.useEffect(()=>{s.current&&(s.current.children[0].scrollTop=0)},[C]);const T=()=>{var r;const a=t.labelSelectedList[0],e=(r=n.filter((l,o)=>o===a)[0])==null?void 0:r.value;p(a,e,!0)},p=React.useCallback((r,a,e)=>{const l=_.cloneDeep(u);l[r]===""||e===!0?l[r]=a:l[r]="",v(l)},[u]);if(!t)return null;const{labelSelectedList:c,config:{inputList:n},currentTagResult:i,setLabel:g}=t,j=r=>c.length>0&&c[0]===r?React__default.default.createElement("span",{className:"keyDownIconActive"},r+1):React__default.default.createElement("span",{className:"keyDownIcon"},r+1),b=(r,a=-1)=>r?r.map((e,l)=>{var o,y,E,h,L;if(e.subSelected){const k=lbAnnotation.TagUtils.judgeResultIsInInputList(e.value,(o=i==null?void 0:i.result)==null?void 0:o[e.value],n);return React__default.default.createElement(es.Collapse,{bordered:!1,expandIcon:expandIconFuc,key:`collapse_${l}_${a+1}`,onChange:()=>p(l,e.value),activeKey:[u[l]]},React__default.default.createElement(Panel,{header:React__default.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",flex:1}},React__default.default.createElement("span",null,e.key,React__default.default.createElement(es.Tooltip,{placement:"bottom",title:m("ClearThisOption")},React__default.default.createElement("img",{style:{marginLeft:5,cursor:"pointer"},onClick:N=>{N.stopPropagation(),t.clearResult(!0,e.value)},src:R===l||k?icon_clearSmall_a:icon_clearSmall,onMouseEnter:()=>{f(l)},onMouseLeave:()=>{f(-1)}})),k&&u[l]===""&&React__default.default.createElement(es.Badge,{color:"#87d068"})),(n==null?void 0:n.length)>1&&j(l)),key:e.value},React__default.default.createElement("div",{className:"level",style:{backgroundColor:c.length>0&&c[0]===l?"rgba(158, 158, 158, 0.18)":""}},b(e.subSelected,l))))}const d=(n==null?void 0:n[a])?n==null?void 0:n[a].value:0,S=((h=(E=(y=i==null?void 0:i.result)==null?void 0:y[d])==null?void 0:E.split(";"))==null?void 0:h.indexOf(e.value))>-1?e.value:"";return((L=n==null?void 0:n[a])==null?void 0:L.isMulti)===!0?React__default.default.createElement("div",{className:"singleBar",key:`${d}_${a}_${l}`},React__default.default.createElement(index,{attributeChanged:()=>g(a,l),selectedAttribute:[S],list:[{value:e.value,label:e.key}],num:l+1})):React__default.default.createElement("div",{className:"singleBar",key:`${d}_${a}_${l}`},React__default.default.createElement(index$1.default,{forbidColor:!0,attributeChanged:()=>g(a,l),selectedAttribute:S,list:[{value:e.value,label:e.key}],num:l+1}))}):null,x=window.innerHeight-61-80;return React__default.default.createElement("div",{className:"tagOperationMenu",ref:s},(n==null?void 0:n.length)===0?React__default.default.createElement("div",{style:{padding:20,textAlign:"center"}},m("NoConfiguration")):React__default.default.createElement("div",{className:"main",style:{height:x}},b(n)))};function mapStateToProps(t){return{toolInstance:t.annotation.toolInstance,imgIndex:t.annotation.imgIndex}}var TagSidebar$1=reactRedux.connect(mapStateToProps,null,null,{context:ctx.LabelBeeContext})(TagSidebar);exports.default=TagSidebar$1,exports.expandIconFuc=expandIconFuc;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),reactRedux=require("react-redux"),_=require("lodash"),index=require("../../../../utils/index.js"),es=require("antd/es"),lbAnnotation=require("@labelbee/lb-annotation"),actionCreators=require("../../../../store/annotation/actionCreators.js"),ConfigUtils=require("../../../../utils/ConfigUtils.js"),reactI18next=require("react-i18next"),ctx=require("../../../../store/ctx.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,r)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,__spreadValues=(e,t)=>{for(var r in t||(t={}))__hasOwnProp.call(t,r)&&__defNormalProp(e,r,t[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(t))__propIsEnum.call(t,r)&&__defNormalProp(e,r,t[r]);return e};const EKeyCode=lbAnnotation.cKeyCode.default,{EVideoToolName}=lbAnnotation.cTool,syntheticEventStopPagination=e=>{e.stopPropagation(),e.nativeEvent.stopPropagation(),e.nativeEvent.stopImmediatePropagation()},TextareaWithFooter=e=>{const{textareaProps:t,footer:r}=e;return React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(es.Input.TextArea,__spreadValues({key:`${t.id}-${t.defaultValue}`,bordered:!1,rows:6,onKeyDown:syntheticEventStopPagination,onKeyUp:syntheticEventStopPagination},t)),React__default.default.createElement("div",{className:index.classnames({textAreaLength:!0})},r))},SingleTextInput=e=>{var t;const r=React.useRef(null),[m,c]=React.useState(!1),[S,w]=React.useState(!1),{t:T}=reactI18next.useTranslation(),{disabled:s,config:l,result:d,updateText:f,index:u,switchToNextTextarea:E,hasMultiple:C,onNext:h}=e,{maxLength:v}=l,i=d?d[l.key]:"",[y,b]=React.useState((t=i==null?void 0:i.length)!=null?t:0);React.useEffect(()=>{var a;b((a=i==null?void 0:i.length)!=null?a:0)},[i]);const p=(a,g)=>{f&&(f(a,l.key,g),l.required&&w(!a))},x=C&&E,N={id:`textInput-${u}`,ref:r,disabled:s,defaultValue:i,maxLength:v,autoSize:{minRows:2,maxRows:6},onChange:a=>{const g=a.target.value;b(a.target.value.length),p(g,!1)},onFocus:()=>{c(!0)},onBlur:a=>{c(!1),p(a.target.value,!0),l.required&&w(!a.target.value)},style:{resize:"none",wordBreak:"break-all"},onKeyDownCapture:a=>{a.ctrlKey&&a.keyCode===EKeyCode.Enter&&(h&&h(),a.preventDefault()),a.keyCode===EKeyCode.Tab&&x&&(a.preventDefault(),a.nativeEvent.stopImmediatePropagation(),E(u)),a.nativeEvent.stopPropagation()}},P=React__default.default.createElement("div",{className:"textAreaFooter"},React__default.default.createElement("div",{className:"hotkeyTip"},x&&React__default.default.createElement("span",null,`[${T("Switch")}]Tab`),React__default.default.createElement("span",null,`[${T("TurnPage")}]Ctrl+Enter`)),React__default.default.createElement("div",{className:"wordCount"},React__default.default.createElement("span",{className:y>=v?"warning":""},y),"/",React__default.default.createElement("span",null,v)));return React.useEffect(()=>{s&&c(!1)},[s]),React__default.default.createElement("div",{className:"textField"},React__default.default.createElement("div",{className:"label"},React__default.default.createElement("span",{className:index.classnames({required:l.required})},l.label),React__default.default.createElement("i",{className:index.classnames({clearText:!0,disabled:s}),onClick:()=>{s||p("",!0)}})),React__default.default.createElement("div",{className:index.classnames({disabled:s,"textarea-outline":!0,"ant-input-focused":m,textareaContainer:!0,focus:m,invalid:S})},React__default.default.createElement(TextareaWithFooter,{footer:P,textareaProps:N})))},TextToolSidebar=({toolInstance:e,imgIndex:t,dispatch:r,triggerEventAfterIndexChanged:m,step:c,stepList:S,basicResultList:w,disabled:T})=>{var s,l,d,f;const[u,E]=React.useState([]),[C,h]=React.useState(0),[v,i]=React.useState(!0),[,y]=React.useState(0),{t:b}=reactI18next.useTranslation(),p=n=>{const o=(n+1)%u.length;x(o)},x=n=>{setTimeout(()=>{const o=document.getElementById(`textInput-${n}`);o&&(h(n),o.focus(),o.select(),o.scrollIntoView({behavior:"smooth",block:"center"}))})};React.useEffect(()=>{e&&e.singleOn("valueUpdated",()=>{y(n=>n+1)})},[e]),React.useEffect(()=>{var n;e&&E(_.cloneDeep((n=e==null?void 0:e.config)==null?void 0:n.configList))},[JSON.stringify((s=e==null?void 0:e.config)==null?void 0:s.configList)]);const N=(f=(d=(l=e==null?void 0:e.textList)==null?void 0:l[0])==null?void 0:d.value)!=null?f:{},P=(n,o,O=!1)=>{var L,q;(q=e==null?void 0:e.updateTextValue)==null||q.call(e,o,n,O,(L=e==null?void 0:e.textList)==null?void 0:L[0])};React.useEffect(()=>{t>-1&&m&&x(0)},[t]);const a=()=>{r(actionCreators.PageForward(!0))},g=n=>{i(n),e==null||e.toggleShowText(n)},F=ConfigUtils.ConfigUtils.getStepConfig(S,c).tool===EVideoToolName.VideoTextTool;return e&&React__default.default.createElement("div",{className:"textToolOperationMenu"},u.map((n,o)=>React__default.default.createElement(SingleTextInput,{config:n,key:n.key,index:o,result:N,updateText:P,switchToNextTextarea:p,hasMultiple:u.length>1,focus:C===o,onNext:a,disabled:T})),F&&React__default.default.createElement("div",{className:"textToolSwitchItem"},b("toggleShowText"),React__default.default.createElement(es.Switch,{style:{alignSelf:"center"},checked:v,onChange:n=>{g(n)}})))};function mapStateToProps(e){return{toolInstance:e.annotation.toolInstance,imgIndex:e.annotation.imgIndex,step:e.annotation.step,basicResultList:e.annotation.basicResultList,stepList:e.annotation.stepList,triggerEventAfterIndexChanged:e.annotation.triggerEventAfterIndexChanged}}var TextToolSidebar$1=reactRedux.connect(mapStateToProps,null,null,{context:ctx.LabelBeeContext})(TextToolSidebar);exports.SingleTextInput=SingleTextInput,exports.TextareaWithFooter=TextareaWithFooter,exports.default=TextToolSidebar$1;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),reactRedux=require("react-redux"),_=require("lodash"),index=require("../../../../utils/index.js"),es=require("antd/es"),lbAnnotation=require("@labelbee/lb-annotation"),actionCreators=require("../../../../store/annotation/actionCreators.js"),ConfigUtils=require("../../../../utils/ConfigUtils.js"),reactI18next=require("react-i18next"),ctx=require("../../../../store/ctx.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,r)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,__spreadValues=(e,t)=>{for(var r in t||(t={}))__hasOwnProp.call(t,r)&&__defNormalProp(e,r,t[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(t))__propIsEnum.call(t,r)&&__defNormalProp(e,r,t[r]);return e};const EKeyCode=lbAnnotation.cKeyCode.default,{EVideoToolName}=lbAnnotation.cTool,syntheticEventStopPagination=e=>{e.stopPropagation(),e.nativeEvent.stopPropagation(),e.nativeEvent.stopImmediatePropagation()},TextareaWithFooter=e=>{const{textareaProps:t,footer:r}=e;return React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(es.Input.TextArea,__spreadValues({key:`${t.id}-${t.defaultValue}`,bordered:!1,rows:6,onKeyDown:syntheticEventStopPagination,onKeyUp:syntheticEventStopPagination},t)),React__default.default.createElement("div",{className:index.classnames({textAreaLength:!0})},r))},SingleTextInput=e=>{var t;const r=React.useRef(null),[m,c]=React.useState(!1),[S,w]=React.useState(!1),{t:T}=reactI18next.useTranslation(),{disabled:s,config:l,result:d,updateText:f,index:u,switchToNextTextarea:E,hasMultiple:C,onNext:h}=e,{maxLength:v}=l,i=d?d[l.key]:"",[y,b]=React.useState((t=i==null?void 0:i.length)!=null?t:0);React.useEffect(()=>{var a;b((a=i==null?void 0:i.length)!=null?a:0)},[i]);const p=(a,g)=>{f&&(f(a,l.key,g),l.required&&w(!a))},x=C&&E,N={id:`textInput-${u}`,ref:r,disabled:s,defaultValue:i,maxLength:v,autoSize:{minRows:2,maxRows:6},onChange:a=>{const g=a.target.value;b(a.target.value.length),p(g,!1)},onFocus:()=>{c(!0)},onBlur:a=>{c(!1),p(a.target.value,!0),l.required&&w(!a.target.value)},style:{resize:"none",wordBreak:"break-all"},onKeyDownCapture:a=>{a.ctrlKey&&a.keyCode===EKeyCode.Enter&&(h&&h(),a.preventDefault()),a.keyCode===EKeyCode.Tab&&x&&(a.preventDefault(),a.nativeEvent.stopImmediatePropagation(),E(u)),a.nativeEvent.stopPropagation()}},P=React__default.default.createElement("div",{className:"textAreaFooter"},React__default.default.createElement("div",{className:"hotkeyTip"},x&&React__default.default.createElement("span",null,`[${T("Switch")}]Tab`),React__default.default.createElement("span",null,`[${T("TurnPage")}]Ctrl+Enter`)),React__default.default.createElement("div",{className:"wordCount"},React__default.default.createElement("span",{className:y>=v?"warning":""},y),"/",React__default.default.createElement("span",null,v)));return React.useEffect(()=>{s&&c(!1)},[s]),React__default.default.createElement("div",{className:"textField"},React__default.default.createElement("div",{className:"label"},React__default.default.createElement("span",{className:index.classnames({required:l.required})},l.label),React__default.default.createElement("i",{className:index.classnames({clearText:!0,disabled:s}),onClick:()=>{s||p("",!0)}})),React__default.default.createElement("div",{className:index.classnames({disabled:s,"textarea-outline":!0,"ant-input-focused":m,textareaContainer:!0,focus:m,invalid:S})},React__default.default.createElement(TextareaWithFooter,{footer:P,textareaProps:N})))},TextToolSidebar=({toolInstance:e,imgIndex:t,dispatch:r,triggerEventAfterIndexChanged:m,step:c,stepList:S,basicResultList:w,disabled:T})=>{var s,l,d,f;const[u,E]=React.useState([]),[C,h]=React.useState(0),[v,i]=React.useState(!0),[,y]=React.useState(0),{t:b}=reactI18next.useTranslation(),p=n=>{const o=(n+1)%u.length;x(o)},x=n=>{setTimeout(()=>{const o=document.getElementById(`textInput-${n}`);o&&(h(n),o.focus(),o.select(),o.scrollIntoView({behavior:"smooth",block:"center"}))})};React.useEffect(()=>{e&&e.singleOn("valueUpdated",()=>{y(n=>n+1)})},[e]),React.useEffect(()=>{var n;e&&E(_.cloneDeep((n=e==null?void 0:e.config)==null?void 0:n.configList))},[JSON.stringify((s=e==null?void 0:e.config)==null?void 0:s.configList)]);const N=(f=(d=(l=e==null?void 0:e.textList)==null?void 0:l[0])==null?void 0:d.value)!=null?f:{},P=(n,o,O=!1)=>{var L,q;(q=e==null?void 0:e.updateTextValue)==null||q.call(e,o,n,O,(L=e==null?void 0:e.textList)==null?void 0:L[0])};React.useEffect(()=>{t>-1&&m&&x(0)},[t]);const a=()=>{r(actionCreators.PageForward(!0))},g=n=>{i(n),e==null||e.toggleShowText(n)},F=ConfigUtils.ConfigUtils.getStepConfig(S,c).tool===EVideoToolName.VideoTextTool;return e&&React__default.default.createElement("div",{className:"textToolOperationMenu"},u==null?void 0:u.map((n,o)=>React__default.default.createElement(SingleTextInput,{config:n,key:n.key,index:o,result:N,updateText:P,switchToNextTextarea:p,hasMultiple:u.length>1,focus:C===o,onNext:a,disabled:T})),F&&React__default.default.createElement("div",{className:"textToolSwitchItem"},b("toggleShowText"),React__default.default.createElement(es.Switch,{style:{alignSelf:"center"},checked:v,onChange:n=>{g(n)}})))};function mapStateToProps(e){return{toolInstance:e.annotation.toolInstance,imgIndex:e.annotation.imgIndex,step:e.annotation.step,basicResultList:e.annotation.basicResultList,stepList:e.annotation.stepList,triggerEventAfterIndexChanged:e.annotation.triggerEventAfterIndexChanged}}var TextToolSidebar$1=reactRedux.connect(mapStateToProps,null,null,{context:ctx.LabelBeeContext})(TextToolSidebar);exports.SingleTextInput=SingleTextInput,exports.TextareaWithFooter=TextareaWithFooter,exports.default=TextToolSidebar$1;
|
package/es/App.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import B from"./views/MainView/index.js";import{i18n as o}from"@labelbee/lb-utils";import O,{useState as M,useEffect as s}from"react";import{connect as U}from"react-redux";import{store as n}from"./index.js";import{LabelBeeContext as z}from"./store/ctx.js";import{ANNOTATION_ACTIONS as j}from"./store/Actions.js";import{InitTaskData as R,InitAnnotationState as V,UpdateInjectFunc as k,loadImgList as G}from"./store/annotation/actionCreators.js";import{LoadFileAndFileData as C}from"./store/annotation/reducer.js";import{ConfigProvider as $}from"antd/es";import q from"antd/es/locale/zh_CN";import H from"antd/es/locale/en_US";var J=Object.defineProperty,K=Object.defineProperties,Q=Object.getOwnPropertyDescriptors,T=Object.getOwnPropertySymbols,W=Object.prototype.hasOwnProperty,X=Object.prototype.propertyIsEnumerable,w=(e,t,a)=>t in e?J(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,Y=(e,t)=>{for(var a in t||(t={}))W.call(t,a)&&w(e,a,t[a]);if(T)for(var a of T(t))X.call(t,a)&&w(e,a,t[a]);return e},Z=(e,t)=>K(e,Q(t));const ee=e=>{const[t,a]=M(0),{imgList:l,step:p=1,stepList:c,onSubmit:d,onSave:g,onPageChange:f,onStepChange:m,initialIndex:u=0,toolInstance:y,setToolInstance:L,getFileData:_,pageSize:h=10,loadFileList:r,defaultLang:P="cn",skipBeforePageTurning:x,beforeRotate:I,checkMode:b=!1,intelligentFit:A=!0,highlightAttribute:S="",preDataProcess:v,getImgIndexByExternal:E,annotationBefore:D}=e;s(()=>{n.dispatch(R({onSubmit:d,stepList:c,step:p,getFileData:_,pageSize:h,loadFileList:r,onSave:g,onPageChange:f,onStepChange:m,skipBeforePageTurning:x,beforeRotate:I,checkMode:b,highlightAttribute:S,preDataProcess:v,getImgIndexByExternal:E,annotationBefore:D})),F(),o.changeLanguage(P);const i=()=>{a(N=>N+1)};return o.on("languageChanged",i),()=>{o.off("languageChanged",i),V(n.dispatch)}},[]),s(()=>{n.dispatch(k({onSubmit:d,stepList:c,getFileData:_,pageSize:h,loadFileList:r,onSave:g,onPageChange:f,onStepChange:m,beforeRotate:I,highlightAttribute:S,preDataProcess:v})),o.changeLanguage(P)},[d,c,_,h,r,g,f,m,P,I,S,v]),s(()=>{L==null||L(y)},[y]),s(()=>{n.dispatch({type:j.SET_STEP,payload:{toStep:p}})},[p]);const F=()=>{r?G(n.dispatch,n.getState,u,!0).then(i=>{i&&n.dispatch(C(u))}):l&&l.length>0&&(n.dispatch({type:j.UPDATE_IMG_LIST,payload:{imgList:l}}),n.dispatch(C(u)))};return O.createElement("div",null,O.createElement($,{locale:o.language==="en"?H:q},O.createElement(B,Z(Y({},e),{intelligentFit:A,checkMode:b}))))},te=e=>({toolInstance:e.annotation.toolInstance});var ae=U(te,null,null,{context:z})(ee);export{ae as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as o from"react";var c;function a(){return a=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},a.apply(this,arguments)}var i=function(t){return o.createElement("svg",a({xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"
|
|
1
|
+
import*as o from"react";var c;function a(){return a=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},a.apply(this,arguments)}var i=function(t){return o.createElement("svg",a({xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"currentColor","aria-hidden":"true","data-icon":"left",viewBox:"64 64 896 896"},t),c||(c=o.createElement("path",{d:"M724 218.3V141c0-6.7-7.7-10.4-12.9-6.3L260.3 486.8a31.86 31.86 0 0 0 0 50.3l450.8 352.1c5.3 4.1 12.9.4 12.9-6.3v-77.3c0-4.9-2.3-9.6-6.1-12.6l-360-281 360-281.1c3.8-3 6.1-7.7 6.1-12.6"})))};export{i as ReactComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as i from"react";var o;function a(){return a=Object.assign?Object.assign.bind():function(r){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n])}return r},a.apply(this,arguments)}var c=function(t){return i.createElement("svg",a({xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"
|
|
1
|
+
import*as i from"react";var o;function a(){return a=Object.assign?Object.assign.bind():function(r){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n])}return r},a.apply(this,arguments)}var c=function(t){return i.createElement("svg",a({xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"currentColor","aria-hidden":"true","data-icon":"right",viewBox:"64 64 896 896"},t),o||(o=i.createElement("path",{d:"M765.7 486.8 314.9 134.7A7.97 7.97 0 0 0 302 141v77.3c0 4.9 2.3 9.6 6.1 12.6l360 281.1-360 281.1c-3.9 3-6.1 7.7-6.1 12.6V883c0 6.7 7.7 10.4 12.9 6.3l450.8-352.1a31.96 31.96 0 0 0 0-50.4"})))};export{c as ReactComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{MathUtils as C,CommonToolUtils as F,uuid as A,AttributeUtils as k}from"@labelbee/lb-annotation";import{jsonParser as P}from"../../../utils/index.js";import{precisionAdd as I,precisionMinus as V,isImageValue as R}from"../../../utils/audio.js";import{message as m}from"antd";import b from"lodash";import g from"react";import _ from"./index.module.scss.js";import{VideoClipToolContextProvider as B}from"./VideoClipToolContext.js";import{EClipStatus as o,ETimeSliceType as T,PER_SLICE_CHANGE as v,SLICE_MIN_TIME as x}from"./constant.js";import{VideoPlayer as j}from"../../videoPlayer/index.js";import M from"./components/videoTimeSlicesOverVideo/index.js";import U from"../../../assets/annotation/video/icon_videoCutting.svg.js";import{decimalReserved as L}from"../../videoPlayer/utils.js";class N extends g.Component{constructor(r){super(r);this.fns=new Map,this.throttledUpdateTime=b.throttle(t=>{this.videoPlayer.currentTime=t},100,{trailing:!0}),this.stepInfo=()=>this.props.stepInfo,this.emitEvent=t=>{const e=this.fns.get(t);e&&e.forEach(i=>{i&&i()})},this.setValid=t=>{this.setState({valid:t}),t===!1&&(this.clearResult(),this.updateSidebar())},this.updateSidebar=()=>{this.emitEvent("changeClipSidebar"),this.emitEvent("updateTextAttribute"),this.emitEvent("changeAttributeSidebar")},this.exportData=()=>{var t,e;const i=(e=(t=this.videoRef)==null?void 0:t.duration)!=null?e:0;return[this.state.result.filter(s=>s.end!==null),{valid:this.state.valid,duration:i}]},this.updateSelectedSliceTimeStartByPer=t=>{var e,i;if(this.state.clipStatus===o.Clipping){m.info("\u622A\u53D6\u4E2D\u4E0D\u652F\u6301\u8C03\u6574\u5F00\u59CB\u65F6\u95F4");return}if(this.selectedSliceIndex>-1){const s=(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0,{end:l,start:u,type:a}=this.state.result[this.selectedSliceIndex],n=C.withinRange(I(u,t),[0,V(a===T.Time?s:l,v)]);this.updateSelectedSliceTimeProperty(n,"start")}},this.updateSelectedSliceTimeEndByPer=t=>{var e,i;if(this.state.clipStatus===o.Clipping){m.info("\u622A\u53D6\u4E2D\u4E0D\u652F\u6301\u8C03\u6574\u7ED3\u675F\u65F6\u95F4");return}if(this.selectedSliceIndex>-1){const s=this.state.result[this.selectedSliceIndex],l=(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0;if(s.type===T.Time){m.info("\u65F6\u95F4\u70B9\u4EC5\u652F\u6301\u8C03\u6574\u5F00\u59CB\u65F6\u95F4");return}const{end:u,start:a}=s,n=C.withinRange(I(u,t),[I(a,v),l]);this.updateSelectedSliceTimeProperty(n,"end")}},this.updateSelectedSliceTimeProperty=(t,e)=>{if(this.selectedSliceIndex>-1){const{result:i}=this.state;i[this.selectedSliceIndex][e]=t,this.setState({result:b.cloneDeep(i)}),this.updateSidebar()}},this.keyDownEvents=t=>{if(!F.hotkeyFilter(t))return;const e=t.target;switch(e&&(e==null?void 0:e.tag)==="INPUT"&&(e==null?void 0:e.type)==="radio"&&t.preventDefault(),t.key.toLocaleLowerCase()){case"x":this.toggleClipStatus();break;case"e":this.addTime();break;case"escape":this.cancelClipped();break;case"-":this.updateSelectedSliceTimeStartByPer(-v);break;case"=":this.updateSelectedSliceTimeStartByPer(v);break;case"[":this.updateSelectedSliceTimeEndByPer(-v);break;case"]":this.updateSelectedSliceTimeEndByPer(v);break}},this.setVideoError=(t,e,i)=>{if(t){const{clipStatus:s}=this.state;s===o.Clipping&&this.toggleClipStatus(i)}this.setState({videoError:t,loading:!1})},this.clearResult=()=>{this.setState({result:[],selectedID:"",textValue:""}),this.updateSidebar()},this.cancelClipped=()=>{const{result:t,selectedID:e,clipStatus:i}=this.state;if(i!==o.Clipping)return;const s=t.findIndex(l=>l.id===e);s>-1&&(t.splice(s,1),this.setState({result:t,selectedID:"",clipStatus:o.Stop}),this.updateSidebar())},this.toggleClipStatus=t=>{var e,i,s;if(this.disabled)return;const{clipStatus:l,selectedAttribute:u}=this.state,a=l!==o.Clipping;let n=a?o.Clipping:o.Stop,{result:d,selectedID:c,textValue:p}=this.state;const h=b.cloneDeep(d),S=t||((e=this.videoPlayer)==null?void 0:e.currentTime),y=(i=this.videoPlayer)==null?void 0:i.duration;if(y===void 0||S===void 0)return;const w=L(S,2);if(a){const f=A();c=f,h.push({start:w,end:null,attribute:u,textAttribute:this.defaultTextAttribute,duration:y,id:f,type:T.Period}),p=this.defaultTextAttribute}else{const f=h.findIndex(E=>E.id===c),D=h[f];D&&(S-D.start<x?(h.splice(f,1),m.info(`\u622A\u53D6\u7247\u6BB5\u4E0D\u80FD\u77ED\u4E8E${x}s`),n=o.Stop,c="",p=""):(h[f].end=L(S,2),(s=this.videoPlayer)==null||s.pause(),m.success(`\u5DF2\u622A\u53D6\u7247\u6BB5${d.length}`)))}this.setState({clipStatus:n,result:h,selectedID:c,textValue:p}),this.updateSidebar()},this.addTime=()=>{var t,e,i,s;if(this.disabled)return;const{result:l,selectedAttribute:u,selectedID:a}=this.state,n=A(),d=b.cloneDeep(l),c=((t=this.videoPlayer)==null?void 0:t.currentTime)||0;d.push({start:c,end:c,attribute:u,textAttribute:this.defaultTextAttribute,id:n,type:T.Time,duration:(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0});const p={result:d,selectedID:n,textValue:this.defaultTextAttribute},h=d.find(S=>S.id===a);this.isClipping&&h?(delete p.selectedID,delete p.textValue,m.success(`\u5DF2\u622A\u53D6\u65F6\u95F4\u70B9${d.length-1}`)):(s=this.videoPlayer)==null||s.pause(),this.setState(p),this.updateSidebar()},this.updateCurrentTime=t=>{this.setState({currentTime:t})},this.contextToCancel=t=>{this.state.clipStatus===o.Stop&&(t.preventDefault(),this.setState({selectedID:""}),this.updateSidebar())},this.onTrackResize=(t,e,i)=>{var s,l;const{result:u}=this.state,a=u.find(n=>n.id===t);if(a){const n=a.duration,d=e==="left",c=d?"start":"end",p=d?-n*i:n*i,h=d?[0,Math.max(((s=a.end)!=null?s:0)-x,0)]:[a.start+x,n],S=C.withinRange(p+((l=a==null?void 0:a[c])!=null?l:0),h);a[c]=S,this.throttledUpdateTime(S)}this.setState({result:[...u]}),this.updateSidebar()},this.renderMediaContent=()=>{var t;const{pageForward:e,pageJump:i,pageBackward:s}=this.props,{result:l,videoError:u,valid:a,currentTime:n}=this.state;return g.createElement("div",{className:_.clipContainer},g.createElement(j,{imgIndex:this.props.imgIndex,imgList:this.props.imgList,pageBackward:s,pageForward:e,pageJump:i,valid:a,setVideoRef:d=>{this.videoPlayer=d},showVideoTrack:!u,onTrackResize:this.onTrackResize,drawLayerSlot:this.props.drawLayerSlot,footer:this.props.footer,dataLoaded:this.props.onVideoLoaded,toggleClipStatus:this.toggleClipStatus,addTime:this.addTime,updateCurrentTime:this.updateCurrentTime}),g.createElement(M,{key:(t=this.videoPlayer)==null?void 0:t.currentTime,result:l,currentTime:n,attributeList:this.props.config.attributeList,extraStyle:{top:this.props.drawLayerSlot?40:0}}),this.isClipping&&g.createElement("i",{className:_.clipping,style:{backgroundImage:U}}))},this.onSelectedTimeSlice=t=>{var e;this.isClipping||(this.setState({selectedID:t.id,selectedAttribute:t.attribute,textValue:t.textAttribute,currentTime:t.start}),this.updateSidebar(),(e=this.videoPlayer)==null||e.pause(),this.videoPlayer.currentTime=t.start)},this.removeTimeSlice=t=>{const{result:e}=this.state,i=this.state.selectedID===t.id?"":this.state.selectedID,s=e.findIndex(l=>l.id===t.id);s>-1&&(e.splice(s,1),this.setState({result:[...e],selectedID:i}),this.updateSidebar())},this.setResult=(t=!0,e=this.props)=>{try{const{imgIndex:i,imgList:s}=e;if(!s[i])return;const u=P(s[i].result)[`step_${this.stepInfo().step}`],a=(u==null?void 0:u.result)||[],n=R(s[i].result||"[]");this.setState({result:a,loading:t,selectedID:"",textValue:"",selectedAttribute:"",clipStatus:o.Stop,valid:n},()=>{this.updateSidebar(),n||m.info("\u65E0\u6548\u89C6\u9891\uFF0C\u8BF7\u8DF3\u8FC7")})}catch(i){console.error("\u6570\u636E\u89E3\u6790\u5931\u8D25"),this.setState({result:[],loading:!1,selectedID:"",textValue:"",selectedAttribute:"",valid:!0},()=>{this.updateSidebar()})}},this.setDefaultAttribute=t=>{const{result:e,selectedID:i}=this.state,s=e.find(l=>l.id===i);s&&i&&(s.attribute=t),this.setState({selectedAttribute:t,result:[...e]}),this.updateSidebar()},this.textChange=t=>{const{result:e,selectedID:i}=this.state;if(this.setState({textValue:t}),i){const s=e.find(l=>l.id===i);s&&(s.textAttribute=t,this.setState({result:[...e]}),this.updateSidebar())}},this.state={result:[],selectedAttribute:"",textValue:"",clipStatus:o.Stop,selectedID:"",loading:!1,videoError:!1,remainingTime:0,currentTime:0,configLoading:!1,valid:!0}}get videoUrl(){var r;const{imgIndex:t,imgList:e}=this.props;return((r=e[t])==null?void 0:r.url)||""}get isClipping(){return this.state.clipStatus===o.Clipping}get resultJSON(){const{imgIndex:r,imgList:t}=this.props;return t.length===0||!t[r]?"[]":t[r].result}get disabled(){return!this.state.valid||this.state.videoError}get loading(){return this.state.loading||this.state.configLoading}get defaultTextAttribute(){return k.getTextAttribute(this.state.result,this.props.config.textCheckType)}get defaultAttribute(){return this.state.selectedAttribute}get selectedID(){return this.state.selectedID}get selectedSliceIndex(){return this.state.result.findIndex(r=>r.id===this.state.selectedID)}get exportContext(){return{selectedID:this.state.selectedID,result:this.state.result,clipStatus:this.state.clipStatus,videoPlayer:this.videoPlayer,attributeList:this.props.config.attributeList,onSelectedTimeSlice:this.onSelectedTimeSlice,removeTimeSlice:this.removeTimeSlice,updateSelectedSliceTimeProperty:this.updateSelectedSliceTimeProperty}}get valid(){return this.state.valid}get config(){var r;return P((r=this.props.stepInfo)==null?void 0:r.config)}get selectedText(){var r,t;return(t=(r=this.state.result)==null?void 0:r[this.selectedSliceIndex])==null?void 0:t.textAttribute}componentDidMount(){this.setState({loading:!1}),this.setResult(!1),this.props.onMounted(this),window.addEventListener("keydown",this.keyDownEvents)}componentWillUnmount(){this.props.onUnmounted(),window.removeEventListener("keydown",this.keyDownEvents)}shouldComponentUpdate(r,t){const e=r.imgIndex-this.props.imgIndex,i=r.step-this.props.step;return(e!==0||i!==0)&&(this.setResult(!0,r),i!==0&&this.setState({loading:!1})),!0}singleOn(r,t){this.fns.set(r,[t])}on(r,t){this.singleOn(r,t)}unbindAll(r){this.fns.delete(r)}render(){const{selectedID:r,result:t,clipStatus:e,selectedAttribute:i}=this.state;return g.createElement(B,{value:{videoPlayer:this.videoPlayer,result:t,selectedID:r,attributeList:this.props.config.attributeList,clipStatus:e,selectedAttribute:i,contextToCancel:this.contextToCancel}},this.renderMediaContent())}}export{N as default};
|
|
1
|
+
import{MathUtils as C,CommonToolUtils as F,uuid as A,AttributeUtils as R}from"@labelbee/lb-annotation";import{jsonParser as P}from"../../../utils/index.js";import{precisionAdd as y,precisionMinus as k,isImageValue as V}from"../../../utils/audio.js";import{message as m}from"antd";import b from"lodash";import g from"react";import _ from"./index.module.scss.js";import{VideoClipToolContextProvider as B}from"./VideoClipToolContext.js";import{EClipStatus as d,ETimeSliceType as T,PER_SLICE_CHANGE as v,SLICE_MIN_TIME as x}from"./constant.js";import{VideoPlayer as j}from"../../videoPlayer/index.js";import M from"./components/videoTimeSlicesOverVideo/index.js";import U from"../../../assets/annotation/video/icon_videoCutting.svg.js";import{decimalReserved as L}from"../../videoPlayer/utils.js";class N extends g.Component{constructor(r){super(r);this.fns=new Map,this.throttledUpdateTime=b.throttle(t=>{this.videoPlayer.currentTime=t},100,{trailing:!0}),this.stepInfo=()=>this.props.stepInfo,this.emitEvent=t=>{const e=this.fns.get(t);e&&e.forEach(i=>{i&&i()})},this.setValid=t=>{this.setState({valid:t}),t===!1&&(this.clearResult(),this.updateSidebar())},this.updateSidebar=()=>{this.emitEvent("changeClipSidebar"),this.emitEvent("updateTextAttribute"),this.emitEvent("changeAttributeSidebar")},this.exportData=()=>{var t,e;const i=(e=(t=this.videoRef)==null?void 0:t.duration)!=null?e:0;return[this.state.result.filter(s=>s.end!==null),{valid:this.state.valid,duration:i}]},this.updateSelectedSliceTimeStartByPer=t=>{var e,i;if(this.state.clipStatus===d.Clipping){m.info("\u622A\u53D6\u4E2D\u4E0D\u652F\u6301\u8C03\u6574\u5F00\u59CB\u65F6\u95F4");return}if(this.selectedSliceIndex>-1){const s=(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0,{end:l,start:u,type:a}=this.state.result[this.selectedSliceIndex],n=C.withinRange(y(u,t),[0,k(a===T.Time?s:l,v)]);this.updateSelectedSliceTimeProperty(n,"start")}},this.updateSelectedSliceTimeEndByPer=t=>{var e,i;if(this.state.clipStatus===d.Clipping){m.info("\u622A\u53D6\u4E2D\u4E0D\u652F\u6301\u8C03\u6574\u7ED3\u675F\u65F6\u95F4");return}if(this.selectedSliceIndex>-1){const s=this.state.result[this.selectedSliceIndex],l=(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0;if(s.type===T.Time){m.info("\u65F6\u95F4\u70B9\u4EC5\u652F\u6301\u8C03\u6574\u5F00\u59CB\u65F6\u95F4");return}const{end:u,start:a}=s,n=C.withinRange(y(u,t),[y(a,v),l]);this.updateSelectedSliceTimeProperty(n,"end")}},this.updateSelectedSliceTimeProperty=(t,e)=>{if(this.selectedSliceIndex>-1){const{result:i}=this.state;i[this.selectedSliceIndex][e]=t,this.setState({result:b.cloneDeep(i)}),this.updateSidebar()}},this.keyDownEvents=t=>{if(!F.hotkeyFilter(t))return;const e=t.target;switch(e&&(e==null?void 0:e.tag)==="INPUT"&&(e==null?void 0:e.type)==="radio"&&t.preventDefault(),t.key.toLocaleLowerCase()){case"x":this.toggleClipStatus();break;case"e":this.addTime();break;case"escape":this.cancelClipped();break;case"-":this.updateSelectedSliceTimeStartByPer(-v);break;case"=":this.updateSelectedSliceTimeStartByPer(v);break;case"[":this.updateSelectedSliceTimeEndByPer(-v);break;case"]":this.updateSelectedSliceTimeEndByPer(v);break}},this.setVideoError=(t,e,i)=>{if(t){const{clipStatus:s}=this.state;s===d.Clipping&&this.toggleClipStatus(i)}this.setState({videoError:t,loading:!1})},this.clearResult=()=>{this.setState({result:[],selectedID:"",textValue:""}),this.updateSidebar()},this.cancelClipped=()=>{const{result:t,selectedID:e,clipStatus:i}=this.state;if(i!==d.Clipping)return;const s=t.findIndex(l=>l.id===e);s>-1&&(t.splice(s,1),this.setState({result:t,selectedID:"",clipStatus:d.Stop}),this.updateSidebar())},this.toggleClipStatus=t=>{var e,i;if(typeof((e=this.props)==null?void 0:e.annotationBefore)=="function"){(i=this.props)==null||i.annotationBefore(()=>this.setClipResult(t));return}this.setClipResult(t)},this.setClipResult=t=>{var e,i,s;if(this.disabled)return;const{clipStatus:l,selectedAttribute:u}=this.state,a=l!==d.Clipping;let n=a?d.Clipping:d.Stop,{result:o,selectedID:c,textValue:h}=this.state;const p=b.cloneDeep(o),S=t||((e=this.videoPlayer)==null?void 0:e.currentTime),I=(i=this.videoPlayer)==null?void 0:i.duration;if(I===void 0||S===void 0)return;const w=L(S,2);if(a){const f=A();c=f,p.push({start:w,end:null,attribute:u,textAttribute:this.defaultTextAttribute,duration:I,id:f,type:T.Period}),h=this.defaultTextAttribute}else{const f=p.findIndex(E=>E.id===c),D=p[f];D&&(S-D.start<x?(p.splice(f,1),m.info(`\u622A\u53D6\u7247\u6BB5\u4E0D\u80FD\u77ED\u4E8E${x}s`),n=d.Stop,c="",h=""):(p[f].end=L(S,2),(s=this.videoPlayer)==null||s.pause(),m.success(`\u5DF2\u622A\u53D6\u7247\u6BB5${o.length}`)))}this.setState({clipStatus:n,result:p,selectedID:c,textValue:h}),this.updateSidebar()},this.addTime=()=>{var t,e,i,s;if(this.disabled)return;const{result:l,selectedAttribute:u,selectedID:a}=this.state,n=A(),o=b.cloneDeep(l),c=((t=this.videoPlayer)==null?void 0:t.currentTime)||0;o.push({start:c,end:c,attribute:u,textAttribute:this.defaultTextAttribute,id:n,type:T.Time,duration:(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0});const h={result:o,selectedID:n,textValue:this.defaultTextAttribute},p=o.find(S=>S.id===a);this.isClipping&&p?(delete h.selectedID,delete h.textValue,m.success(`\u5DF2\u622A\u53D6\u65F6\u95F4\u70B9${o.length-1}`)):(s=this.videoPlayer)==null||s.pause(),this.setState(h),this.updateSidebar()},this.updateCurrentTime=t=>{this.setState({currentTime:t})},this.contextToCancel=t=>{this.state.clipStatus===d.Stop&&(t.preventDefault(),this.setState({selectedID:""}),this.updateSidebar())},this.onTrackResize=(t,e,i)=>{var s,l;const{result:u}=this.state,a=u.find(n=>n.id===t);if(a){const n=a.duration,o=e==="left",c=o?"start":"end",h=o?-n*i:n*i,p=o?[0,Math.max(((s=a.end)!=null?s:0)-x,0)]:[a.start+x,n],S=C.withinRange(h+((l=a==null?void 0:a[c])!=null?l:0),p);a[c]=S,this.throttledUpdateTime(S)}this.setState({result:[...u]}),this.updateSidebar()},this.renderMediaContent=()=>{var t;const{pageForward:e,pageJump:i,pageBackward:s}=this.props,{result:l,videoError:u,valid:a,currentTime:n}=this.state;return g.createElement("div",{className:_.clipContainer},g.createElement(j,{imgIndex:this.props.imgIndex,imgList:this.props.imgList,pageBackward:s,pageForward:e,pageJump:i,valid:a,setVideoRef:o=>{this.videoPlayer=o},showVideoTrack:!u,onTrackResize:this.onTrackResize,drawLayerSlot:this.props.drawLayerSlot,footer:this.props.footer,dataLoaded:this.props.onVideoLoaded,toggleClipStatus:this.toggleClipStatus,addTime:this.addTime,updateCurrentTime:this.updateCurrentTime}),g.createElement(M,{key:(t=this.videoPlayer)==null?void 0:t.currentTime,result:l,currentTime:n,attributeList:this.props.config.attributeList,extraStyle:{top:this.props.drawLayerSlot?40:0}}),this.isClipping&&g.createElement("i",{className:_.clipping,style:{backgroundImage:U}}))},this.onSelectedTimeSlice=t=>{var e;this.isClipping||(this.setState({selectedID:t.id,selectedAttribute:t.attribute,textValue:t.textAttribute,currentTime:t.start}),this.updateSidebar(),(e=this.videoPlayer)==null||e.pause(),this.videoPlayer.currentTime=t.start)},this.removeTimeSlice=t=>{const{result:e}=this.state,i=this.state.selectedID===t.id?"":this.state.selectedID,s=e.findIndex(l=>l.id===t.id);s>-1&&(e.splice(s,1),this.setState({result:[...e],selectedID:i}),this.updateSidebar())},this.setResult=(t=!0,e=this.props)=>{try{const{imgIndex:i,imgList:s}=e;if(!s[i])return;const u=P(s[i].result)[`step_${this.stepInfo().step}`],a=(u==null?void 0:u.result)||[],n=V(s[i].result||"[]");this.setState({result:a,loading:t,selectedID:"",textValue:"",selectedAttribute:"",clipStatus:d.Stop,valid:n},()=>{this.updateSidebar(),n||m.info("\u65E0\u6548\u89C6\u9891\uFF0C\u8BF7\u8DF3\u8FC7")})}catch(i){console.error("\u6570\u636E\u89E3\u6790\u5931\u8D25"),this.setState({result:[],loading:!1,selectedID:"",textValue:"",selectedAttribute:"",valid:!0},()=>{this.updateSidebar()})}},this.setDefaultAttribute=t=>{const{result:e,selectedID:i}=this.state,s=e.find(l=>l.id===i);s&&i&&(s.attribute=t),this.setState({selectedAttribute:t,result:[...e]}),this.updateSidebar()},this.textChange=t=>{const{result:e,selectedID:i}=this.state;if(this.setState({textValue:t}),i){const s=e.find(l=>l.id===i);s&&(s.textAttribute=t,this.setState({result:[...e]}),this.updateSidebar())}},this.state={result:[],selectedAttribute:"",textValue:"",clipStatus:d.Stop,selectedID:"",loading:!1,videoError:!1,remainingTime:0,currentTime:0,configLoading:!1,valid:!0}}get videoUrl(){var r;const{imgIndex:t,imgList:e}=this.props;return((r=e[t])==null?void 0:r.url)||""}get isClipping(){return this.state.clipStatus===d.Clipping}get resultJSON(){const{imgIndex:r,imgList:t}=this.props;return t.length===0||!t[r]?"[]":t[r].result}get disabled(){return!this.state.valid||this.state.videoError}get loading(){return this.state.loading||this.state.configLoading}get defaultTextAttribute(){return R.getTextAttribute(this.state.result,this.props.config.textCheckType)}get defaultAttribute(){return this.state.selectedAttribute}get selectedID(){return this.state.selectedID}get selectedSliceIndex(){return this.state.result.findIndex(r=>r.id===this.state.selectedID)}get exportContext(){return{selectedID:this.state.selectedID,result:this.state.result,clipStatus:this.state.clipStatus,videoPlayer:this.videoPlayer,attributeList:this.props.config.attributeList,onSelectedTimeSlice:this.onSelectedTimeSlice,removeTimeSlice:this.removeTimeSlice,updateSelectedSliceTimeProperty:this.updateSelectedSliceTimeProperty}}get valid(){return this.state.valid}get config(){var r;return P((r=this.props.stepInfo)==null?void 0:r.config)}get selectedText(){var r,t;return(t=(r=this.state.result)==null?void 0:r[this.selectedSliceIndex])==null?void 0:t.textAttribute}componentDidMount(){this.setState({loading:!1}),this.setResult(!1),this.props.onMounted(this),window.addEventListener("keydown",this.keyDownEvents)}componentWillUnmount(){this.props.onUnmounted(),window.removeEventListener("keydown",this.keyDownEvents)}shouldComponentUpdate(r,t){const e=r.imgIndex-this.props.imgIndex,i=r.step-this.props.step;return(e!==0||i!==0)&&(this.setResult(!0,r),i!==0&&this.setState({loading:!1})),!0}singleOn(r,t){this.fns.set(r,[t])}on(r,t){this.singleOn(r,t)}unbindAll(r){this.fns.delete(r)}render(){const{selectedID:r,result:t,clipStatus:e,selectedAttribute:i}=this.state;return g.createElement(B,{value:{videoPlayer:this.videoPlayer,result:t,selectedID:r,attributeList:this.props.config.attributeList,clipStatus:e,selectedAttribute:i,contextToCancel:this.contextToCancel}},this.renderMediaContent())}}export{N as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import h from"react";import{TagUtils as
|
|
1
|
+
import h from"react";import{TagUtils as m,CommonToolUtils as f,uuid as v}from"@labelbee/lb-annotation";import{jsonParser as g}from"../../../utils/index.js";import{VideoPlayer as y}from"../../videoPlayer/index.js";import{VideoTagLayer as L}from"../../videoPlayer/VideoTagLayer.js";import p,{cloneDeep as R}from"lodash";import{getKeyCodeNumber as b}from"../../videoPlayer/utils.js";class S extends h.Component{constructor(e){super(e);this.fns={},this.labelSelectedList=[],this.clearResult=(t=!0,s)=>{const n=s?this.state.tagResult.map(i=>((i==null?void 0:i.result[s])&&delete i.result[s],i)):[];this.setState({tagResult:n},()=>this.emitEvent("render"))},this.exportData=()=>{var t,s;const n=(s=(t=this.videoPlayer)==null?void 0:t.duration)!=null?s:0;return[this.state.tagResult,{valid:this.state.valid,duration:n}]},this.emitEvent=t=>{this.fns[t]&&this.fns[t]()},this.combineResult=(t,s={})=>{var n,i;const l=R(s),{isMulti:a}=t,{key:r,value:d}=t.value;if(a){let o=(i=(n=l[r])==null?void 0:n.split(";"))!=null?i:[];o.includes(d)?o=o.filter(c=>c!==d):o.push(d);const u=new Set(o);return l[r]=Array.from(u).join(";"),p.pickBy(l,c=>c)}return l[r]=l[r]===d?void 0:d,p.pickBy(l,o=>o)},this.setResult=t=>{this.setState({tagResult:t}),this.fns.render&&this.fns.render()},this.setLabel=(t,s)=>{this.setLabelBySelectedList(t,s)},this.keydown=t=>{var s;const n=b(t.keyCode);if(n){const i=n-1;if(((s=this.config.inputList)==null?void 0:s.length)===1){this.labelSelectedList=[0,i],this.setLabel(0,i),setTimeout(()=>{this.labelSelectedList=[],this.emitEvent("render")},500);return}this.labelSelectedList.length===1?(this.labelSelectedList=[this.labelSelectedList[0],i],this.setLabel(this.labelSelectedList[0],i),setTimeout(()=>{this.labelSelectedList=[],this.emitEvent("render")},500)):(this.labelSelectedList=[i],this.emitEvent("expend"))}},this.setValid=t=>{this.setState({valid:t}),t===!1&&this.setState({tagResult:[]}),this.emitEvent("render")},this.setResultFromImgList=t=>{const{imgList:s,imgIndex:n,stepInfo:i}=t;if(!s[n])return;const l=g(s[n].result),a=l[`step_${i.step}`],r=this.getInitResultList();this.setState({tagResult:a?a==null?void 0:a.result:r,valid:(l==null?void 0:l.valid)===void 0?!0:l.valid},()=>this.emitEvent("render"))},this.getInitResultList=()=>{var t;return m.getDefaultTagResult((t=this.config.inputList)!=null?t:[],[])},this.state={tagResult:[],labelSelectedList:[],valid:!0}}get config(){var e;return g((e=this.props.stepInfo)==null?void 0:e.config)}get history(){return{initRecord:()=>{},pushHistory:()=>{}}}get currentTagResult(){var e;return(e=this.state.tagResult[0])!=null?e:{}}get valid(){return this.state.valid}singleOn(e,t){this.fns[e]=t}on(e,t){this.singleOn(e,t)}unbindAll(e){delete this.fns[e]}getTagResultByCode(e,t){var s,n,i;try{const l=(n=(s=this.config)==null?void 0:s.inputList)!=null?n:[],a=(l==null?void 0:l.length)>1,r=t!==void 0?e:0,d=t!==void 0?t:e,o=a?l[r]:l[0],u=((i=o.subSelected)!=null?i:[])[d];if(o&&u)return{value:{key:o.value,value:u.value},isMulti:o.isMulti}}catch(l){return}}setLabelBySelectedList(e,t){var s,n,i,l,a,r;const d=this.getTagResultByCode(e,t);if(d){const o=this.combineResult(d,(n=(s=this.state.tagResult[0])==null?void 0:s.result)!=null?n:{}),u=[{sourceID:f.getSourceID(),id:(l=(i=this.currentTagResult)==null?void 0:i.id)!=null?l:v(8,62),result:o}];if(typeof((a=this.props)==null?void 0:a.annotationBefore)=="function"){(r=this.props)==null||r.annotationBefore(()=>this.setState({tagResult:u},()=>this.emitEvent("render")));return}this.setState({tagResult:u},()=>this.emitEvent("render"))}}componentDidMount(){document.addEventListener("keydown",this.keydown),this.props.onMounted(this),this.setResultFromImgList(this.props)}componentWillUnmount(){document.addEventListener("keydown",this.keydown),this.props.onUnmounted()}shouldComponentUpdate(e){return e.imgIndex!==this.props.imgIndex&&this.setResultFromImgList(e),!0}render(){var e;const{imgIndex:t,imgList:s,pageForward:n,pageJump:i,pageBackward:l}=this.props,{tagResult:a,valid:r}=this.state;return h.createElement("div",{style:{height:"100%",width:"100%",position:"relative",display:"flex",flexDirection:"column"}},h.createElement(y,{imgIndex:t,imgList:s,pageBackward:l,pageForward:n,pageJump:i,valid:r,setVideoRef:d=>{this.videoPlayer=d},dataLoaded:this.props.onVideoLoaded,drawLayerSlot:this.props.drawLayerSlot,footer:this.props.footer}),h.createElement(L,{result:a,inputList:(e=this.config)==null?void 0:e.inputList,hasPromptLayer:!!this.props.drawLayerSlot}))}}export{S as TagToolInstanceAdaptor};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ViewportProvider as b}from"../../components/customResizeHook/index.js";import{prefix as C}from"../../constant/index.js";import{Spin as A}from"antd";import{Layout as y}from"antd/es";import t,{useState as O}from"react";import V from"./annotationOperation/index.js";import M from"./annotationTips/index.js";import k from"./sidebar/index.js";import h from"./toolFooter/index.js";import F from"./toolHeader/index.js";import{getStepConfig as E}from"../../store/annotation/reducer.js";import I from"../../components/videoAnnotate/index.js";import{connect as
|
|
1
|
+
import{ViewportProvider as b}from"../../components/customResizeHook/index.js";import{prefix as C}from"../../constant/index.js";import{Spin as A}from"antd";import{Layout as y}from"antd/es";import t,{useState as O}from"react";import V from"./annotationOperation/index.js";import M from"./annotationTips/index.js";import k from"./sidebar/index.js";import h from"./toolFooter/index.js";import F from"./toolHeader/index.js";import{getStepConfig as E}from"../../store/annotation/reducer.js";import I from"../../components/videoAnnotate/index.js";import{connect as B}from"react-redux";import g from"../../utils/ToolUtils.js";import $ from"../../components/pointCloudView/index.js";import{getClassName as H}from"../../utils/dom.js";import{classnames as R}from"../../utils/index.js";import W from"../../components/predictTracking/previewResult/index.js";import{LabelBeeContext as D}from"../../store/ctx.js";import{EToolName as c}from"../../data/enums/ToolType.js";import U from"./LLMLayout/index.js";import z from"./NLPLayout/index.js";import q from"../../components/audioAnnotate/index.js";import{LoadingOutlined as G}from"@ant-design/icons";import{useTranslation as J}from"react-i18next";import{EPointCloudName as K}from"@labelbee/lb-annotation";var Q=Object.defineProperty,T=Object.getOwnPropertySymbols,X=Object.prototype.hasOwnProperty,Y=Object.prototype.propertyIsEnumerable,P=(e,o,n)=>o in e?Q(e,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[o]=n,i=(e,o)=>{for(var n in o||(o={}))X.call(o,n)&&P(e,n,o[n]);if(T)for(var n of T(o))Y.call(o,n)&&P(e,n,o[n]);return e};const{Sider:Z,Content:p}=y,u=`${C}-layout`,ee=e=>{var o;return t.createElement(t.Fragment,null,e.showTips===!0&&t.createElement(M,{path:e.path,tips:e.tips}),t.createElement(V,i({},e)),t.createElement(h,{style:(o=e.style)==null?void 0:o.footer,mode:e.mode,footer:e==null?void 0:e.footer}))},te=e=>{var o;return t.createElement(t.Fragment,null,t.createElement($,{drawLayerSlot:e.drawLayerSlot,checkMode:e.checkMode,intelligentFit:e.intelligentFit,measureVisible:e.measureVisible}),t.createElement(h,{style:(o=e.style)==null?void 0:o.footer,mode:e.mode,footer:e==null?void 0:e.footer}))},oe=e=>{var o;const{stepList:n,step:r}=e,a=(o=E(n,r))==null?void 0:o.tool,m=g.isPointCloudTool(a),l=g.isVideoTool(a);return m?t.createElement(te,i({},e)):l?t.createElement(I,{drawLayerSlot:e.drawLayerSlot,footer:e.footer,annotationBefore:e==null?void 0:e.annotationBefore}):t.createElement(ee,i({},e))},f=e=>{var o,n,r;const{t:a}=J(),{stepList:m,step:l}=e,d=(o=E(m,l))==null?void 0:o.tool,s=![c.LLM,c.NLP].includes(d),v=![c.LLM,c.NLP].includes(d),L=[K.PointCloud].includes(d);return t.createElement(b,null,t.createElement(A,{spinning:e.loading,indicator:t.createElement(G,null),tip:t.createElement("span",{style:{marginTop:200}},a("LoadingTips")),delay:500},t.createElement(y,{className:R([u,e.className]),style:(n=e.style)==null?void 0:n.layout},t.createElement("header",{className:`${u}__header`,style:(r=e.style)==null?void 0:r.header},t.createElement(F,{header:e==null?void 0:e.header,headerName:e.headerName,goBack:e.goBack,exportData:e.exportData,hasLangNode:s,hasHeaderOption:v,hasPredictTrackingIcon:L})),e.children)))},ne=e=>{var o,n,r,a,m,l,d;const[s,v]=O(void 0),L=(n=(o=e.style)==null?void 0:o.sider)==null?void 0:n.width,{stepList:x,step:N}=e,_=(r=E(x,N))==null?void 0:r.tool,j=c.LLM===_,w=c.NLP===_,S=g.isAudioTool(_);return j?t.createElement(f,i({},e),t.createElement(U,i({},e))):w?t.createElement(f,i({},e),t.createElement(z,i({},e))):S?t.createElement(f,i({},e),t.createElement(q,i({},e))):t.createElement(f,i({},e),t.createElement(y,{className:H("layout","container")},e==null?void 0:e.leftSider,t.createElement(p,{className:`${u}__content`},t.createElement(oe,i({},e)),t.createElement(W,null)),t.createElement(Z,{className:`${u}__side`,width:(a=s!=null?s:L)!=null?a:240,style:(m=e.style)==null?void 0:m.sider},t.createElement(k,{sider:e==null?void 0:e.sider,enableColorPicker:e==null?void 0:e.enableColorPicker,setSiderWidth:v,propsSiderWidth:(d=(l=e.style)==null?void 0:l.sider)==null?void 0:d.width}))))},le=({annotation:e})=>{var o,n,r;const{imgList:a,loading:m}=e,l=(o=a[e.imgIndex])!=null?o:{};return{path:(r=(n=l==null?void 0:l.path)!=null?n:l==null?void 0:l.url)!=null?r:"",loading:m}};var ie=B(le,null,null,{context:D})(ne);export{ie as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import K from"../../../../components/attributeList/index.js";import M from"../../../../components/checkboxList/index.js";import{CaretRightOutlined as P}from"@ant-design/icons";import{Collapse as T,Tooltip as H,Badge as x}from"antd/es";import{cloneDeep as F}from"lodash";import
|
|
1
|
+
import K from"../../../../components/attributeList/index.js";import M from"../../../../components/checkboxList/index.js";import{CaretRightOutlined as P}from"@ant-design/icons";import{Collapse as T,Tooltip as H,Badge as x}from"antd/es";import{cloneDeep as F}from"lodash";import a,{useState as v,useRef as U,useEffect as p,useCallback as q}from"react";import z from"../../../../assets/annotation/common/icon_clearSmall.svg.js";import G from"../../../../assets/annotation/common/icon_clearSmall_a.svg.js";import{TagUtils as J}from"@labelbee/lb-annotation";import{connect as Q}from"react-redux";import{useTranslation as V}from"react-i18next";import{LabelBeeContext as W}from"../../../../store/ctx.js";const{Panel:X}=T,$=({isActive:n})=>a.createElement(P,{rotate:n?90:0}),Y=({toolInstance:n,imgIndex:N})=>{const[s,g]=v([]),i=U(null),[,j]=v(0),[w,f]=v(-1),{t:b}=V();p(()=>{var r,l;n&&(g((l=(r=n.config)==null?void 0:r.inputList)==null?void 0:l.map(e=>e.value)),n.singleOn("render",()=>{j(e=>e+1)}))},[n]),p(()=>{var r;if(n&&(n.singleOn("expend",O),((r=n==null?void 0:n.labelSelectedList)==null?void 0:r.length)===1)){let l=0;for(let e=0;e<n.labelSelectedList[0];e++)l+=46,o[e]&&s[e]!==""&&o[e].subSelected.forEach(t=>{l+=40});i.current&&(i.current.children[0].scrollTop=l)}}),p(()=>{i.current&&(i.current.children[0].scrollTop=0)},[N]);const O=()=>{var r;const l=n.labelSelectedList[0],e=(r=o.filter((t,m)=>m===l)[0])==null?void 0:r.value;h(l,e,!0)},h=q((r,l,e)=>{const t=F(s);t[r]===""||e===!0?t[r]=l:t[r]="",g(t)},[s]);if(!n)return null;const{labelSelectedList:u,config:{inputList:o},currentTagResult:c,setLabel:E}=n,A=r=>u.length>0&&u[0]===r?a.createElement("span",{className:"keyDownIconActive"},r+1):a.createElement("span",{className:"keyDownIcon"},r+1),y=(r,l=-1)=>r?r.map((e,t)=>{var m,_,L,k,C;if(e.subSelected){const R=J.judgeResultIsInInputList(e.value,(m=c==null?void 0:c.result)==null?void 0:m[e.value],o);return a.createElement(T,{bordered:!1,expandIcon:$,key:`collapse_${t}_${l+1}`,onChange:()=>h(t,e.value),activeKey:[s[t]]},a.createElement(X,{header:a.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",flex:1}},a.createElement("span",null,e.key,a.createElement(H,{placement:"bottom",title:b("ClearThisOption")},a.createElement("img",{style:{marginLeft:5,cursor:"pointer"},onClick:D=>{D.stopPropagation(),n.clearResult(!0,e.value)},src:w===t||R?G:z,onMouseEnter:()=>{f(t)},onMouseLeave:()=>{f(-1)}})),R&&s[t]===""&&a.createElement(x,{color:"#87d068"})),(o==null?void 0:o.length)>1&&A(t)),key:e.value},a.createElement("div",{className:"level",style:{backgroundColor:u.length>0&&u[0]===t?"rgba(158, 158, 158, 0.18)":""}},y(e.subSelected,t))))}const d=(o==null?void 0:o[l])?o==null?void 0:o[l].value:0,S=((k=(L=(_=c==null?void 0:c.result)==null?void 0:_[d])==null?void 0:L.split(";"))==null?void 0:k.indexOf(e.value))>-1?e.value:"";return((C=o==null?void 0:o[l])==null?void 0:C.isMulti)===!0?a.createElement("div",{className:"singleBar",key:`${d}_${l}_${t}`},a.createElement(M,{attributeChanged:()=>E(l,t),selectedAttribute:[S],list:[{value:e.value,label:e.key}],num:t+1})):a.createElement("div",{className:"singleBar",key:`${d}_${l}_${t}`},a.createElement(K,{forbidColor:!0,attributeChanged:()=>E(l,t),selectedAttribute:S,list:[{value:e.value,label:e.key}],num:t+1}))}):null,B=window.innerHeight-61-80;return a.createElement("div",{className:"tagOperationMenu",ref:i},(o==null?void 0:o.length)===0?a.createElement("div",{style:{padding:20,textAlign:"center"}},b("NoConfiguration")):a.createElement("div",{className:"main",style:{height:B}},y(o)))};function Z(n){return{toolInstance:n.annotation.toolInstance,imgIndex:n.annotation.imgIndex}}var I=Q(Z,null,null,{context:W})(Y);export{I as default,$ as expandIconFuc};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import o,{useState as
|
|
1
|
+
import o,{useState as d,useEffect as h,useRef as I}from"react";import{connect as M}from"react-redux";import{cloneDeep as z}from"lodash";import{classnames as S}from"../../../../utils/index.js";import{Switch as W,Input as J}from"antd/es";import{cKeyCode as G,cTool as H}from"@labelbee/lb-annotation";import{PageForward as Q}from"../../../../store/annotation/actionCreators.js";import{ConfigUtils as X}from"../../../../utils/ConfigUtils.js";import{useTranslation as A}from"react-i18next";import{LabelBeeContext as Y}from"../../../../store/ctx.js";var Z=Object.defineProperty,K=Object.getOwnPropertySymbols,ee=Object.prototype.hasOwnProperty,te=Object.prototype.propertyIsEnumerable,$=(e,t,r)=>t in e?Z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ne=(e,t)=>{for(var r in t||(t={}))ee.call(t,r)&&$(e,r,t[r]);if(K)for(var r of K(t))te.call(t,r)&&$(e,r,t[r]);return e};const j=G.default,{EVideoToolName:oe}=H,V=e=>{e.stopPropagation(),e.nativeEvent.stopPropagation(),e.nativeEvent.stopImmediatePropagation()},D=e=>{const{textareaProps:t,footer:r}=e;return o.createElement(o.Fragment,null,o.createElement(J.TextArea,ne({key:`${t.id}-${t.defaultValue}`,bordered:!1,rows:6,onKeyDown:V,onKeyUp:V},t)),o.createElement("div",{className:S({textAreaLength:!0})},r))},q=e=>{var t;const r=I(null),[E,f]=d(!1),[N,P]=d(!1),{t:w}=A(),{disabled:s,config:i,result:m,updateText:p,index:u,switchToNextTextarea:y,hasMultiple:L,onNext:b}=e,{maxLength:g}=i,c=m?m[i.key]:"",[_,C]=d((t=c==null?void 0:c.length)!=null?t:0);h(()=>{var n;C((n=c==null?void 0:c.length)!=null?n:0)},[c]);const v=(n,T)=>{p&&(p(n,i.key,T),i.required&&P(!n))},x=L&&y,k={id:`textInput-${u}`,ref:r,disabled:s,defaultValue:c,maxLength:g,autoSize:{minRows:2,maxRows:6},onChange:n=>{const T=n.target.value;C(n.target.value.length),v(T,!1)},onFocus:()=>{f(!0)},onBlur:n=>{f(!1),v(n.target.value,!0),i.required&&P(!n.target.value)},style:{resize:"none",wordBreak:"break-all"},onKeyDownCapture:n=>{n.ctrlKey&&n.keyCode===j.Enter&&(b&&b(),n.preventDefault()),n.keyCode===j.Tab&&x&&(n.preventDefault(),n.nativeEvent.stopImmediatePropagation(),y(u)),n.nativeEvent.stopPropagation()}},F=o.createElement("div",{className:"textAreaFooter"},o.createElement("div",{className:"hotkeyTip"},x&&o.createElement("span",null,`[${w("Switch")}]Tab`),o.createElement("span",null,`[${w("TurnPage")}]Ctrl+Enter`)),o.createElement("div",{className:"wordCount"},o.createElement("span",{className:_>=g?"warning":""},_),"/",o.createElement("span",null,g)));return h(()=>{s&&f(!1)},[s]),o.createElement("div",{className:"textField"},o.createElement("div",{className:"label"},o.createElement("span",{className:S({required:i.required})},i.label),o.createElement("i",{className:S({clearText:!0,disabled:s}),onClick:()=>{s||v("",!0)}})),o.createElement("div",{className:S({disabled:s,"textarea-outline":!0,"ant-input-focused":E,textareaContainer:!0,focus:E,invalid:N})},o.createElement(D,{footer:F,textareaProps:k})))},ae=({toolInstance:e,imgIndex:t,dispatch:r,triggerEventAfterIndexChanged:E,step:f,stepList:N,basicResultList:P,disabled:w})=>{var s,i,m,p;const[u,y]=d([]),[L,b]=d(0),[g,c]=d(!0),[,_]=d(0),{t:C}=A(),v=a=>{const l=(a+1)%u.length;x(l)},x=a=>{setTimeout(()=>{const l=document.getElementById(`textInput-${a}`);l&&(b(a),l.focus(),l.select(),l.scrollIntoView({behavior:"smooth",block:"center"}))})};h(()=>{e&&e.singleOn("valueUpdated",()=>{_(a=>a+1)})},[e]),h(()=>{var a;e&&y(z((a=e==null?void 0:e.config)==null?void 0:a.configList))},[JSON.stringify((s=e==null?void 0:e.config)==null?void 0:s.configList)]);const k=(p=(m=(i=e==null?void 0:e.textList)==null?void 0:i[0])==null?void 0:m.value)!=null?p:{},F=(a,l,U=!1)=>{var O,R;(R=e==null?void 0:e.updateTextValue)==null||R.call(e,l,a,U,(O=e==null?void 0:e.textList)==null?void 0:O[0])};h(()=>{t>-1&&E&&x(0)},[t]);const n=()=>{r(Q(!0))},T=a=>{c(a),e==null||e.toggleShowText(a)},B=X.getStepConfig(N,f).tool===oe.VideoTextTool;return e&&o.createElement("div",{className:"textToolOperationMenu"},u==null?void 0:u.map((a,l)=>o.createElement(q,{config:a,key:a.key,index:l,result:k,updateText:F,switchToNextTextarea:v,hasMultiple:u.length>1,focus:L===l,onNext:n,disabled:w})),B&&o.createElement("div",{className:"textToolSwitchItem"},C("toggleShowText"),o.createElement(W,{style:{alignSelf:"center"},checked:g,onChange:a=>{T(a)}})))};function re(e){return{toolInstance:e.annotation.toolInstance,imgIndex:e.annotation.imgIndex,step:e.annotation.step,basicResultList:e.annotation.basicResultList,stepList:e.annotation.stepList,triggerEventAfterIndexChanged:e.annotation.triggerEventAfterIndexChanged}}var le=M(re,null,null,{context:Y})(ae);export{q as SingleTextInput,D as TextareaWithFooter,le as default};
|