@corva/ui 0.33.0-14 → 0.33.0-15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"@babel/runtime/helpers/defineProperty";import r from"@babel/runtime/helpers/classCallCheck";import t from"@babel/runtime/regenerator";import i from"@babel/runtime/helpers/asyncToGenerator";import{isNativeDetected as o}from"../utils/mobileDetect.js";import{jsxs as n,jsx as l,Fragment as s}from"react/jsx-runtime";import{createRef as a,PureComponent as p}from"react";import u from"@babel/runtime/helpers/createClass";import{getS3DownloadLink as c,getS3SignedUrl as d}from"../clients/jsonApi/index.js";import f from"prop-types";import{withStyles as m}from"@material-ui/core/styles";import h from"@babel/runtime/helpers/assertThisInitialized";import b from"@babel/runtime/helpers/inherits";import g from"@babel/runtime/helpers/possibleConstructorReturn";import F from"@babel/runtime/helpers/getPrototypeOf";import v from"./IconButton/index.js";import U from"react-s3-uploader/s3upload";import y from"@material-ui/core/CircularProgress";import P from"@material-ui/icons/PhotoCamera";import S from"./PostPreviewDialog/index.js";import w from"./Icons/AttachIcon.js";function O(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,i)}return t}function D(r){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?O(Object(i),!0).forEach((function(t){e(r,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(i)):O(Object(i)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(i,e))}))}return r}function j(e){var r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var t,i=F(e);if(r){var o=F(this).constructor;t=Reflect.construct(i,arguments,o)}else t=i.apply(this,arguments);return g(this,t)}}var I=function(f){b(g,p);var m=j(g);function g(o){var n,l;return r(this,g),n=m.call(this,o),e(h(n),"onFinish",i(t.mark((function e(){return t.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n.setState({currentUpload:null,uploadingFileToS3:!1,openFileUploadPreviewDialog:n.props.openPreviewDialogOnUpload},(function(){n.props.onFinish&&
|
|
1
|
+
import e from"@babel/runtime/helpers/defineProperty";import r from"@babel/runtime/helpers/classCallCheck";import t from"@babel/runtime/regenerator";import i from"@babel/runtime/helpers/asyncToGenerator";import{isNativeDetected as o}from"../utils/mobileDetect.js";import{jsxs as n,jsx as l,Fragment as s}from"react/jsx-runtime";import{createRef as a,PureComponent as p}from"react";import u from"@babel/runtime/helpers/createClass";import{getS3DownloadLink as c,getS3SignedUrl as d}from"../clients/jsonApi/index.js";import f from"prop-types";import{withStyles as m}from"@material-ui/core/styles";import h from"@babel/runtime/helpers/assertThisInitialized";import b from"@babel/runtime/helpers/inherits";import g from"@babel/runtime/helpers/possibleConstructorReturn";import F from"@babel/runtime/helpers/getPrototypeOf";import v from"./IconButton/index.js";import U from"react-s3-uploader/s3upload";import y from"@material-ui/core/CircularProgress";import P from"@material-ui/icons/PhotoCamera";import S from"./PostPreviewDialog/index.js";import w from"./Icons/AttachIcon.js";function O(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,i)}return t}function D(r){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?O(Object(i),!0).forEach((function(t){e(r,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(i)):O(Object(i)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(i,e))}))}return r}function j(e){var r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var t,i=F(e);if(r){var o=F(this).constructor;t=Reflect.construct(i,arguments,o)}else t=i.apply(this,arguments);return g(this,t)}}var I=function(f){b(g,p);var m=j(g);function g(o){var n,l;return r(this,g),n=m.call(this,o),e(h(n),"onFinish",i(t.mark((function e(){var r;return t.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,c(n.state.s3FileName);case 2:r=e.sent,n.setState({currentUpload:null,uploadingFileToS3:!1,openFileUploadPreviewDialog:n.props.openPreviewDialogOnUpload,s3FileUrl:r.url},(function(){n.props.onFinish&&n.props.onFinish(n.state.s3FileUrl,n.state.s3FileName,n.state.s3FileSize)}));case 4:case"end":return e.stop()}}),e)})))),e(h(n),"onError",(function(e){n.props.onError&&n.props.onError(e),console.error(e)})),e(h(n),"getSignedUrl",(l=i(t.mark((function e(r,i){var o;return t.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,d(r.name,r.type);case 3:o=e.sent,e.next=10;break;case 6:return e.prev=6,e.t0=e.catch(0),n.setState({uploadingFileToS3:null,currentUpload:null},(function(){n.onError(e.t0.message)})),e.abrupt("return");case 10:n.setState({s3FileUrl:o.signed_url,s3FileName:o.file_name,s3FileSize:r.size}),i(D(D({},o),{},{signedUrl:o.signed_url}));case 12:case"end":return e.stop()}}),e,null,[[0,6]])}))),function(e,r){return l.apply(this,arguments)})),e(h(n),"preprocess",(function(e,r){r(e)})),e(h(n),"uploadFile",(function(e){if(e.target.files[0]){n.clearUpload();var r=new U({fileElement:n.fileInput.current,getSignedUrl:n.getSignedUrl,preprocess:n.preprocess,onProgress:function(){},onFinishS3Put:n.onFinish,onError:n.onError});n.setState({uploadingFileToS3:!0,currentUpload:{uploader:r}})}})),e(h(n),"handleCloseFileUploadPreviewDialog",(function(){n.setState({openFileUploadPreviewDialog:!1})})),e(h(n),"handleShare",(function(e,r,t){n.setState({openFileUploadPreviewDialog:!1},(function(){n.props.handleShare&&n.props.handleShare(e,r,t)}))})),n.state={currentUpload:null,s3FileUrl:null,s3FileName:null,s3FileSize:null,uploadingFileToS3:!1,openFileUploadPreviewDialog:!1},n.fileInput=a(),n}return u(g,[{key:"clearUpload",value:function(){var e=this.state.currentUpload;e&&e.uploader&&e.uploader.abortUpload()}},{key:"renderUploadButton",value:function(){var e=o?P:w;return n("label",{htmlFor:this.props.inputId,children:[l("input",{ref:this.fileInput,id:this.props.inputId,type:"file",disabled:this.props.disabled,onChange:this.uploadFile,style:{display:"none"}}),l(v,{"data-testid":"".concat("fileUpload","_attachFileButton"),"aria-label":"File Upload",disabled:this.props.disabled,component:this.props.disabled?"button":"span",className:this.props.fileUploadIconClassName,disableRipple:this.props.disableRipple,tooltipProps:{title:"Attach File"},children:l(e,{})})]})}},{key:"render",value:function(){return n(s,{children:[this.state.uploadingFileToS3?l(y,{"data-testid":"generic_uploadProgress",classes:{root:this.props.classes.progressRoot},size:20}):this.renderUploadButton(),this.state.openFileUploadPreviewDialog&&l(S,{open:this.state.openFileUploadPreviewDialog,fileUrl:this.state.s3FileUrl,fileName:this.state.s3FileName,fileSize:this.state.s3FileSize,handleShare:this.handleShare,handleClose:this.handleCloseFileUploadPreviewDialog,additionalFields:this.props.additionalFields,requiredFields:this.props.requiredFields,message:this.props.message})]})}}]),g}();I.propTypes={additionalFields:f.arrayOf(f.node),classes:f.shape({}).isRequired,disableRipple:f.bool,disabled:f.bool,fileUploadIconClassName:f.string,handleShare:f.func,inputId:f.string,message:f.string,onError:f.func,onFinish:f.func,openPreviewDialogOnUpload:f.bool,requiredFields:f.arrayOf(f.string)},I.defaultProps={additionalFields:[],disableRipple:!1,disabled:!1,fileUploadIconClassName:void 0,handleShare:void 0,inputId:"icon-button-file",message:void 0,onError:void 0,onFinish:void 0,openPreviewDialogOnUpload:!0,requiredFields:[]};var C=m({progressRoot:{margin:14,marginTop:20}})(I);export default C;
|