@corva/ui 0.32.0-2 → 0.32.0-3

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"@babel/runtime/helpers/defineProperty";import"../../constants/completion.js";import"../../constants/alerts.js";import"lodash";import e from"@babel/runtime/helpers/slicedToArray";import"../../constants/goals.js";import"../../constants/segment.js";import"../../constants/apps.js";import"../../constants/drillstring.js";import"../../constants/notifications.js";import"../../constants/feed.js";import"@babel/runtime/regenerator";import"@babel/runtime/helpers/asyncToGenerator";import t from"@material-ui/core/colors/grey";import a from"../../utils/main.js";import{isNativeDetected as i}from"../../utils/mobileDetect.js";import{getIsImage as o,getIsVideo as r}from"../../utils/fileExtension.js";import{jsx as l,jsxs as n,Fragment as s}from"react/jsx-runtime";import{Dialog as m}from"@material-ui/core";import{useState as c,useCallback as d}from"react";import"querystring";import"uuid/v1";import"../../clients/jsonApi/index.js";import"../../clients/subscriptions.js";import p from"../../effects/useSignedURL.js";import h from"prop-types";import{withStyles as u}from"@material-ui/core/styles";import f from"@material-ui/core/Typography";import g from"../FileTypeIcon.js";import v from"react-player";import b from"@material-ui/core/IconButton";import N from"@material-ui/icons/Image";import w from"@material-ui/icons/SaveAlt";import y from"@material-ui/icons/Fullscreen";import x from"../ImageViewer/index.js";import I from"../GoogleDocsViewer/index.js";import A from"./styles.css.js";var j=t[200],P=t[400],L=t[600],z={label:"small",value:135},F={label:"medium",value:300},U={fileImage:function(e,t){return{maxWidth:"100%",borderRadius:4,overflow:"hidden",maxHeight:t===z.label?z.value:F.value,display:e?"initial":"none",cursor:"pointer"}},fileDownloadWrapper:{marginTop:10,padding:"10px 10px 10px 5px",border:"1px solid ".concat(L),borderRadius:3,maxWidth:500,width:"75%"},imagePlaceholder:{position:"relative",backgroundColor:j,borderRadius:3,marginTop:10,height:135,width:135}},W=function(e){return n(s,{children:[n("div",{onClick:e.openLightbox,className:A.cAttachmentImg,children:[l("img",{"data-testid":"".concat("Attachment","_image"),src:e.attachmentUrl,style:U.fileImage(e.imageIsLoaded,e.size),alt:"Attachment",onLoad:e.setImageIsLoaded}),l("div",{"data-testid":"".concat("Attachment","_button"),className:A.cAttachmentImgPreviwBtn,children:l(y,{})})]}),!e.imageIsLoaded&&l("div",{style:U.imagePlaceholder,children:l(N,{"data-testid":"".concat("Attachment","_placeholder"),className:e.classes.imageIconRoot,htmlColor:P,fontSize:"large"})}),e.lightboxIsOpen&&l(x,{mainSrc:e.attachmentUrl,imagePadding:50,onAfterOpen:e.handleLightboxOpen,onCloseRequest:e.handleLightboxClose})]})},R=function(e){return n("div",{className:A.cAttachmentFileWrapper,children:[n("div",{className:A.cAttachmentFileDownloadWrapper,style:U.fileDownloadWrapper,onClick:e.openPreview,children:[l(g,{fileName:e.displayName||e.attachmentUrl,className:A.cAttachmentFileDownloadWrapperFileIcon,size:e.small?25:50}),l("div",{"data-testid":"".concat("Attachment","_name"),className:A.cAttachmentFileDownloadWrapperFileName,children:l(f,{variant:"subtitle2",noWrap:!0,className:e.classes.fileName,children:a.getFileNameWithExtensionFromPath(e.displayName||e.attachmentUrl)})}),l(m,{open:e.previewIsOpen,onClose:e.closePreview,classes:{root:e.classes.dialogRoot,paper:i?e.classes.nativeDialog:e.classes.dialog},children:l(I,{fileUrl:e.attachmentUrl,fileName:a.getFileNameWithExtensionFromPath(e.displayName||e.attachmentUrl),fileSize:e.attachmentSize,onClose:e.closePreview,width:"100%",height:"100%"})})]}),l("a",{download:e.displayName,href:e.attachmentUrl,className:A.cAttachmentFileDownloadWrapperForm,children:l(b,{"data-testid":"".concat("Attachment","_downloadButton"),type:"submit",children:l(w,{className:e.classes.downloadIcon})})})]})};function D(t){var a=c(!1),n=e(a,2),s=n[0],m=n[1],h=c(!1),u=e(h,2),f=u[0],g=u[1],b=c(!1),N=e(b,2),w=N[0],y=N[1],x=t.displayName||t.attachmentUrl,I=o(x),j=r(x),P=p(t.fileName)||t.attachmentUrl,L=d((function(e){return e.preventDefault()}),[]);return I?l("div",{className:A.cAttachment,children:l(W,{size:t.size,openLightbox:function(){return g(!0)},attachmentUrl:P,setImageIsLoaded:function(){return m(!0)},imageIsLoaded:s,lightboxIsOpen:f,handleLightboxOpen:function(){i&&document.documentElement.addEventListener("touchmove",L,{passive:!1})},handleLightboxClose:function(){i&&document.documentElement.removeEventListener("touchmove",L),g(!1)},classes:t.classes})}):j&&v.canPlay(P)?l("div",{className:A.cAttachment,children:l(v,{"data-testid":"".concat("Attachment","_player"),className:A.cAttachmentReactPlayer,url:P,config:{file:{attributes:{preload:"metadata"}}},controls:!0,height:t.size===z.label?z.value:F.value,width:null})}):l("div",{className:A.cAttachment,children:l(R,{attachmentUrl:P,attachmentSize:t.attachmentSize,displayName:t.displayName,openPreview:function(){return y(!0)},closePreview:function(e){e.stopPropagation(),y(!1)},previewIsOpen:w,classes:t.classes,small:t.small})})}D.propTypes={attachmentUrl:h.string.isRequired,attachmentSize:h.number,displayName:h.string,fileName:h.string,size:h.oneOf([z.label,F.label]),classes:h.shape({}).isRequired,small:h.bool},D.defaultProps={displayName:null,fileName:null,attachmentSize:void 0,size:F.label,small:!1};var S=u((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"},downloadIcon:{color:L,"&:hover":{color:e.palette.common.white}}}}))(D);export default S;
1
+ import"@babel/runtime/helpers/defineProperty";import"../../constants/completion.js";import"../../constants/alerts.js";import"lodash";import e from"@babel/runtime/helpers/slicedToArray";import"../../constants/goals.js";import"../../constants/segment.js";import"../../constants/apps.js";import"../../constants/drillstring.js";import"../../constants/notifications.js";import"../../constants/feed.js";import"@babel/runtime/regenerator";import"@babel/runtime/helpers/asyncToGenerator";import t from"@material-ui/core/colors/grey";import a from"../../utils/main.js";import{isNativeDetected as i}from"../../utils/mobileDetect.js";import{getIsImage as o,getIsVideo as r}from"../../utils/fileExtension.js";import{jsx as l,jsxs as n,Fragment as s}from"react/jsx-runtime";import{Dialog as m}from"@material-ui/core";import{useState as c,useCallback as d}from"react";import"querystring";import"uuid/v1";import"../../clients/jsonApi/index.js";import"../../clients/subscriptions.js";import p from"../../effects/useSignedURL.js";import h from"prop-types";import{withStyles as u}from"@material-ui/core/styles";import f from"@material-ui/core/Typography";import g from"../FileTypeIcon.js";import v from"react-player";import b from"@material-ui/core/IconButton";import N from"@material-ui/icons/Image";import w from"@material-ui/icons/SaveAlt";import y from"@material-ui/icons/Fullscreen";import x from"../ImageViewer/index.js";import I from"../GoogleDocsViewer/index.js";import A from"./styles.css.js";var j=t[200],P=t[400],L=t[600],z={label:"small",value:135},F={label:"medium",value:300},U={fileImage:function(e,t){return{maxWidth:"100%",borderRadius:4,overflow:"hidden",maxHeight:t===z.label?z.value:F.value,display:e?"initial":"none",cursor:"pointer"}},fileDownloadWrapper:{marginTop:10,padding:"10px 10px 10px 5px",border:"1px solid ".concat(L),borderRadius:3,maxWidth:500,width:"75%"},imagePlaceholder:{position:"relative",backgroundColor:j,borderRadius:3,marginTop:10,height:135,width:135}},W=function(e){return n(s,{children:[n("div",{onClick:e.openLightbox,className:A.cAttachmentImg,children:[l("img",{"data-testid":"".concat("Attachment","_image"),src:e.attachmentUrl,style:U.fileImage(e.imageIsLoaded,e.size),alt:"Attachment",onLoad:e.setImageIsLoaded}),l("div",{"data-testid":"".concat("Attachment","_button"),className:A.cAttachmentImgPreviwBtn,children:l(y,{})})]}),!e.imageIsLoaded&&l("div",{style:U.imagePlaceholder,children:l(N,{"data-testid":"".concat("Attachment","_placeholder"),className:e.classes.imageIconRoot,htmlColor:P,fontSize:"large"})}),e.lightboxIsOpen&&l(x,{mainSrc:e.attachmentUrl,imagePadding:50,onAfterOpen:e.handleLightboxOpen,onCloseRequest:e.handleLightboxClose})]})},R=function(e){return n("div",{className:A.cAttachmentFileWrapper,children:[n("div",{className:A.cAttachmentFileDownloadWrapper,style:U.fileDownloadWrapper,onClick:e.openPreview,children:[l(g,{fileName:e.displayName||e.attachmentUrl,className:A.cAttachmentFileDownloadWrapperFileIcon,size:e.small?25:50}),l("div",{"data-testid":"".concat("Attachment","_name"),className:A.cAttachmentFileDownloadWrapperFileName,children:l(f,{variant:"subtitle2",noWrap:!0,className:e.classes.fileName,children:a.getFileNameWithExtensionFromPath(e.displayName||e.attachmentUrl)})}),l(m,{open:e.previewIsOpen,onClose:e.closePreview,classes:{root:e.classes.dialogRoot,paper:i?e.classes.nativeDialog:e.classes.dialog},children:l(I,{fileUrl:e.attachmentUrl,fileName:a.getFileNameWithExtensionFromPath(e.displayName||e.attachmentUrl),fileSize:e.attachmentSize,onClose:e.closePreview,width:"100%",height:"100%"})})]}),l("a",{download:e.displayName,href:e.attachmentUrl,className:A.cAttachmentFileDownloadWrapperForm,children:l(b,{"data-testid":"".concat("Attachment","_downloadButton"),type:"submit",children:l(w,{className:e.classes.downloadIcon})})})]})};function D(t){var a=c(!1),n=e(a,2),s=n[0],m=n[1],h=c(!1),u=e(h,2),f=u[0],g=u[1],b=c(!1),N=e(b,2),w=N[0],y=N[1],x=t.displayName||t.attachmentUrl,I=o(x),j=r(x),P=p(t.fileName),L=t.attachmentUrl||P,U=d((function(e){return e.preventDefault()}),[]);return I?l("div",{className:A.cAttachment,children:l(W,{size:t.size,openLightbox:function(){return g(!0)},attachmentUrl:L,setImageIsLoaded:function(){return m(!0)},imageIsLoaded:s,lightboxIsOpen:f,handleLightboxOpen:function(){i&&document.documentElement.addEventListener("touchmove",U,{passive:!1})},handleLightboxClose:function(){i&&document.documentElement.removeEventListener("touchmove",U),g(!1)},classes:t.classes})}):j&&v.canPlay(L)?l("div",{className:A.cAttachment,children:l(v,{"data-testid":"".concat("Attachment","_player"),className:A.cAttachmentReactPlayer,url:L,config:{file:{attributes:{preload:"metadata"}}},controls:!0,height:t.size===z.label?z.value:F.value,width:null})}):l("div",{className:A.cAttachment,children:l(R,{attachmentUrl:L,attachmentSize:t.attachmentSize,displayName:t.displayName,openPreview:function(){return y(!0)},closePreview:function(e){e.stopPropagation(),y(!1)},previewIsOpen:w,classes:t.classes,small:t.small})})}D.propTypes={attachmentUrl:h.string.isRequired,attachmentSize:h.number,displayName:h.string,fileName:h.string,size:h.oneOf([z.label,F.label]),classes:h.shape({}).isRequired,small:h.bool},D.defaultProps={displayName:null,fileName:null,attachmentSize:void 0,size:F.label,small:!1};var S=u((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"},downloadIcon:{color:L,"&:hover":{color:e.palette.common.white}}}}))(D);export default S;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@corva/ui",
3
- "version": "0.32.0-2",
3
+ "version": "0.32.0-3",
4
4
  "description": "Shared components/utils for Corva ui projects",
5
5
  "keywords": [
6
6
  "corva-ui"