@corva/ui 0.63.0-rc.7 → 0.63.0-rc.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";var e=require("@babel/runtime/helpers/slicedToArray"),t=require("react"),a=require("prop-types"),i=require("react-player"),r=require("@material-ui/core/styles"),s=require("@material-ui/core/Typography"),l=require("@material-ui/core"),n=require("@material-ui/icons/Image"),o=require("@material-ui/icons/SaveAlt"),c=require("@material-ui/icons/Fullscreen"),d=require("@material-ui/core/colors/grey"),u=require("../FileTypeIcon.js"),m=require("../ImageViewer/index.js"),h=require("../GoogleDocsViewer/index.js"),p=require("../IconButton/index.js"),g=require("../../utils/mobileDetect.js"),f=require("../../utils/fileExtension.js");require("@babel/runtime/helpers/asyncToGenerator"),require("@babel/runtime/helpers/defineProperty"),require("@babel/runtime/regenerator"),require("querystring"),require("uuid/v1"),require("lodash"),require("../../clients/jsonApi/index.js"),require("../../clients/subscriptions.js"),require("../../constants/goals.js"),require("../../constants/segment.js"),require("../../constants/alerts.js"),require("../../constants/apps.js"),require("../../constants/drillstring.js"),require("../../constants/completion.js"),require("../../constants/notifications.js"),require("../../constants/feed.js"),require("../../constants/bha.js"),require("../../utils/env.js"),require("../GradientManager/configuration/constants.js");var q=require("../../effects/useSignedURL.js");require("../../utils/index.js"),require("uuid"),require("jsona"),require("../StatusBadge/constants.js"),require("@babel/runtime/helpers/toConsumableArray"),require("lodash/set"),require("lodash/get"),require("lodash/unset"),require("moment"),require("../../clients/api/apiCore.js"),require("../../clients/constants.js");var x=require("../../utils/main.js"),j=require("./styles.css.js"),v=require("react/jsx-runtime");function b(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var N=b(e),w=b(a),y=b(i),I=b(s),A=b(n),F=b(o),P=b(c),S=b(d),D=S.default[200],L=S.default[400],W={label:"small",value:135},z={label:"medium",value:300},C={fileImage:function(e,t){return{maxWidth:"100%",borderRadius:4,overflow:"hidden",maxHeight:t===W.label?W.value:z.value,display:e?"initial":"none",cursor:"pointer"}},fileDownloadWrapper:{padding:"10px 10px 10px 5px",border:"1px solid #616161",borderRadius:3,maxWidth:500,width:"75%"},imagePlaceholder:{position:"relative",backgroundColor:D,borderRadius:3,marginTop:10,height:135,width:135}},U=function(e){return v.jsxs(v.Fragment,{children:[v.jsxs("div",{onClick:e.openLightbox,className:j.cAttachmentImg,children:[v.jsx("img",{"data-testid":"".concat("Attachment","_image"),src:e.attachmentUrl,style:C.fileImage(e.imageIsLoaded,e.size),alt:"Attachment",onLoad:e.setImageIsLoaded}),v.jsx("div",{"data-testid":"".concat("Attachment","_button"),className:j.cAttachmentImgPreviwBtn,children:v.jsx(P.default,{})})]}),!e.imageIsLoaded&&v.jsx("div",{style:C.imagePlaceholder,children:v.jsx(A.default,{"data-testid":"".concat("Attachment","_placeholder"),className:e.classes.imageIconRoot,htmlColor:L,fontSize:"large"})}),e.lightboxIsOpen&&v.jsx(m,{mainSrc:e.attachmentUrl,imagePadding:50,onAfterOpen:e.handleLightboxOpen,onCloseRequest:e.handleLightboxClose})]})},R=function(e){var t=q(e.attachmentFileName);return v.jsxs("div",{className:j.cAttachmentFileWrapper,children:[v.jsxs("div",{className:j.cAttachmentFileDownloadWrapper,style:C.fileDownloadWrapper,onClick:e.openPreview,children:[v.jsx(u,{fileName:e.displayName||e.attachmentUrl,className:j.cAttachmentFileDownloadWrapperFileIcon,size:e.small?25:50}),v.jsx("div",{"data-testid":"".concat("Attachment","_name"),className:j.cAttachmentFileDownloadWrapperFileName,children:v.jsx(I.default,{variant:"subtitle2",noWrap:!0,className:e.classes.fileName,children:x.getFileNameWithExtensionFromPath(e.displayName||e.attachmentUrl)})}),v.jsx(l.Dialog,{open:e.previewIsOpen,onClose:e.closePreview,classes:{root:e.classes.dialogRoot,paper:g.isNativeDetected?e.classes.nativeDialog:e.classes.dialog},onClick:e.closePreview,children:v.jsx(h,{fileUrl:t,fileName:x.getFileNameWithExtensionFromPath(e.displayName||e.attachmentUrl),fileSize:e.attachmentSize,onClose:e.closePreview,width:"100%",height:"100%"})})]}),v.jsx("a",{download:e.displayName,href:t,className:j.cAttachmentFileDownloadWrapperForm,children:v.jsx(p,{"data-testid":"".concat("Attachment","_downloadButton"),className:e.classes.downloadIcon,type:"submit",children:v.jsx(F.default,{className:e.classes.downloadIcon})})})]})};function O(e){var a=t.useState(!1),i=N.default(a,2),r=i[0],s=i[1],l=t.useState(!1),n=N.default(l,2),o=n[0],c=n[1],d=t.useState(!1),u=N.default(d,2),m=u[0],h=u[1],p=e.displayName||e.attachmentUrl||e.fileName,x=f.getIsImage(p),b=f.getIsVideo(p),w=q(!e.attachmentUrl&&e.fileName),I=e.attachmentUrl||w,A=t.useCallback((function(e){return e.preventDefault()}),[]);return x?v.jsx("div",{className:j.cAttachment,children:v.jsx(U,{size:e.size,openLightbox:function(){return c(!0)},attachmentUrl:I,setImageIsLoaded:function(){return s(!0)},imageIsLoaded:r,lightboxIsOpen:o,handleLightboxOpen:function(){g.isNativeDetected&&document.documentElement.addEventListener("touchmove",A,{passive:!1})},handleLightboxClose:function(){g.isNativeDetected&&document.documentElement.removeEventListener("touchmove",A),c(!1)},classes:e.classes})}):b&&y.default.canPlay(I)?v.jsx("div",{className:j.cAttachment,children:v.jsx(y.default,{"data-testid":"".concat("Attachment","_player"),className:j.cAttachmentReactPlayer,url:I,config:{file:{attributes:{preload:"metadata"}}},controls:!0,height:e.size===W.label?W.value:z.value,width:null})}):v.jsx("div",{className:j.cAttachment,children:v.jsx(R,{attachmentUrl:I,attachmentFileName:e.fileName,attachmentSize:e.attachmentSize,displayName:e.displayName,openPreview:function(){return h(!0)},closePreview:function(e){e.stopPropagation(),h(!1)},previewIsOpen:m,classes:e.classes,small:e.small})})}O.propTypes={attachmentUrl:w.default.string.isRequired,attachmentSize:w.default.number,displayName:w.default.string,fileName:w.default.string,size:w.default.oneOf([W.label,z.label]),classes:w.default.shape({}).isRequired,small:w.default.bool},O.defaultProps={displayName:null,fileName:null,attachmentSize:void 0,size:z.label,small:!1};var E=r.withStyles((function(e){return{imageIconRoot:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)"},dialog:{width:"95%",height:"95%",maxWidth:"100%",position:"relative"},nativeDialog:{width:"100%",height:"100%",maxWidth:"100%",maxHeight:"100%",margin:0},dialogRoot:{backgroundColor:"rgba(0, 0, 0, 0.85)"},fileName:{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",fontWeight:400},downloadIcon:{color:e.palette.primary.text3}}}))(O);module.exports=E;
1
+ "use strict";var e=require("@babel/runtime/helpers/slicedToArray"),t=require("react"),a=require("prop-types"),i=require("react-player"),s=require("@material-ui/core/styles"),r=require("@material-ui/core/Typography"),l=require("@material-ui/core"),n=require("@material-ui/icons/Image"),o=require("@material-ui/icons/SaveAlt"),c=require("@material-ui/icons/Fullscreen"),d=require("@material-ui/core/colors/grey"),u=require("../FileTypeIcon.js"),m=require("../ImageViewer/index.js"),h=require("../GoogleDocsViewer/index.js"),p=require("../IconButton/index.js"),g=require("../../utils/mobileDetect.js"),f=require("../../utils/fileExtension.js");require("@babel/runtime/helpers/asyncToGenerator"),require("@babel/runtime/helpers/defineProperty"),require("@babel/runtime/regenerator"),require("querystring"),require("uuid/v1"),require("lodash"),require("../../clients/jsonApi/index.js"),require("../../clients/subscriptions.js"),require("../../constants/goals.js"),require("../../constants/segment.js"),require("../../constants/alerts.js"),require("../../constants/apps.js"),require("../../constants/drillstring.js"),require("../../constants/completion.js"),require("../../constants/notifications.js"),require("../../constants/feed.js"),require("../../constants/bha.js"),require("../../utils/env.js"),require("../GradientManager/configuration/constants.js");var q=require("../../effects/useSignedURL.js");require("../../utils/index.js"),require("uuid"),require("jsona"),require("../StatusBadge/constants.js"),require("@babel/runtime/helpers/toConsumableArray"),require("lodash/set"),require("lodash/get"),require("lodash/unset"),require("moment"),require("../../clients/api/apiCore.js"),require("../../clients/constants.js");var x=require("../../utils/main.js"),j=require("./styles.css.js"),v=require("react/jsx-runtime");function b(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var N=b(e),w=b(a),y=b(i),I=b(r),A=b(n),F=b(o),P=b(c),S=b(d),D=S.default[200],L=S.default[400],W={label:"small",value:135},z={label:"medium",value:300},C={fileImage:function(e,t){return{maxWidth:"100%",borderRadius:4,overflow:"hidden",maxHeight:t===W.label?W.value:z.value,display:e?"initial":"none",cursor:"pointer"}},fileDownloadWrapper:{padding:"10px 10px 10px 5px",border:"1px solid #616161",borderRadius:3,maxWidth:500,width:"75%"},imagePlaceholder:{position:"relative",backgroundColor:D,borderRadius:3,marginTop:10,height:135,width:135}},R=function(e){var t=q(e.attachmentFileName);return v.jsxs(v.Fragment,{children:[v.jsxs("div",{onClick:e.openLightbox,className:j.cAttachmentImg,children:[v.jsx("img",{"data-testid":"".concat("Attachment","_image"),src:t,style:C.fileImage(e.imageIsLoaded,e.size),alt:"Attachment",onLoad:e.setImageIsLoaded}),v.jsx("div",{"data-testid":"".concat("Attachment","_button"),className:j.cAttachmentImgPreviwBtn,children:v.jsx(P.default,{})})]}),!e.imageIsLoaded&&v.jsx("div",{style:C.imagePlaceholder,children:v.jsx(A.default,{"data-testid":"".concat("Attachment","_placeholder"),className:e.classes.imageIconRoot,htmlColor:L,fontSize:"large"})}),e.lightboxIsOpen&&v.jsx(m,{mainSrc:t,imagePadding:50,onAfterOpen:e.handleLightboxOpen,onCloseRequest:e.handleLightboxClose})]})},U=function(e){var t=q(e.attachmentFileName);return v.jsxs("div",{className:j.cAttachmentFileWrapper,children:[v.jsxs("div",{className:j.cAttachmentFileDownloadWrapper,style:C.fileDownloadWrapper,onClick:e.openPreview,children:[v.jsx(u,{fileName:e.displayName||e.attachmentUrl,className:j.cAttachmentFileDownloadWrapperFileIcon,size:e.small?25:50}),v.jsx("div",{"data-testid":"".concat("Attachment","_name"),className:j.cAttachmentFileDownloadWrapperFileName,children:v.jsx(I.default,{variant:"subtitle2",noWrap:!0,className:e.classes.fileName,children:x.getFileNameWithExtensionFromPath(e.displayName||e.attachmentUrl)})}),v.jsx(l.Dialog,{open:e.previewIsOpen,onClose:e.closePreview,classes:{root:e.classes.dialogRoot,paper:g.isNativeDetected?e.classes.nativeDialog:e.classes.dialog},onClick:e.closePreview,children:v.jsx(h,{fileUrl:t,fileName:x.getFileNameWithExtensionFromPath(e.displayName||e.attachmentUrl),fileSize:e.attachmentSize,onClose:e.closePreview,width:"100%",height:"100%"})})]}),v.jsx("a",{download:e.displayName,href:t,className:j.cAttachmentFileDownloadWrapperForm,children:v.jsx(p,{"data-testid":"".concat("Attachment","_downloadButton"),className:e.classes.downloadIcon,type:"submit",children:v.jsx(F.default,{className:e.classes.downloadIcon})})})]})};function O(e){var a=t.useState(!1),i=N.default(a,2),s=i[0],r=i[1],l=t.useState(!1),n=N.default(l,2),o=n[0],c=n[1],d=t.useState(!1),u=N.default(d,2),m=u[0],h=u[1],p=e.displayName||e.attachmentUrl||e.fileName,x=f.getIsImage(p),b=f.getIsVideo(p),w=q(!e.attachmentUrl&&e.fileName),I=e.attachmentUrl||w,A=t.useCallback((function(e){return e.preventDefault()}),[]);return x?v.jsx("div",{className:j.cAttachment,children:v.jsx(R,{size:e.size,openLightbox:function(){return c(!0)},attachmentFileName:e.fileName,setImageIsLoaded:function(){return r(!0)},imageIsLoaded:s,lightboxIsOpen:o,handleLightboxOpen:function(){g.isNativeDetected&&document.documentElement.addEventListener("touchmove",A,{passive:!1})},handleLightboxClose:function(){g.isNativeDetected&&document.documentElement.removeEventListener("touchmove",A),c(!1)},classes:e.classes})}):b&&y.default.canPlay(I)?v.jsx("div",{className:j.cAttachment,children:v.jsx(y.default,{"data-testid":"".concat("Attachment","_player"),className:j.cAttachmentReactPlayer,url:I,config:{file:{attributes:{preload:"metadata"}}},controls:!0,height:e.size===W.label?W.value:z.value,width:null})}):v.jsx("div",{className:j.cAttachment,children:v.jsx(U,{attachmentUrl:I,attachmentFileName:e.fileName,attachmentSize:e.attachmentSize,displayName:e.displayName,openPreview:function(){return h(!0)},closePreview:function(e){e.stopPropagation(),h(!1)},previewIsOpen:m,classes:e.classes,small:e.small})})}O.propTypes={attachmentUrl:w.default.string.isRequired,attachmentSize:w.default.number,displayName:w.default.string,fileName:w.default.string,size:w.default.oneOf([W.label,z.label]),classes:w.default.shape({}).isRequired,small:w.default.bool},O.defaultProps={displayName:null,fileName:null,attachmentSize:void 0,size:z.label,small:!1};var E=s.withStyles((function(e){return{imageIconRoot:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)"},dialog:{width:"95%",height:"95%",maxWidth:"100%",position:"relative"},nativeDialog:{width:"100%",height:"100%",maxWidth:"100%",maxHeight:"100%",margin:0},dialogRoot:{backgroundColor:"rgba(0, 0, 0, 0.85)"},fileName:{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",fontWeight:400},downloadIcon:{color:e.palette.primary.text3}}}))(O);module.exports=E;
@@ -1 +1 @@
1
- import e from"@babel/runtime/helpers/slicedToArray";import{useState as t,useCallback as a}from"react";import i from"prop-types";import o from"react-player";import{withStyles as r}from"@material-ui/core/styles";import s from"@material-ui/core/Typography";import{Dialog as n}from"@material-ui/core";import l from"@material-ui/icons/Image";import m from"@material-ui/icons/SaveAlt";import c from"@material-ui/icons/Fullscreen";import d from"@material-ui/core/colors/grey";import p from"../FileTypeIcon.js";import h from"../ImageViewer/index.js";import u from"../GoogleDocsViewer/index.js";import f from"../IconButton/index.js";import{isNativeDetected as g}from"../../utils/mobileDetect.js";import{getIsImage as v,getIsVideo as b}from"../../utils/fileExtension.js";import"@babel/runtime/helpers/asyncToGenerator";import"@babel/runtime/helpers/defineProperty";import"@babel/runtime/regenerator";import"querystring";import"uuid/v1";import"lodash";import"../../clients/jsonApi/index.js";import"../../clients/subscriptions.js";import"../../constants/goals.js";import"../../constants/segment.js";import"../../constants/alerts.js";import"../../constants/apps.js";import"../../constants/drillstring.js";import"../../constants/completion.js";import"../../constants/notifications.js";import"../../constants/feed.js";import"../../constants/bha.js";import"../../utils/env.js";import"../GradientManager/configuration/constants.js";import N from"../../effects/useSignedURL.js";import"../../utils/index.js";import"uuid";import"jsona";import"../StatusBadge/constants.js";import"@babel/runtime/helpers/toConsumableArray";import"lodash/set";import"lodash/get";import"lodash/unset";import"moment";import"../../clients/api/apiCore.js";import"../../clients/constants.js";import w from"../../utils/main.js";import y from"./styles.css.js";import{jsx as x,jsxs as j,Fragment as I}from"react/jsx-runtime";var A=d[200],P=d[400],F={label:"small",value:135},L={label:"medium",value:300},W={fileImage:function(e,t){return{maxWidth:"100%",borderRadius:4,overflow:"hidden",maxHeight:t===F.label?F.value:L.value,display:e?"initial":"none",cursor:"pointer"}},fileDownloadWrapper:{padding:"10px 10px 10px 5px",border:"1px solid #616161",borderRadius:3,maxWidth:500,width:"75%"},imagePlaceholder:{position:"relative",backgroundColor:A,borderRadius:3,marginTop:10,height:135,width:135}},z=function(e){return j(I,{children:[j("div",{onClick:e.openLightbox,className:y.cAttachmentImg,children:[x("img",{"data-testid":"".concat("Attachment","_image"),src:e.attachmentUrl,style:W.fileImage(e.imageIsLoaded,e.size),alt:"Attachment",onLoad:e.setImageIsLoaded}),x("div",{"data-testid":"".concat("Attachment","_button"),className:y.cAttachmentImgPreviwBtn,children:x(c,{})})]}),!e.imageIsLoaded&&x("div",{style:W.imagePlaceholder,children:x(l,{"data-testid":"".concat("Attachment","_placeholder"),className:e.classes.imageIconRoot,htmlColor:P,fontSize:"large"})}),e.lightboxIsOpen&&x(h,{mainSrc:e.attachmentUrl,imagePadding:50,onAfterOpen:e.handleLightboxOpen,onCloseRequest:e.handleLightboxClose})]})},C=function(e){var t=N(e.attachmentFileName);return j("div",{className:y.cAttachmentFileWrapper,children:[j("div",{className:y.cAttachmentFileDownloadWrapper,style:W.fileDownloadWrapper,onClick:e.openPreview,children:[x(p,{fileName:e.displayName||e.attachmentUrl,className:y.cAttachmentFileDownloadWrapperFileIcon,size:e.small?25:50}),x("div",{"data-testid":"".concat("Attachment","_name"),className:y.cAttachmentFileDownloadWrapperFileName,children:x(s,{variant:"subtitle2",noWrap:!0,className:e.classes.fileName,children:w.getFileNameWithExtensionFromPath(e.displayName||e.attachmentUrl)})}),x(n,{open:e.previewIsOpen,onClose:e.closePreview,classes:{root:e.classes.dialogRoot,paper:g?e.classes.nativeDialog:e.classes.dialog},onClick:e.closePreview,children:x(u,{fileUrl:t,fileName:w.getFileNameWithExtensionFromPath(e.displayName||e.attachmentUrl),fileSize:e.attachmentSize,onClose:e.closePreview,width:"100%",height:"100%"})})]}),x("a",{download:e.displayName,href:t,className:y.cAttachmentFileDownloadWrapperForm,children:x(f,{"data-testid":"".concat("Attachment","_downloadButton"),className:e.classes.downloadIcon,type:"submit",children:x(m,{className:e.classes.downloadIcon})})})]})};function U(i){var r=t(!1),s=e(r,2),n=s[0],l=s[1],m=t(!1),c=e(m,2),d=c[0],p=c[1],h=t(!1),u=e(h,2),f=u[0],w=u[1],j=i.displayName||i.attachmentUrl||i.fileName,I=v(j),A=b(j),P=N(!i.attachmentUrl&&i.fileName),W=i.attachmentUrl||P,U=a((function(e){return e.preventDefault()}),[]);return I?x("div",{className:y.cAttachment,children:x(z,{size:i.size,openLightbox:function(){return p(!0)},attachmentUrl:W,setImageIsLoaded:function(){return l(!0)},imageIsLoaded:n,lightboxIsOpen:d,handleLightboxOpen:function(){g&&document.documentElement.addEventListener("touchmove",U,{passive:!1})},handleLightboxClose:function(){g&&document.documentElement.removeEventListener("touchmove",U),p(!1)},classes:i.classes})}):A&&o.canPlay(W)?x("div",{className:y.cAttachment,children:x(o,{"data-testid":"".concat("Attachment","_player"),className:y.cAttachmentReactPlayer,url:W,config:{file:{attributes:{preload:"metadata"}}},controls:!0,height:i.size===F.label?F.value:L.value,width:null})}):x("div",{className:y.cAttachment,children:x(C,{attachmentUrl:W,attachmentFileName:i.fileName,attachmentSize:i.attachmentSize,displayName:i.displayName,openPreview:function(){return w(!0)},closePreview:function(e){e.stopPropagation(),w(!1)},previewIsOpen:f,classes:i.classes,small:i.small})})}U.propTypes={attachmentUrl:i.string.isRequired,attachmentSize:i.number,displayName:i.string,fileName:i.string,size:i.oneOf([F.label,L.label]),classes:i.shape({}).isRequired,small:i.bool},U.defaultProps={displayName:null,fileName:null,attachmentSize:void 0,size:L.label,small:!1};var R=r((function(e){return{imageIconRoot:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)"},dialog:{width:"95%",height:"95%",maxWidth:"100%",position:"relative"},nativeDialog:{width:"100%",height:"100%",maxWidth:"100%",maxHeight:"100%",margin:0},dialogRoot:{backgroundColor:"rgba(0, 0, 0, 0.85)"},fileName:{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",fontWeight:400},downloadIcon:{color:e.palette.primary.text3}}}))(U);export{R as default};
1
+ import e from"@babel/runtime/helpers/slicedToArray";import{useState as t,useCallback as a}from"react";import i from"prop-types";import o from"react-player";import{withStyles as r}from"@material-ui/core/styles";import s from"@material-ui/core/Typography";import{Dialog as n}from"@material-ui/core";import l from"@material-ui/icons/Image";import m from"@material-ui/icons/SaveAlt";import c from"@material-ui/icons/Fullscreen";import d from"@material-ui/core/colors/grey";import p from"../FileTypeIcon.js";import h from"../ImageViewer/index.js";import u from"../GoogleDocsViewer/index.js";import f from"../IconButton/index.js";import{isNativeDetected as g}from"../../utils/mobileDetect.js";import{getIsImage as v,getIsVideo as b}from"../../utils/fileExtension.js";import"@babel/runtime/helpers/asyncToGenerator";import"@babel/runtime/helpers/defineProperty";import"@babel/runtime/regenerator";import"querystring";import"uuid/v1";import"lodash";import"../../clients/jsonApi/index.js";import"../../clients/subscriptions.js";import"../../constants/goals.js";import"../../constants/segment.js";import"../../constants/alerts.js";import"../../constants/apps.js";import"../../constants/drillstring.js";import"../../constants/completion.js";import"../../constants/notifications.js";import"../../constants/feed.js";import"../../constants/bha.js";import"../../utils/env.js";import"../GradientManager/configuration/constants.js";import N from"../../effects/useSignedURL.js";import"../../utils/index.js";import"uuid";import"jsona";import"../StatusBadge/constants.js";import"@babel/runtime/helpers/toConsumableArray";import"lodash/set";import"lodash/get";import"lodash/unset";import"moment";import"../../clients/api/apiCore.js";import"../../clients/constants.js";import w from"../../utils/main.js";import y from"./styles.css.js";import{jsx as x,jsxs as j,Fragment as I}from"react/jsx-runtime";var A=d[200],F=d[400],P={label:"small",value:135},L={label:"medium",value:300},W={fileImage:function(e,t){return{maxWidth:"100%",borderRadius:4,overflow:"hidden",maxHeight:t===P.label?P.value:L.value,display:e?"initial":"none",cursor:"pointer"}},fileDownloadWrapper:{padding:"10px 10px 10px 5px",border:"1px solid #616161",borderRadius:3,maxWidth:500,width:"75%"},imagePlaceholder:{position:"relative",backgroundColor:A,borderRadius:3,marginTop:10,height:135,width:135}},z=function(e){var t=N(e.attachmentFileName);return j(I,{children:[j("div",{onClick:e.openLightbox,className:y.cAttachmentImg,children:[x("img",{"data-testid":"".concat("Attachment","_image"),src:t,style:W.fileImage(e.imageIsLoaded,e.size),alt:"Attachment",onLoad:e.setImageIsLoaded}),x("div",{"data-testid":"".concat("Attachment","_button"),className:y.cAttachmentImgPreviwBtn,children:x(c,{})})]}),!e.imageIsLoaded&&x("div",{style:W.imagePlaceholder,children:x(l,{"data-testid":"".concat("Attachment","_placeholder"),className:e.classes.imageIconRoot,htmlColor:F,fontSize:"large"})}),e.lightboxIsOpen&&x(h,{mainSrc:t,imagePadding:50,onAfterOpen:e.handleLightboxOpen,onCloseRequest:e.handleLightboxClose})]})},C=function(e){var t=N(e.attachmentFileName);return j("div",{className:y.cAttachmentFileWrapper,children:[j("div",{className:y.cAttachmentFileDownloadWrapper,style:W.fileDownloadWrapper,onClick:e.openPreview,children:[x(p,{fileName:e.displayName||e.attachmentUrl,className:y.cAttachmentFileDownloadWrapperFileIcon,size:e.small?25:50}),x("div",{"data-testid":"".concat("Attachment","_name"),className:y.cAttachmentFileDownloadWrapperFileName,children:x(s,{variant:"subtitle2",noWrap:!0,className:e.classes.fileName,children:w.getFileNameWithExtensionFromPath(e.displayName||e.attachmentUrl)})}),x(n,{open:e.previewIsOpen,onClose:e.closePreview,classes:{root:e.classes.dialogRoot,paper:g?e.classes.nativeDialog:e.classes.dialog},onClick:e.closePreview,children:x(u,{fileUrl:t,fileName:w.getFileNameWithExtensionFromPath(e.displayName||e.attachmentUrl),fileSize:e.attachmentSize,onClose:e.closePreview,width:"100%",height:"100%"})})]}),x("a",{download:e.displayName,href:t,className:y.cAttachmentFileDownloadWrapperForm,children:x(f,{"data-testid":"".concat("Attachment","_downloadButton"),className:e.classes.downloadIcon,type:"submit",children:x(m,{className:e.classes.downloadIcon})})})]})};function R(i){var r=t(!1),s=e(r,2),n=s[0],l=s[1],m=t(!1),c=e(m,2),d=c[0],p=c[1],h=t(!1),u=e(h,2),f=u[0],w=u[1],j=i.displayName||i.attachmentUrl||i.fileName,I=v(j),A=b(j),F=N(!i.attachmentUrl&&i.fileName),W=i.attachmentUrl||F,R=a((function(e){return e.preventDefault()}),[]);return I?x("div",{className:y.cAttachment,children:x(z,{size:i.size,openLightbox:function(){return p(!0)},attachmentFileName:i.fileName,setImageIsLoaded:function(){return l(!0)},imageIsLoaded:n,lightboxIsOpen:d,handleLightboxOpen:function(){g&&document.documentElement.addEventListener("touchmove",R,{passive:!1})},handleLightboxClose:function(){g&&document.documentElement.removeEventListener("touchmove",R),p(!1)},classes:i.classes})}):A&&o.canPlay(W)?x("div",{className:y.cAttachment,children:x(o,{"data-testid":"".concat("Attachment","_player"),className:y.cAttachmentReactPlayer,url:W,config:{file:{attributes:{preload:"metadata"}}},controls:!0,height:i.size===P.label?P.value:L.value,width:null})}):x("div",{className:y.cAttachment,children:x(C,{attachmentUrl:W,attachmentFileName:i.fileName,attachmentSize:i.attachmentSize,displayName:i.displayName,openPreview:function(){return w(!0)},closePreview:function(e){e.stopPropagation(),w(!1)},previewIsOpen:f,classes:i.classes,small:i.small})})}R.propTypes={attachmentUrl:i.string.isRequired,attachmentSize:i.number,displayName:i.string,fileName:i.string,size:i.oneOf([P.label,L.label]),classes:i.shape({}).isRequired,small:i.bool},R.defaultProps={displayName:null,fileName:null,attachmentSize:void 0,size:L.label,small:!1};var S=r((function(e){return{imageIconRoot:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)"},dialog:{width:"95%",height:"95%",maxWidth:"100%",position:"relative"},nativeDialog:{width:"100%",height:"100%",maxWidth:"100%",maxHeight:"100%",margin:0},dialogRoot:{backgroundColor:"rgba(0, 0, 0, 0.85)"},fileName:{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",fontWeight:400},downloadIcon:{color:e.palette.primary.text3}}}))(R);export{S as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@corva/ui",
3
- "version": "0.63.0-rc.7",
3
+ "version": "0.63.0-rc.8",
4
4
  "description": "Shared components/utils for Corva ui projects",
5
5
  "keywords": [
6
6
  "corva-ui"