@nocobase/plugin-block-workbench 1.7.0-beta.9 → 1.8.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +0,0 @@
1
- /**
2
- * This file is part of the NocoBase (R) project.
3
- * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
- * Authors: NocoBase Team.
5
- *
6
- * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
- * For more information, please refer to: https://www.nocobase.com/agreement.
8
- */
9
-
10
- "use strict";(self.webpackChunk_nocobase_plugin_block_workbench=self.webpackChunk_nocobase_plugin_block_workbench||[]).push([["713"],{192:function(e,t,n){n.r(t),n.d(t,{QRCodeScanner:function(){return k},QRCodeScannerInner:function(){return S}});var r=n("482"),o=n("772"),i=n("738"),l=n("156"),a=n.n(l),c=n("238");function u(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}function s(e){var t=e.style,n={position:"absolute",backgroundColor:"rgb(255, 255, 255)"};return a().createElement("div",{id:"qr-scan-box",style:u({boxSizing:"border-box",inset:"0px"},void 0===t?{}:t)},a().createElement("div",{style:u({width:"40px",height:"5px",top:"-5px",left:"0px"},n)}),a().createElement("div",{style:u({width:"40px",height:"5px",top:"-5px",right:"0px"},n)}),a().createElement("div",{style:u({width:"40px",height:"5px",bottom:"-5px",left:"0px"},n)}),a().createElement("div",{style:u({width:"40px",height:"5px",bottom:"-5px",right:"0px"},n)}),a().createElement("div",{style:u({width:"5px",height:"45px",top:"-5px",left:"-5px"},n)}),a().createElement("div",{style:u({width:"5px",height:"45px",bottom:"-5px",left:"-5px"},n)}),a().createElement("div",{style:u({width:"5px",height:"45px",top:"-5px",right:"-5px"},n)}),a().createElement("div",{style:u({width:"5px",height:"45px",bottom:"-5px",right:"-5px"},n)}))}var f=n("58"),h=n.n(f),p=n("128");function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function m(e,t,n,r,o,i,l){try{var a=e[i](l),c=a.value}catch(e){n(e);return}a.done?t(c):Promise.resolve(c).then(r,o)}function b(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){m(i,r,o,l,a,"next",e)}function a(e){m(i,r,o,l,a,"throw",e)}l(void 0)})}}function y(e,t){var n,r,o,i,l={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw TypeError("Generator is already executing.");for(;l;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return l.label++,{value:i[1],done:!1};case 5:l.label++,r=i[1],i=[0];continue;case 7:i=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){l=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){l.label=i[1];break}if(6===i[0]&&l.label<o[1]){l.label=o[1],o=i;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(i);break}o[2]&&l.ops.pop(),l.trys.pop();continue}i=t.call(e,l)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function g(e,t){return e.startsWith(t)?e.slice(t.length):e}function v(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function x(e,t,n,r,o,i,l){try{var a=e[i](l),c=a.value}catch(e){n(e);return}a.done?t(c):Promise.resolve(c).then(r,o)}function w(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],l=!0,a=!1;try{for(o=o.call(e);!(l=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);l=!0);}catch(e){a=!0,r=e}finally{try{!l&&null!=o.return&&o.return()}finally{if(a)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return v(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return v(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var E="qrcode",S=function(e){var t,n,u,f,m,v,x,S,k,O,A,C,j,I,z,M,P,T,N,W=(0,l.useRef)(),R=(0,l.useRef)(),_=(0,c.useTranslation)("block-workbench").t,F=w((0,l.useState)({width:0,height:0}),2),H=F[0],B=F[1],D=Math.max(document.documentElement.clientWidth||0,window.innerWidth||0),Q=Math.max(document.documentElement.clientHeight||0,window.innerHeight||0);var q=(n=(t={onScannerSizeChanged:B,elementId:E}).onScannerSizeChanged,u=t.elementId,f=(0,o.useApp)().pm.get(h()).mobileRouter.basename.replace(/\/+$/,""),S=(x=(m=(0,l.useState)(),v=2,function(e){if(Array.isArray(e))return e}(m)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],l=!0,a=!1;try{for(o=o.call(e);!(l=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);l=!0);}catch(e){a=!0,r=e}finally{try{!l&&null!=o.return&&o.return()}finally{if(a)throw r}}return i}}(m,2)||function(e,t){if(e){if("string"==typeof e)return d(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return d(e,t)}}(m,v)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()))[0],k=x[1],O=(0,p.useNavigate)(),A=(0,c.useTranslation)("block-workbench").t,C=(0,l.useMemo)(function(){return{width:Math.max(document.documentElement.clientWidth||0,window.innerWidth||0),height:Math.max(document.documentElement.clientHeight||0,window.innerHeight||0)}},[]),I=(0,l.useCallback)((j=b(function(e){return y(this,function(t){return[2,e.start({facingMode:"environment"},{fps:10,qrbox:function(e,t){return n({width:e,height:t}),{width:C.width,height:C.height}}},function(e){O(g(e,f))},void 0)]})}),function(e){return j.apply(this,arguments)}),[O,n,C,f]),M=(0,l.useCallback)((z=b(function(e){var t;return y(this,function(n){return(t=e.getState(),[i.lz.SCANNING,i.lz.PAUSED].includes(t))?[2,e.stop()]:[2]})}),function(e){return z.apply(this,arguments)}),[]),T=(0,l.useCallback)((P=b(function(e){var t;return y(this,function(t){switch(t.label){case 0:return[4,M(S)];case 1:t.sent(),t.label=2;case 2:return t.trys.push([2,4,,5]),[4,S.scanFileV2(e,!1)];case 3:return O(g(t.sent().decodedText,f)),[3,5];case 4:return t.sent(),alert(A("QR code recognition failed, please scan again")),I(S),[3,5];case 5:return[2]}})}),function(e){return P.apply(this,arguments)}),[M,S,O,f,A,I]),(0,l.useEffect)(function(){var e=new i.t2(u);return k(e),I(e),function(){M(e)}},[u,I,M]),{startScanCamera:I,startScanFile:T}).startScanFile,G=function(){R.current&&R.current.click()},U=function(e){var t=e.target.files;if(t.length>0){var n=t[0];n.size<1e6?q(n):alert(_("The image size is too large. Please compress it to below 1MB before uploading"))}};(0,l.useEffect)(function(){return document.documentElement.style.overscrollBehavior="none",function(){document.documentElement.style.overscrollBehavior="default"}},[]),(0,l.useEffect)(function(){var e=H.width,t=H.height,n=Math.max(document.documentElement.clientWidth||0,window.innerWidth||0),r=Math.max(document.documentElement.clientHeight||0,window.innerHeight||0);if(e>0&&t>0&&t<r){var o=Math.floor(r/t*e),i=document.getElementsByTagName("video")[0];i.style.height="".concat(r,"px"),i.style.width="".concat(o,"px"),W.current.style.left="".concat((n-o)/2,"px"),W.current.style.position="absolute"}},[H]);var $={zIndex:"1003",fontSize:"1.8em",fontWeight:"bold"};return a().createElement(a().Fragment,null,a().createElement("div",{ref:W,id:E,style:{position:"absolute"}}),a().createElement(s,{style:function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}({},(N=Math.floor(.6*Math.min(D,Q)),{left:"".concat((D-N)/2,"px"),top:"".concat((Q-N)/2,"px"),position:"fixed",width:"".concat(N,"px"),height:"".concat(N,"px")}))}),a().createElement(function(){return a().createElement("div",{style:{position:"absolute",bottom:"20px",left:"20px",padding:"10px 60px"}},a().createElement("div",{style:{color:"white",width:"40px",display:"flex",flexDirection:"column",alignItems:"center"}},a().createElement(r.FileImageOutlined,{style:$,onClick:G}),_("Album"),a().createElement("input",{ref:R,type:"file",accept:"image/*",onChange:U,style:{visibility:"hidden"}})))},null))},k=function(e){var t=(0,o.useActionContext)(),n=t.visible,u=t.setVisible,s=w((0,l.useState)(!1),2),f=s[0],h=s[1],p=(0,c.useTranslation)("block-workbench").t;return(0,l.useEffect)(function(){var e,t,r=(t=(e=function(){var e,t,n;return function(e,t){var n,r,o,i,l={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw TypeError("Generator is already executing.");for(;l;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return l.label++,{value:i[1],done:!1};case 5:l.label++,r=i[1],i=[0];continue;case 7:i=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){l=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){l.label=i[1];break}if(6===i[0]&&l.label<o[1]){l.label=o[1],o=i;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(i);break}o[2]&&l.ops.pop(),l.trys.pop();continue}i=t.call(e,l)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,i.t2.getCameras()];case 1:return 0===r.sent().length?alert(p("No camera device detected")):h(!0),[3,3];case 2:return e=r.sent(),t={NotFoundError:p("No camera device detected"),NotAllowedError:p("You have not granted permission to use the camera")},console.log(e),alert(null!=(n=t[e.name])?n:e),h(!1),u(!1),[3,3];case 3:return[2]}})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){x(i,r,o,l,a,"next",e)}function a(e){x(i,r,o,l,a,"throw",e)}l(void 0)})}),function(){return t.apply(this,arguments)});n&&!f&&r()},[n,f,u,p]),n&&f?a().createElement("div",{style:{position:"fixed",width:"100%",height:"100%",background:"black",zIndex:"1001",top:0,left:0,overflow:"hidden"}},a().createElement(S,null),a().createElement(r.LeftOutlined,{style:{position:"absolute",top:"22px",left:"20px",zIndex:"1003",color:"white",fontSize:"1.8em",fontWeight:"bold"},onClick:function(){return u(!1)}}),a().createElement("div",{style:{position:"absolute",color:"white",fontSize:"1.5em",left:0,right:0,top:"20px",zIndex:"1002",marginLeft:"auto",marginRight:"auto",textAlign:"center"}},p("Scan QR code"))):null}}}]);