@aws-amplify/ui-react-storage 0.0.1 → 1.0.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.
- package/dist/esm/components/StorageManager/StorageManager.mjs +1 -1
- package/dist/esm/components/StorageManager/hooks/useUploadFiles/useUploadFiles.mjs +1 -1
- package/dist/esm/components/StorageManager/ui/FileList/FileList.mjs +1 -1
- package/dist/esm/components/StorageManager/ui/FilePicker/FilePicker.mjs +1 -0
- package/dist/index.js +1 -1
- package/dist/styles.css +126 -55
- package/dist/types/components/StorageManager/StorageManager.d.ts +5 -5
- package/dist/types/components/StorageManager/hooks/index.d.ts +1 -1
- package/dist/types/components/StorageManager/index.d.ts +1 -0
- package/dist/types/components/StorageManager/types.d.ts +6 -9
- package/dist/types/components/StorageManager/ui/DropZone/index.d.ts +1 -2
- package/dist/types/components/StorageManager/ui/DropZone/types.d.ts +0 -6
- package/dist/types/components/StorageManager/ui/FilePicker/FilePicker.d.ts +6 -0
- package/dist/types/components/StorageManager/ui/FilePicker/index.d.ts +1 -0
- package/dist/types/components/StorageManager/ui/index.d.ts +2 -1
- package/dist/types/components/index.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +4 -3
- package/dist/esm/components/StorageManager/ui/DropZone/FilePicker.mjs +0 -1
- package/dist/types/components/StorageManager/ui/DropZone/FilePicker.d.ts +0 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"react";import{Logger as i}from"aws-amplify";import{ComponentClassNames as s}from"@aws-amplify/ui-react";import{useDropZone as o}from"./hooks/useDropZone/useDropZone.mjs";import{useStorageManager as
|
|
1
|
+
import*as e from"react";import{Logger as i}from"aws-amplify";import{ComponentClassNames as s,VisuallyHidden as r}from"@aws-amplify/ui-react";import{useDropZone as o}from"./hooks/useDropZone/useDropZone.mjs";import{useStorageManager as l}from"./hooks/useStorageManager/useStorageManager.mjs";import{useUploadFiles as t}from"./hooks/useUploadFiles/useUploadFiles.mjs";import{FileStatus as a}from"./types.mjs";import{Container as n}from"./ui/Container/Container.mjs";import{DropZone as m}from"./ui/DropZone/DropZone.mjs";import{FileList as p}from"./ui/FileList/FileList.mjs";import{FileListHeader as c}from"./ui/FileListHeader/FileListHeader.mjs";import{FilePicker as u}from"./ui/FilePicker/FilePicker.mjs";import{checkMaxFileSize as d}from"./utils/checkMaxFileSize.mjs";import{defaultStorageManagerDisplayText as f}from"./utils/displayText.mjs";import{filterAllowedFiles as F}from"./utils/filterAllowedFiles.mjs";import"tslib";const g=new i("Storage.StorageManager");function h({acceptedFileTypes:i,accessLevel:h,defaultFiles:U,displayText:x,isResumable:y=!1,maxFileCount:j,maxFileSize:k,onUploadError:E,onUploadSuccess:S,onFileRemove:T,showThumbnails:C=!0,processFile:L,components:b,provider:v,path:P}){i&&h&&j||g.warn("FileUploader requires accessLevel, acceptedFileTypes and maxFileCount props");const D=Object.assign({Container:n,DropZone:m,FileList:p,FilePicker:u,FileListHeader:c},b),w=void 0===j||"number"==typeof j&&j>1,M=Object.assign(Object.assign({},f),x),{getFileSizeErrorText:R}=M,Z=e=>d({file:e,maxFileSize:k,getFileSizeErrorText:R}),{addFiles:z,files:H,removeUpload:O,setUploadingFile:A,setUploadPaused:$,setUploadProgress:q,setUploadSuccess:I,setUploadResumed:N}=l(U),B=o({onChange:e=>{const{files:s}=e.dataTransfer;if(!s||0===s.length)return;const r=F(Array.from(s),i);z({files:r,getFileErrorMessage:Z})}});t({accessLevel:h,files:H,isResumable:y,maxFileCount:j,onUploadError:E,onUploadSuccess:S,setUploadingFile:A,setUploadProgress:q,setUploadSuccess:I,processFile:L,provider:v,path:P});const G=0!==H.length&&H.every((e=>100===(null==e?void 0:e.progress))),J=H.filter((e=>e.progress<100)).length>j,K=H.filter((e=>(null==e?void 0:e.status)===a.UPLOADED)).length,Q=H.length-K,V=H.length>0,W=e.useRef(null);return e.createElement(D.Container,{className:`${s.StorageManager} ${V?s.StorageManagerPreviewer:""}`},e.createElement(D.DropZone,Object.assign({},B,{displayText:M}),e.createElement(e.Fragment,null,e.createElement(D.FilePicker,{onClick:function(){W.current&&(W.current.click(),W.current.value="")}},M.browseFilesText),e.createElement(r,null,e.createElement("input",{type:"file",tabIndex:-1,ref:W,onChange:e=>{const{files:i}=e.target;i&&0!==i.length&&z({files:Array.from(i),getFileErrorMessage:Z})},multiple:w,accept:i.join(",")})))),V?e.createElement(D.FileListHeader,{allUploadsSuccessful:G,displayText:M,fileCount:H.length,remainingFilesCount:Q}):null,e.createElement(D.FileList,{displayText:M,files:H,isResumable:y,onCancelUpload:({id:e,uploadTask:i})=>{i.pause(),O({id:e})},onDeleteUpload:({id:e})=>{if(O({id:e}),"function"==typeof T){const i=H.find((i=>i.id===e));i&&T({key:i.key})}},onResume:({id:e,uploadTask:i})=>{i.resume(),N({id:e})},onPause:({id:e,uploadTask:i})=>{i.pause(),$({id:e})},showThumbnails:C,hasMaxFilesError:J,maxFileCount:j}))}h.Container=n,h.DropZone=m,h.FileList=p,h.FileListHeader=c,h.FilePicker=u;export{h as StorageManager};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"react";import{uploadFile as l}from"../../utils/uploadFile.mjs";import{FileStatus as o}from"../../types.mjs";function s({files:s,accessLevel:i,isResumable:a,setUploadProgress:r,setUploadingFile:t,setUploadSuccess:c,onUploadError:f,onUploadSuccess:p,maxFileCount:d,processFile:n,provider:m,path:u=""}){e.useEffect((()=>{const e=s.filter((e=>e.status===o.QUEUED));if(!(e.length>d))for(const{file:o,key:s,id:d}of e){const e=e=>{null==p||p(e),c({id:d})},k=e=>{const l=0===e.total?100:Math.floor(e.loaded/e.total*100);r({id:d,progress:l})},b=e=>{null==f||f(e)};if(o){const r="function"==typeof n?n({file:o,key:s}):{file:o,key:s};if(a){const o=l({file:r.file,fileName:u+r.key,isResumable:!0,level:i,completeCallback:e,progressCallback:k,errorCallback:b,provider:m});t({id:d,uploadTask:o})}else l({file:r.file,fileName:u+r.key,isResumable:!1,level:i,completeCallback:e,progressCallback:k,errorCallback:b,provider:m}),t({id:d})}}}),[s,i,a,r,t,f,p,d,c,n,m])}export{s as useUploadFiles};
|
|
1
|
+
import*as e from"react";import{uploadFile as l}from"../../utils/uploadFile.mjs";import{FileStatus as o}from"../../types.mjs";function s({files:s,accessLevel:i,isResumable:a,setUploadProgress:r,setUploadingFile:t,setUploadSuccess:c,onUploadError:f,onUploadSuccess:p,maxFileCount:d,processFile:n,provider:m,path:u=""}){e.useEffect((()=>{const e=s.filter((e=>e.status===o.QUEUED));if(!(e.length>d))for(const{file:o,key:s,id:d}of e){const e=e=>{null==p||p(e),c({id:d})},k=e=>{const l=0===e.total?100:Math.floor(e.loaded/e.total*100);r({id:d,progress:l})},b=e=>{null==f||f(e)};if(o){const r="function"==typeof n?n({file:o,key:s}):{file:o,key:s};if(a){const o=l({file:r.file,fileName:u+r.key,isResumable:!0,level:i,completeCallback:e,progressCallback:k,errorCallback:b,provider:m});t({id:d,uploadTask:o})}else l({file:r.file,fileName:u+r.key,isResumable:!1,level:i,completeCallback:e,progressCallback:k,errorCallback:b,provider:m}),t({id:d})}}}),[s,i,a,r,t,f,p,d,c,n,m,u])}export{s as useUploadFiles};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"react";import{View as a,Alert as
|
|
1
|
+
import e from"react";import{View as a,ComponentClassNames as s,Alert as r}from"@aws-amplify/ui-react";import{FileStatus as o}from"../../types.mjs";import{FileControl as i}from"./FileControl.mjs";function t({displayText:t,files:l,hasMaxFilesError:n,isResumable:m,onCancelUpload:u,onDeleteUpload:p,onResume:d,onPause:c,showThumbnails:g,maxFileCount:f}){if(l.length<1)return null;const{getMaxFilesErrorText:T}=t,U=T(f);return e.createElement(a,{className:s.StorageManagerFileList},l.map((a=>{const{file:s,status:r,progress:l,error:n,key:f,isImage:T,id:U,uploadTask:h}=a,x=s&&T?URL.createObjectURL(s):"",y=!m||l>0,R=r===o.UPLOADING;return e.createElement(i,{displayName:f,errorMessage:n,displayText:t,isImage:T,isUploading:R,isResumable:m,key:U,loaderIsDeterminate:y,onRemove:()=>{m&&(r===o.UPLOADING||r===o.PAUSED)&&h?u({id:U,uploadTask:h}):p({id:U})},onPause:()=>{h&&c({id:U,uploadTask:h})},onResume:()=>{h&&d({id:U,uploadTask:h})},progress:l,showThumbnails:g,size:null==s?void 0:s.size,status:r,thumbnailUrl:x})})),n&&e.createElement(r,{variation:"error",heading:U}))}export{t as FileList};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__rest as e}from"tslib";import r from"react";import{ComponentClassNames as a,Button as i}from"@aws-amplify/ui-react";function s(s){var{children:t,className:m=a.StorageManagerFilePicker,size:c="small"}=s,l=e(s,["children","className","size"]);return r.createElement(i,Object.assign({},l,{className:m,size:c}),t)}export{s as FilePicker};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),a=require("aws-amplify"),t=require("@aws-amplify/ui-react"),s=require("tslib"),l=require("classnames"),r=require("@aws-amplify/ui"),n=require("@aws-amplify/ui-react/internal");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function i(e){if(e&&e.__esModule)return e;var a=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var s=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(a,t,s.get?s:{enumerable:!0,get:function(){return e[t]}})}})),a.default=e,Object.freeze(a)}var u,c,d=o(e),p=i(e),m=o(l);function g(e,a){switch(a.type){case c.ADD_FILES:{const{files:t}=a,s=t.map((e=>{const t=a.getFileErrorMessage(e);return{id:e.name,file:e,error:t,key:e.name,status:t?u.ERROR:u.QUEUED,isImage:e.type.startsWith("image/"),progress:-1}})),l=[...e.files,...s];return Object.assign(Object.assign({},e),{files:l})}case c.SET_STATUS_UPLOADING:{const{id:t,uploadTask:s}=a,{files:l}=e,r=l.reduce(((e,a)=>a.id===t?[...e,Object.assign(Object.assign({},a),{status:u.UPLOADING,progress:0,uploadTask:s||void 0})]:[...e,a]),[]);return Object.assign(Object.assign({},e),{files:r})}case c.SET_UPLOAD_PROGRESS:{const{id:t,progress:s}=a,{files:l}=e,r=l.reduce(((e,a)=>a.id===t?[...e,Object.assign(Object.assign({},a),{progress:s})]:[...e,a]),[]);return Object.assign(Object.assign({},e),{files:r})}case c.SET_STATUS:{const{id:t,status:s}=a,{files:l}=e,r=l.reduce(((e,a)=>a.id===t?[...e,Object.assign(Object.assign({},a),{status:s})]:[...e,a]),[]);return Object.assign(Object.assign({},e),{files:r})}case c.REMOVE_UPLOAD:{const{id:t}=a,{files:s}=e,l=s.reduce(((e,a)=>a.id===t?[...e]:[...e,a]),[]);return Object.assign(Object.assign({},e),{files:l})}}}!function(e){e.QUEUED="queued",e.UPLOADING="uploading",e.PAUSED="paused",e.ERROR="error",e.UPLOADED="uploaded"}(u||(u={})),function(e){e.ADD_FILES="ADD_FILES",e.SET_STATUS="SET_STATUS",e.SET_STATUS_UPLOADING="SET_STATUS_UPLOADING",e.SET_UPLOAD_PROGRESS="SET_UPLOAD_PROGRESS",e.REMOVE_UPLOAD="REMOVE_UPLOAD"}(c||(c={}));const f=({id:e,status:a})=>({type:c.SET_STATUS,id:e,status:a});function E(e=[]){const[{files:a},t]=d.default.useReducer(g,{files:e.map((e=>Object.assign(Object.assign({},e),{id:e.key,key:e.key,status:u.UPLOADED})))});return{removeUpload:({id:e})=>{t((({id:e})=>({type:c.REMOVE_UPLOAD,id:e}))({id:e}))},setUploadPaused:({id:e})=>{t(f({id:e,status:u.PAUSED}))},setUploadProgress:({progress:e,id:a})=>{t((({id:e,progress:a})=>({type:c.SET_UPLOAD_PROGRESS,id:e,progress:a}))({id:a,progress:e}))},setUploadResumed:({id:e})=>{t(f({id:e,status:u.UPLOADING}))},setUploadSuccess:({id:e})=>{t(f({id:e,status:u.UPLOADED}))},setUploadingFile:({uploadTask:e,id:a})=>{t((({id:e,uploadTask:a})=>({type:c.SET_STATUS_UPLOADING,id:e,uploadTask:a}))({id:a,uploadTask:e}))},addFiles:({files:e,getFileErrorMessage:a})=>{t((({files:e,getFileErrorMessage:a})=>({type:c.ADD_FILES,files:e,getFileErrorMessage:a}))({files:e,getFileErrorMessage:a}))},files:a}}function T(e){var{file:t,fileName:l,level:r="private",progressCallback:n,errorCallback:o,completeCallback:i,isResumable:u=!1,provider:c}=e,d=s.__rest(e,["file","fileName","level","progressCallback","errorCallback","completeCallback","isResumable","provider"]);const p=t.type||"binary/octet-stream";return!0===u?a.Storage.put(l,t,Object.assign({level:r,resumable:!0,progressCallback:n,errorCallback:o,completeCallback:i,contentType:p,provider:c},d)):a.Storage.put(l,t,Object.assign({level:r,resumable:!1,progressCallback:n,contentType:p,provider:c},d)).then(i,o)}function S({children:e,className:a}){return d.default.createElement(t.View,{className:a},e)}function U({children:e,displayText:a,inDropZone:s,onDragEnter:l,onDragLeave:o,onDragOver:i,onDragStart:u,onDrop:c,testId:p}){const{dropFilesText:g}=a;return d.default.createElement(t.View,{className:m.default(s&&r.classNameModifier(t.ComponentClassNames.StorageManagerDropZone,"active"),t.ComponentClassNames.StorageManagerDropZone),"data-testid":p,onDragStart:u,onDragEnter:l,onDragLeave:o,onDrop:c,onDragOver:i},d.default.createElement(n.IconUpload,{"aria-hidden":!0,className:t.ComponentClassNames.StorageManagerDropZoneIcon}),d.default.createElement(t.Text,{className:t.ComponentClassNames.StorageManagerDropZoneText},g),e)}function C({acceptedFileTypes:e,allowMultipleFiles:a,displayText:s,onFileChange:l}){const r=d.default.useRef(null),{browseFilesText:n}=s;return d.default.createElement(t.View,null,d.default.createElement(t.Button,{className:t.ComponentClassNames.StorageManagerDropZoneButton,onClick:function(){r.current&&(r.current.click(),r.current.value="")},size:"small"},n),d.default.createElement(t.VisuallyHidden,null,d.default.createElement("input",{type:"file",tabIndex:-1,ref:r,onChange:l,multiple:a,accept:e.join(",")})))}const D=({errorMessage:e,getPausedText:a,getUploadingText:s,percentage:l,status:o,uploadSuccessfulText:i})=>{switch(o){case u.UPLOADING:return d.default.createElement(t.Text,{className:t.ComponentClassNames.StorageManagerFileStatus},s(l));case u.PAUSED:return d.default.createElement(t.Text,{className:t.ComponentClassNames.StorageManagerFileStatus},a(l));case u.UPLOADED:return d.default.createElement(t.Text,{className:m.default(t.ComponentClassNames.StorageManagerFileStatus,r.classNameModifier(t.ComponentClassNames.StorageManagerFileStatus,"success"))},d.default.createElement(n.IconCheck,{fontSize:"xl"})," ",i);case u.ERROR:return d.default.createElement(t.Text,{className:m.default(t.ComponentClassNames.StorageManagerFileStatus,r.classNameModifier(t.ComponentClassNames.StorageManagerFileStatus,"error"))},d.default.createElement(n.IconError,{fontSize:"xl"})," ",e);default:return null}},F=({altText:e,onClick:a})=>d.default.createElement(t.Button,{size:"small",onClick:a},d.default.createElement(t.VisuallyHidden,null,e),d.default.createElement(n.IconClose,{"aria-hidden":!0,fontSize:"medium"})),b=({displayName:e,fileSize:a})=>d.default.createElement(d.default.Fragment,null,d.default.createElement(t.View,{className:t.ComponentClassNames.StorageManagerFileMain},d.default.createElement(t.Text,{className:t.ComponentClassNames.StorageManagerFileName},e)),d.default.createElement(t.Text,{as:"span",className:t.ComponentClassNames.StorageManagerFileSize},a?r.humanFileSize(a,!0):"")),x=({fileName:e,isImage:a,url:s})=>{const l=a?d.default.createElement(t.Image,{alt:e,src:s}):d.default.createElement(n.IconFile,null);return d.default.createElement(t.View,{className:t.ComponentClassNames.StorageManagerFileImage},l)};function O({onPause:e,onResume:a,displayName:s,errorMessage:l,isImage:r,isResumable:n,loaderIsDeterminate:o,onRemove:i,progress:c,showThumbnails:p=!0,size:m,status:g,displayText:f,thumbnailUrl:E}){const{getPausedText:T,getUploadingText:S,uploadSuccessfulText:U,pauseText:C,resumeText:O}=f;return d.default.createElement(t.View,{className:t.ComponentClassNames.StorageManagerFile},d.default.createElement(t.View,{className:t.ComponentClassNames.StorageManagerFileWrapper},p?d.default.createElement(x,{isImage:r,fileName:s,url:E}):null,d.default.createElement(b,{displayName:s,fileSize:m}),g===u.UPLOADING?d.default.createElement(t.Loader,{className:t.ComponentClassNames.StorageManagerLoader,variation:"linear",percentage:c,isDeterminate:o,isPercentageTextHidden:!0}):null,!n||g!==u.UPLOADING&&g!==u.PAUSED?null:g===u.PAUSED?d.default.createElement(t.Button,{onClick:a,size:"small",variation:"link"},O):d.default.createElement(t.Button,{onClick:e,size:"small",variation:"link"},C),d.default.createElement(F,{altText:`Remove file ${s}`,onClick:i})),d.default.createElement(D,{uploadSuccessfulText:U,getUploadingText:S,getPausedText:T,status:g,errorMessage:l,percentage:c}))}function N({displayText:e,files:a,hasMaxFilesError:s,isResumable:l,onCancelUpload:r,onDeleteUpload:n,onResume:o,onPause:i,showThumbnails:c,maxFileCount:p}){if(a.length<1)return null;const{getMaxFilesErrorText:m}=e,g=m(p);return d.default.createElement(t.View,{className:"amplify-storagemanager--filelist"},a.map((a=>{const{file:t,status:s,progress:p,error:m,key:g,isImage:f,id:E,uploadTask:T}=a,S=t&&f?URL.createObjectURL(t):"",U=!l||p>0,C=s===u.UPLOADING;return d.default.createElement(O,{displayName:g,errorMessage:m,displayText:e,isImage:f,isUploading:C,isResumable:l,key:E,loaderIsDeterminate:U,onRemove:()=>{l&&(s===u.UPLOADING||s===u.PAUSED)&&T?r({id:E,uploadTask:T}):n({id:E})},onPause:()=>{T&&i({id:E,uploadTask:T})},onResume:()=>{T&&o({id:E,uploadTask:T})},progress:p,showThumbnails:c,size:null==t?void 0:t.size,status:s,thumbnailUrl:S})})),s&&d.default.createElement(t.Alert,{variation:"error",heading:g}))}function P({fileCount:e,remainingFilesCount:a,displayText:s,allUploadsSuccessful:l}){const{getFilesUploadedText:r,getRemainingFilesText:n}=s;return d.default.createElement(t.Text,{className:t.ComponentClassNames.StorageManagerPreviewerText},l?r(e):n(a))}const y=({file:e,getFileSizeErrorText:a,maxFileSize:t})=>void 0===t?"":e.size>t?a(function(e,a=!1,t=1){const s=a?1e3:1024;if(Math.abs(e)<s)return`${e} B`;const l=a?["kB","MB","GB","TB","PB","EB","ZB","YB"]:["KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"];let r=-1;const n=Math.pow(10,t);do{e/=s,++r}while(Math.round(Math.abs(e)*n)/n>=s&&r<l.length-1);return e.toFixed(t)+" "+l[r]}(t,!0)):"",k={getFilesUploadedText:e=>`${e} ${1===e?"file uploaded":"files uploaded"}`,getFileSizeErrorText:e=>`File size must be below ${e}`,getRemainingFilesText:e=>`${e} ${1===e?"file":"files"} uploading`,getUploadingText:e=>"Uploading"+(e>0?`: ${e}%`:""),getUploadButtonText:e=>`Upload ${e} ${1===e?"file":"files"}`,getMaxFilesErrorText:e=>`Cannot choose more than ${e} ${1===e?"file":"files"}. Remove files before updating`,getErrorText:e=>e,doneButtonText:"Done",clearAllButtonText:"Clear all",extensionNotAllowedText:"Extension not allowed",browseFilesText:"Browse files",dropFilesText:"Drop files here or",pauseText:"Pause",resumeText:"Resume",uploadSuccessfulText:"Uploaded successfully",getPausedText:e=>`Paused: ${e}%`},v=new a.Logger("Storage.StorageManager");function h({acceptedFileTypes:a,accessLevel:s,defaultFiles:l,displayText:r,isResumable:n=!1,maxFileCount:o,maxFileSize:i,onUploadError:c,onUploadSuccess:d,onFileRemove:m,showThumbnails:g=!0,processFile:f,components:D,provider:F,path:b}){a&&s&&o||v.warn("FileUploader requires accessLevel, acceptedFileTypes and maxFileCount props");const x=Object.assign({Container:S,DropZone:U,FileList:N,FilePicker:C,FileListHeader:P},D),O=void 0===o||"number"==typeof o&&o>1,h=Object.assign(Object.assign({},k),r),{getFileSizeErrorText:M}=h,L=e=>y({file:e,maxFileSize:i,getFileSizeErrorText:M}),{addFiles:R,files:A,removeUpload:w,setUploadingFile:I,setUploadPaused:_,setUploadProgress:j,setUploadSuccess:B,setUploadResumed:z}=E(l),G=function({onChange:a}){const[t,s]=e.useState(!1);return{onDragStart:e=>{e.dataTransfer.clearData()},onDragEnter:e=>{e.preventDefault(),e.stopPropagation()},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),s(!1)},onDragOver:e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="copy",s(!0)},onDrop:e=>{e.preventDefault(),e.stopPropagation(),s(!1),a(e)},inDropZone:t}}({onChange:e=>{const{files:t}=e.dataTransfer;if(!t||0===t.length)return;const s=((e,a)=>e.filter((e=>{const t=e.name||"",s=(e.type||"").toLowerCase(),l=s.replace(/\/.*$/,"");return a.some((e=>{const a=e.trim().toLowerCase();return"."===a.charAt(0)?t.toLowerCase().endsWith(a):a.endsWith("/*")?l===a.replace(/\/.*$/,""):s===a}))})))(Array.from(t),a);R({files:s,getFileErrorMessage:L})}});!function({files:e,accessLevel:a,isResumable:t,setUploadProgress:s,setUploadingFile:l,setUploadSuccess:r,onUploadError:n,onUploadSuccess:o,maxFileCount:i,processFile:c,provider:d,path:m=""}){p.useEffect((()=>{const p=e.filter((e=>e.status===u.QUEUED));if(!(p.length>i))for(const{file:e,key:i,id:u}of p){const p=e=>{null==o||o(e),r({id:u})},g=e=>{const a=0===e.total?100:Math.floor(e.loaded/e.total*100);s({id:u,progress:a})},f=e=>{null==n||n(e)};if(e){const s="function"==typeof c?c({file:e,key:i}):{file:e,key:i};if(t){const e=T({file:s.file,fileName:m+s.key,isResumable:!0,level:a,completeCallback:p,progressCallback:g,errorCallback:f,provider:d});l({id:u,uploadTask:e})}else T({file:s.file,fileName:m+s.key,isResumable:!1,level:a,completeCallback:p,progressCallback:g,errorCallback:f,provider:d}),l({id:u})}}}),[e,a,t,s,l,n,o,i,r,c,d])}({accessLevel:s,files:A,isResumable:n,maxFileCount:o,onUploadError:c,onUploadSuccess:d,setUploadingFile:I,setUploadProgress:j,setUploadSuccess:B,processFile:f,provider:F,path:b});const $=0!==A.length&&A.every((e=>100===(null==e?void 0:e.progress))),V=A.filter((e=>e.progress<100)).length>o,Z=A.filter((e=>(null==e?void 0:e.status)===u.UPLOADED)).length,q=A.length-Z,H=A.length>0;return p.createElement(x.Container,{className:`${t.ComponentClassNames.StorageManager} ${H?t.ComponentClassNames.StorageManagerPreviewer:""}`},p.createElement(x.DropZone,Object.assign({},G,{displayText:h}),p.createElement(x.FilePicker,{onFileChange:e=>{const{files:a}=e.target;a&&0!==a.length&&R({files:Array.from(a),getFileErrorMessage:L})},displayText:h,acceptedFileTypes:a,allowMultipleFiles:O})),H?p.createElement(x.FileListHeader,{allUploadsSuccessful:$,displayText:h,fileCount:A.length,remainingFilesCount:q}):null,p.createElement(x.FileList,{displayText:h,files:A,isResumable:n,onCancelUpload:({id:e,uploadTask:a})=>{a.pause(),w({id:e})},onDeleteUpload:({id:e})=>{if(w({id:e}),"function"==typeof m){const a=A.find((a=>a.id===e));a&&m({key:a.key})}},onResume:({id:e,uploadTask:a})=>{a.resume(),z({id:e})},onPause:({id:e,uploadTask:a})=>{a.pause(),_({id:e})},showThumbnails:g,hasMaxFilesError:V,maxFileCount:o}))}h.Container=S,h.DropZone=U,h.FileList=N,h.FileListHeader=P,h.FilePicker=C,exports.StorageManager=h;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),a=require("aws-amplify"),t=require("@aws-amplify/ui-react"),s=require("tslib"),l=require("classnames"),r=require("@aws-amplify/ui"),n=require("@aws-amplify/ui-react/internal");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function i(e){if(e&&e.__esModule)return e;var a=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var s=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(a,t,s.get?s:{enumerable:!0,get:function(){return e[t]}})}})),a.default=e,Object.freeze(a)}var u,c,d=o(e),p=i(e),m=o(l);function g(e,a){switch(a.type){case c.ADD_FILES:{const{files:t}=a,s=t.map((e=>{const t=a.getFileErrorMessage(e);return{id:e.name,file:e,error:t,key:e.name,status:t?u.ERROR:u.QUEUED,isImage:e.type.startsWith("image/"),progress:-1}})),l=[...e.files,...s];return Object.assign(Object.assign({},e),{files:l})}case c.SET_STATUS_UPLOADING:{const{id:t,uploadTask:s}=a,{files:l}=e,r=l.reduce(((e,a)=>a.id===t?[...e,Object.assign(Object.assign({},a),{status:u.UPLOADING,progress:0,uploadTask:s||void 0})]:[...e,a]),[]);return Object.assign(Object.assign({},e),{files:r})}case c.SET_UPLOAD_PROGRESS:{const{id:t,progress:s}=a,{files:l}=e,r=l.reduce(((e,a)=>a.id===t?[...e,Object.assign(Object.assign({},a),{progress:s})]:[...e,a]),[]);return Object.assign(Object.assign({},e),{files:r})}case c.SET_STATUS:{const{id:t,status:s}=a,{files:l}=e,r=l.reduce(((e,a)=>a.id===t?[...e,Object.assign(Object.assign({},a),{status:s})]:[...e,a]),[]);return Object.assign(Object.assign({},e),{files:r})}case c.REMOVE_UPLOAD:{const{id:t}=a,{files:s}=e,l=s.reduce(((e,a)=>a.id===t?[...e]:[...e,a]),[]);return Object.assign(Object.assign({},e),{files:l})}}}!function(e){e.QUEUED="queued",e.UPLOADING="uploading",e.PAUSED="paused",e.ERROR="error",e.UPLOADED="uploaded"}(u||(u={})),function(e){e.ADD_FILES="ADD_FILES",e.SET_STATUS="SET_STATUS",e.SET_STATUS_UPLOADING="SET_STATUS_UPLOADING",e.SET_UPLOAD_PROGRESS="SET_UPLOAD_PROGRESS",e.REMOVE_UPLOAD="REMOVE_UPLOAD"}(c||(c={}));const f=({id:e,status:a})=>({type:c.SET_STATUS,id:e,status:a});function E(e=[]){const[{files:a},t]=d.default.useReducer(g,{files:e.map((e=>Object.assign(Object.assign({},e),{id:e.key,key:e.key,status:u.UPLOADED})))});return{removeUpload:({id:e})=>{t((({id:e})=>({type:c.REMOVE_UPLOAD,id:e}))({id:e}))},setUploadPaused:({id:e})=>{t(f({id:e,status:u.PAUSED}))},setUploadProgress:({progress:e,id:a})=>{t((({id:e,progress:a})=>({type:c.SET_UPLOAD_PROGRESS,id:e,progress:a}))({id:a,progress:e}))},setUploadResumed:({id:e})=>{t(f({id:e,status:u.UPLOADING}))},setUploadSuccess:({id:e})=>{t(f({id:e,status:u.UPLOADED}))},setUploadingFile:({uploadTask:e,id:a})=>{t((({id:e,uploadTask:a})=>({type:c.SET_STATUS_UPLOADING,id:e,uploadTask:a}))({id:a,uploadTask:e}))},addFiles:({files:e,getFileErrorMessage:a})=>{t((({files:e,getFileErrorMessage:a})=>({type:c.ADD_FILES,files:e,getFileErrorMessage:a}))({files:e,getFileErrorMessage:a}))},files:a}}function T(e){var{file:t,fileName:l,level:r="private",progressCallback:n,errorCallback:o,completeCallback:i,isResumable:u=!1,provider:c}=e,d=s.__rest(e,["file","fileName","level","progressCallback","errorCallback","completeCallback","isResumable","provider"]);const p=t.type||"binary/octet-stream";return!0===u?a.Storage.put(l,t,Object.assign({level:r,resumable:!0,progressCallback:n,errorCallback:o,completeCallback:i,contentType:p,provider:c},d)):a.Storage.put(l,t,Object.assign({level:r,resumable:!1,progressCallback:n,contentType:p,provider:c},d)).then(i,o)}function S({children:e,className:a}){return d.default.createElement(t.View,{className:a},e)}function U({children:e,displayText:a,inDropZone:s,onDragEnter:l,onDragLeave:o,onDragOver:i,onDragStart:u,onDrop:c,testId:p}){const{dropFilesText:g}=a;return d.default.createElement(t.View,{className:m.default(s&&r.classNameModifier(t.ComponentClassNames.StorageManagerDropZone,"active"),t.ComponentClassNames.StorageManagerDropZone),"data-testid":p,onDragStart:u,onDragEnter:l,onDragLeave:o,onDrop:c,onDragOver:i},d.default.createElement(n.IconUpload,{"aria-hidden":!0,className:t.ComponentClassNames.StorageManagerDropZoneIcon}),d.default.createElement(t.Text,{className:t.ComponentClassNames.StorageManagerDropZoneText},g),e)}const C=({errorMessage:e,getPausedText:a,getUploadingText:s,percentage:l,status:o,uploadSuccessfulText:i})=>{switch(o){case u.UPLOADING:return d.default.createElement(t.Text,{className:t.ComponentClassNames.StorageManagerFileStatus},s(l));case u.PAUSED:return d.default.createElement(t.Text,{className:t.ComponentClassNames.StorageManagerFileStatus},a(l));case u.UPLOADED:return d.default.createElement(t.Text,{className:m.default(t.ComponentClassNames.StorageManagerFileStatus,r.classNameModifier(t.ComponentClassNames.StorageManagerFileStatus,"success"))},d.default.createElement(n.IconCheck,{fontSize:"xl"})," ",i);case u.ERROR:return d.default.createElement(t.Text,{className:m.default(t.ComponentClassNames.StorageManagerFileStatus,r.classNameModifier(t.ComponentClassNames.StorageManagerFileStatus,"error"))},d.default.createElement(n.IconError,{fontSize:"xl"})," ",e);default:return null}},D=({altText:e,onClick:a})=>d.default.createElement(t.Button,{size:"small",onClick:a},d.default.createElement(t.VisuallyHidden,null,e),d.default.createElement(n.IconClose,{"aria-hidden":!0,fontSize:"medium"})),b=({displayName:e,fileSize:a})=>d.default.createElement(d.default.Fragment,null,d.default.createElement(t.View,{className:t.ComponentClassNames.StorageManagerFileMain},d.default.createElement(t.Text,{className:t.ComponentClassNames.StorageManagerFileName},e)),d.default.createElement(t.Text,{as:"span",className:t.ComponentClassNames.StorageManagerFileSize},a?r.humanFileSize(a,!0):"")),F=({fileName:e,isImage:a,url:s})=>{const l=a?d.default.createElement(t.Image,{alt:e,src:s}):d.default.createElement(n.IconFile,null);return d.default.createElement(t.View,{className:t.ComponentClassNames.StorageManagerFileImage},l)};function x({onPause:e,onResume:a,displayName:s,errorMessage:l,isImage:r,isResumable:n,loaderIsDeterminate:o,onRemove:i,progress:c,showThumbnails:p=!0,size:m,status:g,displayText:f,thumbnailUrl:E}){const{getPausedText:T,getUploadingText:S,uploadSuccessfulText:U,pauseText:x,resumeText:O}=f;return d.default.createElement(t.View,{className:t.ComponentClassNames.StorageManagerFile},d.default.createElement(t.View,{className:t.ComponentClassNames.StorageManagerFileWrapper},p?d.default.createElement(F,{isImage:r,fileName:s,url:E}):null,d.default.createElement(b,{displayName:s,fileSize:m}),g===u.UPLOADING?d.default.createElement(t.Loader,{className:t.ComponentClassNames.StorageManagerLoader,variation:"linear",percentage:c,isDeterminate:o,isPercentageTextHidden:!0}):null,!n||g!==u.UPLOADING&&g!==u.PAUSED?null:g===u.PAUSED?d.default.createElement(t.Button,{onClick:a,size:"small",variation:"link"},O):d.default.createElement(t.Button,{onClick:e,size:"small",variation:"link"},x),d.default.createElement(D,{altText:`Remove file ${s}`,onClick:i})),d.default.createElement(C,{uploadSuccessfulText:U,getUploadingText:S,getPausedText:T,status:g,errorMessage:l,percentage:c}))}function O({displayText:e,files:a,hasMaxFilesError:s,isResumable:l,onCancelUpload:r,onDeleteUpload:n,onResume:o,onPause:i,showThumbnails:c,maxFileCount:p}){if(a.length<1)return null;const{getMaxFilesErrorText:m}=e,g=m(p);return d.default.createElement(t.View,{className:t.ComponentClassNames.StorageManagerFileList},a.map((a=>{const{file:t,status:s,progress:p,error:m,key:g,isImage:f,id:E,uploadTask:T}=a,S=t&&f?URL.createObjectURL(t):"",U=!l||p>0,C=s===u.UPLOADING;return d.default.createElement(x,{displayName:g,errorMessage:m,displayText:e,isImage:f,isUploading:C,isResumable:l,key:E,loaderIsDeterminate:U,onRemove:()=>{l&&(s===u.UPLOADING||s===u.PAUSED)&&T?r({id:E,uploadTask:T}):n({id:E})},onPause:()=>{T&&i({id:E,uploadTask:T})},onResume:()=>{T&&o({id:E,uploadTask:T})},progress:p,showThumbnails:c,size:null==t?void 0:t.size,status:s,thumbnailUrl:S})})),s&&d.default.createElement(t.Alert,{variation:"error",heading:g}))}function N({fileCount:e,remainingFilesCount:a,displayText:s,allUploadsSuccessful:l}){const{getFilesUploadedText:r,getRemainingFilesText:n}=s;return d.default.createElement(t.Text,{className:t.ComponentClassNames.StorageManagerPreviewerText},l?r(e):n(a))}function P(e){var{children:a,className:l=t.ComponentClassNames.StorageManagerFilePicker,size:r="small"}=e,n=s.__rest(e,["children","className","size"]);return d.default.createElement(t.Button,Object.assign({},n,{className:l,size:r}),a)}const y=({file:e,getFileSizeErrorText:a,maxFileSize:t})=>void 0===t?"":e.size>t?a(function(e,a=!1,t=1){const s=a?1e3:1024;if(Math.abs(e)<s)return`${e} B`;const l=a?["kB","MB","GB","TB","PB","EB","ZB","YB"]:["KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"];let r=-1;const n=Math.pow(10,t);do{e/=s,++r}while(Math.round(Math.abs(e)*n)/n>=s&&r<l.length-1);return e.toFixed(t)+" "+l[r]}(t,!0)):"",k={getFilesUploadedText:e=>`${e} ${1===e?"file uploaded":"files uploaded"}`,getFileSizeErrorText:e=>`File size must be below ${e}`,getRemainingFilesText:e=>`${e} ${1===e?"file":"files"} uploading`,getUploadingText:e=>"Uploading"+(e>0?`: ${e}%`:""),getUploadButtonText:e=>`Upload ${e} ${1===e?"file":"files"}`,getMaxFilesErrorText:e=>`Cannot choose more than ${e} ${1===e?"file":"files"}. Remove files before updating`,getErrorText:e=>e,doneButtonText:"Done",clearAllButtonText:"Clear all",extensionNotAllowedText:"Extension not allowed",browseFilesText:"Browse files",dropFilesText:"Drop files here or",pauseText:"Pause",resumeText:"Resume",uploadSuccessfulText:"Uploaded successfully",getPausedText:e=>`Paused: ${e}%`},v=new a.Logger("Storage.StorageManager");function h({acceptedFileTypes:a,accessLevel:s,defaultFiles:l,displayText:r,isResumable:n=!1,maxFileCount:o,maxFileSize:i,onUploadError:c,onUploadSuccess:d,onFileRemove:m,showThumbnails:g=!0,processFile:f,components:C,provider:D,path:b}){a&&s&&o||v.warn("FileUploader requires accessLevel, acceptedFileTypes and maxFileCount props");const F=Object.assign({Container:S,DropZone:U,FileList:O,FilePicker:P,FileListHeader:N},C),x=void 0===o||"number"==typeof o&&o>1,h=Object.assign(Object.assign({},k),r),{getFileSizeErrorText:M}=h,L=e=>y({file:e,maxFileSize:i,getFileSizeErrorText:M}),{addFiles:R,files:A,removeUpload:_,setUploadingFile:j,setUploadPaused:w,setUploadProgress:I,setUploadSuccess:z,setUploadResumed:B}=E(l),G=function({onChange:a}){const[t,s]=e.useState(!1);return{onDragStart:e=>{e.dataTransfer.clearData()},onDragEnter:e=>{e.preventDefault(),e.stopPropagation()},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),s(!1)},onDragOver:e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="copy",s(!0)},onDrop:e=>{e.preventDefault(),e.stopPropagation(),s(!1),a(e)},inDropZone:t}}({onChange:e=>{const{files:t}=e.dataTransfer;if(!t||0===t.length)return;const s=((e,a)=>e.filter((e=>{const t=e.name||"",s=(e.type||"").toLowerCase(),l=s.replace(/\/.*$/,"");return a.some((e=>{const a=e.trim().toLowerCase();return"."===a.charAt(0)?t.toLowerCase().endsWith(a):a.endsWith("/*")?l===a.replace(/\/.*$/,""):s===a}))})))(Array.from(t),a);R({files:s,getFileErrorMessage:L})}});!function({files:e,accessLevel:a,isResumable:t,setUploadProgress:s,setUploadingFile:l,setUploadSuccess:r,onUploadError:n,onUploadSuccess:o,maxFileCount:i,processFile:c,provider:d,path:m=""}){p.useEffect((()=>{const p=e.filter((e=>e.status===u.QUEUED));if(!(p.length>i))for(const{file:e,key:i,id:u}of p){const p=e=>{null==o||o(e),r({id:u})},g=e=>{const a=0===e.total?100:Math.floor(e.loaded/e.total*100);s({id:u,progress:a})},f=e=>{null==n||n(e)};if(e){const s="function"==typeof c?c({file:e,key:i}):{file:e,key:i};if(t){const e=T({file:s.file,fileName:m+s.key,isResumable:!0,level:a,completeCallback:p,progressCallback:g,errorCallback:f,provider:d});l({id:u,uploadTask:e})}else T({file:s.file,fileName:m+s.key,isResumable:!1,level:a,completeCallback:p,progressCallback:g,errorCallback:f,provider:d}),l({id:u})}}}),[e,a,t,s,l,n,o,i,r,c,d,m])}({accessLevel:s,files:A,isResumable:n,maxFileCount:o,onUploadError:c,onUploadSuccess:d,setUploadingFile:j,setUploadProgress:I,setUploadSuccess:z,processFile:f,provider:D,path:b});const $=0!==A.length&&A.every((e=>100===(null==e?void 0:e.progress))),V=A.filter((e=>e.progress<100)).length>o,Z=A.filter((e=>(null==e?void 0:e.status)===u.UPLOADED)).length,q=A.length-Z,H=A.length>0,W=p.useRef(null);return p.createElement(F.Container,{className:`${t.ComponentClassNames.StorageManager} ${H?t.ComponentClassNames.StorageManagerPreviewer:""}`},p.createElement(F.DropZone,Object.assign({},G,{displayText:h}),p.createElement(p.Fragment,null,p.createElement(F.FilePicker,{onClick:function(){W.current&&(W.current.click(),W.current.value="")}},h.browseFilesText),p.createElement(t.VisuallyHidden,null,p.createElement("input",{type:"file",tabIndex:-1,ref:W,onChange:e=>{const{files:a}=e.target;a&&0!==a.length&&R({files:Array.from(a),getFileErrorMessage:L})},multiple:x,accept:a.join(",")})))),H?p.createElement(F.FileListHeader,{allUploadsSuccessful:$,displayText:h,fileCount:A.length,remainingFilesCount:q}):null,p.createElement(F.FileList,{displayText:h,files:A,isResumable:n,onCancelUpload:({id:e,uploadTask:a})=>{a.pause(),_({id:e})},onDeleteUpload:({id:e})=>{if(_({id:e}),"function"==typeof m){const a=A.find((a=>a.id===e));a&&m({key:a.key})}},onResume:({id:e,uploadTask:a})=>{a.resume(),B({id:e})},onPause:({id:e,uploadTask:a})=>{a.pause(),w({id:e})},showThumbnails:g,hasMaxFilesError:V,maxFileCount:o}))}h.Container=S,h.DropZone=U,h.FileList=O,h.FileListHeader=N,h.FilePicker=P,exports.StorageManager=h;
|
package/dist/styles.css
CHANGED
|
@@ -731,6 +731,72 @@
|
|
|
731
731
|
--amplify-components-stepperfield-button-disabled-background-color: var(--amplify-components-fieldcontrol-disabled-background-color);
|
|
732
732
|
--amplify-components-stepperfield-button-hover-color: var(--amplify-components-button-hover-color);
|
|
733
733
|
--amplify-components-stepperfield-button-hover-background-color: var(--amplify-components-button-hover-background-color);
|
|
734
|
+
--amplify-components-storagemanager-dropzone-background-color: var(--amplify-colors-background-primary);
|
|
735
|
+
--amplify-components-storagemanager-dropzone-border-radius: var(--amplify-radii-small);
|
|
736
|
+
--amplify-components-storagemanager-dropzone-border-color: var(--amplify-colors-border-primary);
|
|
737
|
+
--amplify-components-storagemanager-dropzone-border-style: dashed;
|
|
738
|
+
--amplify-components-storagemanager-dropzone-border-width: var(--amplify-border-widths-small);
|
|
739
|
+
--amplify-components-storagemanager-dropzone-gap: var(--amplify-space-small);
|
|
740
|
+
--amplify-components-storagemanager-dropzone-padding-block: var(--amplify-space-xl);
|
|
741
|
+
--amplify-components-storagemanager-dropzone-padding-inline: var(--amplify-space-large);
|
|
742
|
+
--amplify-components-storagemanager-dropzone-text-align: center;
|
|
743
|
+
--amplify-components-storagemanager-dropzone-active-background-color: var(--amplify-colors-brand-primary-10);
|
|
744
|
+
--amplify-components-storagemanager-dropzone-active-border-radius: var(--amplify-components-fileuploader-dropzone-border-radius);
|
|
745
|
+
--amplify-components-storagemanager-dropzone-active-border-color: var(--amplify-colors-border-pressed);
|
|
746
|
+
--amplify-components-storagemanager-dropzone-active-border-style: var(--amplify-components-fileuploader-dropzone-border-style);
|
|
747
|
+
--amplify-components-storagemanager-dropzone-active-border-width: var(--amplify-border-widths-medium);
|
|
748
|
+
--amplify-components-storagemanager-dropzone-icon-color: var(--amplify-colors-border-primary);
|
|
749
|
+
--amplify-components-storagemanager-dropzone-icon-font-size: var(--amplify-font-sizes-xxl);
|
|
750
|
+
--amplify-components-storagemanager-dropzone-text-color: var(--amplify-colors-font-tertiary);
|
|
751
|
+
--amplify-components-storagemanager-dropzone-text-font-size: var(--amplify-font-sizes-medium);
|
|
752
|
+
--amplify-components-storagemanager-dropzone-text-font-weight: var(--amplify-font-weights-bold);
|
|
753
|
+
--amplify-components-storagemanager-file-background-color: var(--amplify-colors-background-primary);
|
|
754
|
+
--amplify-components-storagemanager-file-border-radius: var(--amplify-radii-small);
|
|
755
|
+
--amplify-components-storagemanager-file-border-color: var(--amplify-colors-border-primary);
|
|
756
|
+
--amplify-components-storagemanager-file-border-style: solid;
|
|
757
|
+
--amplify-components-storagemanager-file-border-width: var(--amplify-border-widths-small);
|
|
758
|
+
--amplify-components-storagemanager-file-padding-block: var(--amplify-space-xs);
|
|
759
|
+
--amplify-components-storagemanager-file-padding-inline: var(--amplify-space-small);
|
|
760
|
+
--amplify-components-storagemanager-file-gap: var(--amplify-space-small);
|
|
761
|
+
--amplify-components-storagemanager-file-align-items: baseline;
|
|
762
|
+
--amplify-components-storagemanager-file-name-font-size: var(--amplify-font-sizes-medium);
|
|
763
|
+
--amplify-components-storagemanager-file-name-font-weight: var(--amplify-font-weights-bold);
|
|
764
|
+
--amplify-components-storagemanager-file-name-color: var(--amplify-colors-font-primary);
|
|
765
|
+
--amplify-components-storagemanager-file-size-font-size: var(--amplify-font-sizes-small);
|
|
766
|
+
--amplify-components-storagemanager-file-size-font-weight: var(--amplify-font-weights-normal);
|
|
767
|
+
--amplify-components-storagemanager-file-size-color: var(--amplify-colors-font-tertiary);
|
|
768
|
+
--amplify-components-storagemanager-file-image-width: var(--amplify-space-xxl);
|
|
769
|
+
--amplify-components-storagemanager-file-image-height: var(--amplify-space-xxl);
|
|
770
|
+
--amplify-components-storagemanager-file-image-background-color: var(--amplify-colors-background-secondary);
|
|
771
|
+
--amplify-components-storagemanager-file-image-color: var(--amplify-colors-font-tertiary);
|
|
772
|
+
--amplify-components-storagemanager-file-image-border-radius: var(--amplify-radii-small);
|
|
773
|
+
--amplify-components-storagemanager-loader-stroke-linecap: round;
|
|
774
|
+
--amplify-components-storagemanager-loader-stroke-empty: var(--amplify-colors-border-secondary);
|
|
775
|
+
--amplify-components-storagemanager-loader-stroke-filled: var(--amplify-components-loader-stroke-filled);
|
|
776
|
+
--amplify-components-storagemanager-loader-stroke-width: var(--amplify-border-widths-large);
|
|
777
|
+
--amplify-components-storagemanager-previewer-background-color: var(--amplify-colors-background-primary);
|
|
778
|
+
--amplify-components-storagemanager-previewer-border-color: var(--amplify-colors-border-primary);
|
|
779
|
+
--amplify-components-storagemanager-previewer-border-style: solid;
|
|
780
|
+
--amplify-components-storagemanager-previewer-border-width: var(--amplify-border-widths-small);
|
|
781
|
+
--amplify-components-storagemanager-previewer-border-radius: var(--amplify-radii-small);
|
|
782
|
+
--amplify-components-storagemanager-previewer-padding-block: var(--amplify-space-zero);
|
|
783
|
+
--amplify-components-storagemanager-previewer-padding-inline: var(--amplify-space-zero);
|
|
784
|
+
--amplify-components-storagemanager-previewer-max-height: 40rem;
|
|
785
|
+
--amplify-components-storagemanager-previewer-max-width: auto;
|
|
786
|
+
--amplify-components-storagemanager-previewer-text-font-size: var(--amplify-font-sizes-medium);
|
|
787
|
+
--amplify-components-storagemanager-previewer-text-font-weight: var(--amplify-font-weights-bold);
|
|
788
|
+
--amplify-components-storagemanager-previewer-text-color: var(--amplify-colors-font-primary);
|
|
789
|
+
--amplify-components-storagemanager-previewer-body-padding-block: var(--amplify-space-medium);
|
|
790
|
+
--amplify-components-storagemanager-previewer-body-padding-inline: var(--amplify-space-medium);
|
|
791
|
+
--amplify-components-storagemanager-previewer-body-gap: var(--amplify-space-small);
|
|
792
|
+
--amplify-components-storagemanager-previewer-footer-border-color: var(--amplify-colors-border-secondary);
|
|
793
|
+
--amplify-components-storagemanager-previewer-footer-border-style: solid;
|
|
794
|
+
--amplify-components-storagemanager-previewer-footer-border-width: var(--amplify-border-widths-small);
|
|
795
|
+
--amplify-components-storagemanager-previewer-footer-padding-block: var(--amplify-space-medium);
|
|
796
|
+
--amplify-components-storagemanager-previewer-footer-padding-inline: var(--amplify-space-medium);
|
|
797
|
+
--amplify-components-storagemanager-previewer-footer-justify-content: space-between;
|
|
798
|
+
--amplify-components-storagemanager-filelist-flex-direction: column;
|
|
799
|
+
--amplify-components-storagemanager-filelist-gap: var(--amplify-space-small);
|
|
734
800
|
--amplify-components-switchfield-disabled-opacity: var(--amplify-opacities-60);
|
|
735
801
|
--amplify-components-switchfield-focused-shadow: 0px 0px 0px 2px var(--amplify-colors-border-focus);
|
|
736
802
|
--amplify-components-switchfield-font-size: var(--amplify-font-sizes-medium);
|
|
@@ -4403,67 +4469,72 @@ html[dir=rtl] .amplify-field-group__inner-start {
|
|
|
4403
4469
|
}
|
|
4404
4470
|
|
|
4405
4471
|
.amplify-storagemanager__dropzone {
|
|
4406
|
-
background-color: var(--amplify-components-
|
|
4407
|
-
border-color: var(--amplify-components-
|
|
4408
|
-
border-radius: var(--amplify-components-
|
|
4409
|
-
border-style: var(--amplify-components-
|
|
4410
|
-
border-width: var(--amplify-components-
|
|
4411
|
-
text-align: var(--amplify-components-
|
|
4412
|
-
padding-block: var(--amplify-components-
|
|
4413
|
-
padding-inline: var(--amplify-components-
|
|
4472
|
+
background-color: var(--amplify-components-storagemanager-dropzone-background-color);
|
|
4473
|
+
border-color: var(--amplify-components-storagemanager-dropzone-border-color);
|
|
4474
|
+
border-radius: var(--amplify-components-storagemanager-dropzone-border-radius);
|
|
4475
|
+
border-style: var(--amplify-components-storagemanager-dropzone-border-style);
|
|
4476
|
+
border-width: var(--amplify-components-storagemanager-dropzone-border-width);
|
|
4477
|
+
text-align: var(--amplify-components-storagemanager-dropzone-text-align);
|
|
4478
|
+
padding-block: var(--amplify-components-storagemanager-dropzone-padding-block);
|
|
4479
|
+
padding-inline: var(--amplify-components-storagemanager-dropzone-padding-inline);
|
|
4414
4480
|
display: flex;
|
|
4415
4481
|
flex-direction: column;
|
|
4416
4482
|
align-items: center;
|
|
4417
|
-
gap: var(--amplify-components-
|
|
4483
|
+
gap: var(--amplify-components-storagemanager-dropzone-gap);
|
|
4418
4484
|
}
|
|
4419
4485
|
.amplify-storagemanager__dropzone--small {
|
|
4420
4486
|
flex-direction: row;
|
|
4421
4487
|
justify-content: center;
|
|
4422
4488
|
}
|
|
4423
4489
|
.amplify-storagemanager__dropzone--active {
|
|
4424
|
-
border-color: var(--amplify-components-
|
|
4425
|
-
border-width: var(--amplify-components-
|
|
4426
|
-
background-color: var(--amplify-components-
|
|
4490
|
+
border-color: var(--amplify-components-storagemanager-dropzone-active-border-color);
|
|
4491
|
+
border-width: var(--amplify-components-storagemanager-dropzone-active-border-width);
|
|
4492
|
+
background-color: var(--amplify-components-storagemanager-dropzone-active-background-color);
|
|
4427
4493
|
}
|
|
4428
4494
|
.amplify-storagemanager__dropzone__icon {
|
|
4429
|
-
font-size: var(--amplify-components-
|
|
4430
|
-
color: var(--amplify-components-
|
|
4495
|
+
font-size: var(--amplify-components-storagemanager-dropzone-icon-font-size);
|
|
4496
|
+
color: var(--amplify-components-storagemanager-dropzone-icon-color);
|
|
4431
4497
|
}
|
|
4432
4498
|
.amplify-storagemanager__dropzone__text {
|
|
4433
|
-
color: var(--amplify-components-
|
|
4434
|
-
font-size: var(--amplify-components-
|
|
4435
|
-
font-weight: var(--amplify-components-
|
|
4499
|
+
color: var(--amplify-components-storagemanager-dropzone-text-color);
|
|
4500
|
+
font-size: var(--amplify-components-storagemanager-dropzone-text-font-size);
|
|
4501
|
+
font-weight: var(--amplify-components-storagemanager-dropzone-text-font-weight);
|
|
4502
|
+
}
|
|
4503
|
+
.amplify-storagemanager__file__list {
|
|
4504
|
+
display: flex;
|
|
4505
|
+
flex-direction: var(--amplify-components-storagemanager-filelist-flex-direction);
|
|
4506
|
+
gap: var(--amplify-components-storagemanager-filelist-gap);
|
|
4436
4507
|
}
|
|
4437
4508
|
.amplify-storagemanager__file {
|
|
4438
4509
|
position: relative;
|
|
4439
|
-
border-width: var(--amplify-components-
|
|
4440
|
-
border-style: var(--amplify-components-
|
|
4441
|
-
border-color: var(--amplify-components-
|
|
4442
|
-
border-radius: var(--amplify-components-
|
|
4510
|
+
border-width: var(--amplify-components-storagemanager-file-border-width);
|
|
4511
|
+
border-style: var(--amplify-components-storagemanager-file-border-style);
|
|
4512
|
+
border-color: var(--amplify-components-storagemanager-file-border-color);
|
|
4513
|
+
border-radius: var(--amplify-components-storagemanager-file-border-radius);
|
|
4443
4514
|
display: flex;
|
|
4444
4515
|
flex-direction: column;
|
|
4445
|
-
padding-inline: var(--amplify-components-
|
|
4446
|
-
padding-block: var(--amplify-components-
|
|
4447
|
-
align-items: var(--amplify-components-
|
|
4516
|
+
padding-inline: var(--amplify-components-storagemanager-file-padding-inline);
|
|
4517
|
+
padding-block: var(--amplify-components-storagemanager-file-padding-block);
|
|
4518
|
+
align-items: var(--amplify-components-storagemanager-file-align-items);
|
|
4448
4519
|
}
|
|
4449
4520
|
.amplify-storagemanager__file__wrapper {
|
|
4450
4521
|
width: 100%;
|
|
4451
4522
|
display: flex;
|
|
4452
4523
|
flex-direction: row;
|
|
4453
4524
|
align-items: center;
|
|
4454
|
-
gap: var(--amplify-components-
|
|
4525
|
+
gap: var(--amplify-components-storagemanager-file-gap);
|
|
4455
4526
|
}
|
|
4456
4527
|
.amplify-storagemanager__file__name {
|
|
4457
4528
|
text-overflow: ellipsis;
|
|
4458
4529
|
overflow: hidden;
|
|
4459
|
-
font-weight: var(--amplify-components-
|
|
4460
|
-
font-size: var(--amplify-components-
|
|
4461
|
-
color: var(--amplify-components-
|
|
4530
|
+
font-weight: var(--amplify-components-storagemanager-file-name-font-weight);
|
|
4531
|
+
font-size: var(--amplify-components-storagemanager-file-name-font-size);
|
|
4532
|
+
color: var(--amplify-components-storagemanager-file-name-color);
|
|
4462
4533
|
}
|
|
4463
4534
|
.amplify-storagemanager__file__size {
|
|
4464
|
-
font-weight: var(--amplify-components-
|
|
4465
|
-
font-size: var(--amplify-components-
|
|
4466
|
-
color: var(--amplify-components-
|
|
4535
|
+
font-weight: var(--amplify-components-storagemanager-file-size-font-weight);
|
|
4536
|
+
font-size: var(--amplify-components-storagemanager-file-size-font-size);
|
|
4537
|
+
color: var(--amplify-components-storagemanager-file-size-color);
|
|
4467
4538
|
}
|
|
4468
4539
|
.amplify-storagemanager__file__main {
|
|
4469
4540
|
flex: 1;
|
|
@@ -4475,29 +4546,29 @@ html[dir=rtl] .amplify-field-group__inner-start {
|
|
|
4475
4546
|
display: flex;
|
|
4476
4547
|
align-items: center;
|
|
4477
4548
|
justify-content: center;
|
|
4478
|
-
width: var(--amplify-components-
|
|
4479
|
-
height: var(--amplify-components-
|
|
4480
|
-
background-color: var(--amplify-components-
|
|
4481
|
-
border-radius: var(--amplify-components-
|
|
4482
|
-
color: var(--amplify-components-
|
|
4549
|
+
width: var(--amplify-components-storagemanager-file-image-width);
|
|
4550
|
+
height: var(--amplify-components-storagemanager-file-image-height);
|
|
4551
|
+
background-color: var(--amplify-components-storagemanager-file-image-background-color);
|
|
4552
|
+
border-radius: var(--amplify-components-storagemanager-file-image-border-radius);
|
|
4553
|
+
color: var(--amplify-components-storagemanager-file-image-color);
|
|
4483
4554
|
}
|
|
4484
4555
|
.amplify-storagemanager__file__image img {
|
|
4485
4556
|
max-height: 100%;
|
|
4486
4557
|
}
|
|
4487
4558
|
.amplify-storagemanager__file__status--error {
|
|
4488
4559
|
color: var(--amplify-colors-font-error);
|
|
4489
|
-
font-size: var(--amplify-components-
|
|
4560
|
+
font-size: var(--amplify-components-storagemanager-file-size-font-size);
|
|
4490
4561
|
}
|
|
4491
4562
|
.amplify-storagemanager__file__status--success {
|
|
4492
4563
|
color: var(--amplify-colors-font-success);
|
|
4493
4564
|
}
|
|
4494
4565
|
.amplify-storagemanager__loader {
|
|
4495
|
-
stroke-linecap: var(--amplify-components-
|
|
4496
|
-
stroke: var(--amplify-components-
|
|
4497
|
-
stroke-width: var(--amplify-components-
|
|
4498
|
-
height: var(--amplify-components-
|
|
4566
|
+
stroke-linecap: var(--amplify-components-storagemanager-loader-stroke-linecap);
|
|
4567
|
+
stroke: var(--amplify-components-storagemanager-loader-stroke-empty);
|
|
4568
|
+
stroke-width: var(--amplify-components-storagemanager-loader-stroke-width);
|
|
4569
|
+
height: var(--amplify-components-storagemanager-loader-stroke-width);
|
|
4499
4570
|
--amplify-components-loader-linear-stroke-filled: var(
|
|
4500
|
-
--amplify-components-
|
|
4571
|
+
--amplify-components-storagemanager-loader-stroke-filled
|
|
4501
4572
|
);
|
|
4502
4573
|
overflow: hidden;
|
|
4503
4574
|
position: absolute;
|
|
@@ -4508,22 +4579,22 @@ html[dir=rtl] .amplify-field-group__inner-start {
|
|
|
4508
4579
|
.amplify-storagemanager__previewer {
|
|
4509
4580
|
display: flex;
|
|
4510
4581
|
flex-direction: column;
|
|
4511
|
-
max-width: var(--amplify-components-
|
|
4512
|
-
max-height: var(--amplify-components-
|
|
4582
|
+
max-width: var(--amplify-components-storagemanager-previewer-max-width);
|
|
4583
|
+
max-height: var(--amplify-components-storagemanager-previewer-max-height);
|
|
4513
4584
|
overflow: auto;
|
|
4514
|
-
gap: var(--amplify-components-
|
|
4515
|
-
padding-inline: var(--amplify-components-
|
|
4516
|
-
padding-block: var(--amplify-components-
|
|
4517
|
-
background-color: var(--amplify-components-
|
|
4518
|
-
border-width: var(--amplify-components-
|
|
4519
|
-
border-style: var(--amplify-components-
|
|
4520
|
-
border-color: var(--amplify-components-
|
|
4521
|
-
border-radius: var(--amplify-components-
|
|
4585
|
+
gap: var(--amplify-components-storagemanager-previewer-body-gap);
|
|
4586
|
+
padding-inline: var(--amplify-components-storagemanager-previewer-body-padding-inline);
|
|
4587
|
+
padding-block: var(--amplify-components-storagemanager-previewer-body-padding-block);
|
|
4588
|
+
background-color: var(--amplify-components-storagemanager-previewer-background-color);
|
|
4589
|
+
border-width: var(--amplify-components-storagemanager-previewer-border-width);
|
|
4590
|
+
border-style: var(--amplify-components-storagemanager-previewer-border-style);
|
|
4591
|
+
border-color: var(--amplify-components-storagemanager-previewer-border-color);
|
|
4592
|
+
border-radius: var(--amplify-components-storagemanager-previewer-border-radius);
|
|
4522
4593
|
}
|
|
4523
4594
|
.amplify-storagemanager__previewer__text {
|
|
4524
|
-
font-weight: var(--amplify-components-
|
|
4525
|
-
font-size: var(--amplify-components-
|
|
4526
|
-
color: var(--amplify-components-
|
|
4595
|
+
font-weight: var(--amplify-components-storagemanager-previewer-text-font-weight);
|
|
4596
|
+
font-size: var(--amplify-components-storagemanager-previewer-text-font-size);
|
|
4597
|
+
color: var(--amplify-components-storagemanager-previewer-text-color);
|
|
4527
4598
|
}
|
|
4528
4599
|
|
|
4529
4600
|
[data-label-position=start] {
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import { StorageManagerProps } from './types';
|
|
3
3
|
declare function StorageManager({ acceptedFileTypes, accessLevel, defaultFiles, displayText: overrideDisplayText, isResumable, maxFileCount, maxFileSize, onUploadError, onUploadSuccess, onFileRemove, showThumbnails, processFile, components, provider, path, }: StorageManagerProps): JSX.Element;
|
|
4
4
|
declare namespace StorageManager {
|
|
5
|
-
var Container: typeof import("./ui
|
|
6
|
-
var DropZone: typeof import("./ui
|
|
7
|
-
var FileList: typeof import("./ui
|
|
8
|
-
var FileListHeader: typeof import("./ui
|
|
9
|
-
var FilePicker: typeof import("./ui
|
|
5
|
+
var Container: typeof import("./ui").Container;
|
|
6
|
+
var DropZone: typeof import("./ui").DropZone;
|
|
7
|
+
var FileList: typeof import("./ui").FileList;
|
|
8
|
+
var FileListHeader: typeof import("./ui").FileListHeader;
|
|
9
|
+
var FilePicker: typeof import("./ui").FilePicker;
|
|
10
10
|
}
|
|
11
11
|
export { StorageManager };
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { StorageAccessLevel, UploadTask } from '@aws-amplify/storage';
|
|
3
|
-
import { DropZoneProps, FilePickerProps } from './ui
|
|
4
|
-
import { FileListProps } from './ui/FileList';
|
|
5
|
-
import { ContainerProps } from './ui/Container';
|
|
6
|
-
import { FileListHeaderProps } from './ui/FileListHeader';
|
|
3
|
+
import { ContainerProps, DropZoneProps, FileListHeaderProps, FileListProps, FilePickerProps } from './ui';
|
|
7
4
|
import { StorageManagerDisplayText } from './utils';
|
|
8
5
|
export declare enum FileStatus {
|
|
9
6
|
QUEUED = "queued",
|
|
@@ -39,11 +36,11 @@ export interface StorageManagerProps {
|
|
|
39
36
|
* Component overrides
|
|
40
37
|
*/
|
|
41
38
|
components?: {
|
|
42
|
-
Container?:
|
|
43
|
-
DropZone?:
|
|
44
|
-
FileList?:
|
|
45
|
-
FilePicker?:
|
|
46
|
-
FileListHeader?:
|
|
39
|
+
Container?: React.ComponentType<ContainerProps>;
|
|
40
|
+
DropZone?: React.ComponentType<DropZoneProps>;
|
|
41
|
+
FileList?: React.ComponentType<FileListProps>;
|
|
42
|
+
FilePicker?: React.ComponentType<FilePickerProps>;
|
|
43
|
+
FileListHeader?: React.ComponentType<FileListHeaderProps>;
|
|
47
44
|
};
|
|
48
45
|
/**
|
|
49
46
|
* List of default files already uploaded
|
|
@@ -11,9 +11,3 @@ export interface DropZoneProps {
|
|
|
11
11
|
onDrop: (event: React.DragEvent<HTMLDivElement>) => void;
|
|
12
12
|
testId?: string;
|
|
13
13
|
}
|
|
14
|
-
export interface FilePickerProps {
|
|
15
|
-
acceptedFileTypes: string[];
|
|
16
|
-
displayText: StorageManagerDisplayText;
|
|
17
|
-
allowMultipleFiles: boolean;
|
|
18
|
-
onFileChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
19
|
-
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Button } from '@aws-amplify/ui-react';
|
|
3
|
+
export declare type FilePickerProps = Parameters<typeof Button>[0] & {
|
|
4
|
+
onClick: React.MouseEventHandler<HTMLButtonElement>;
|
|
5
|
+
};
|
|
6
|
+
export declare function FilePicker({ children, className, size, ...props }: FilePickerProps): JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FilePicker, FilePickerProps } from './FilePicker';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { Container, ContainerProps } from './Container';
|
|
2
|
-
export { DropZone, DropZoneProps
|
|
2
|
+
export { DropZone, DropZoneProps } from './DropZone';
|
|
3
3
|
export { FileList, FileListProps } from './FileList';
|
|
4
4
|
export { FileListHeader, FileListHeaderProps } from './FileListHeader';
|
|
5
|
+
export { FilePicker, FilePickerProps } from './FilePicker';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { StorageManager, StorageManagerProps } from './StorageManager';
|
|
1
|
+
export { StorageManager, StorageManagerProps, DropZoneProps, ContainerProps, FileListProps, FilePickerProps, FileListHeaderProps, } from './StorageManager';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { StorageManager, StorageManagerProps } from './components';
|
|
1
|
+
export { StorageManager, StorageManagerProps, DropZoneProps, ContainerProps, FileListProps, FilePickerProps, FileListHeaderProps, } from './components';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-amplify/ui-react-storage",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/esm/index.mjs",
|
|
6
6
|
"exports": {
|
|
@@ -40,8 +40,9 @@
|
|
|
40
40
|
"typecheck": "tsc --noEmit"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@aws-amplify/ui": "5.5.
|
|
44
|
-
"@aws-amplify/ui-react
|
|
43
|
+
"@aws-amplify/ui": "5.5.10",
|
|
44
|
+
"@aws-amplify/ui-react": "4.5.1",
|
|
45
|
+
"@aws-amplify/ui-react-core": "2.1.18",
|
|
45
46
|
"classnames": "2.3.1",
|
|
46
47
|
"lodash": "4.17.21",
|
|
47
48
|
"tslib": "2.4.1"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import e from"react";import{View as t,Button as l,ComponentClassNames as n,VisuallyHidden as r}from"@aws-amplify/ui-react";function a({acceptedFileTypes:a,allowMultipleFiles:c,displayText:i,onFileChange:o}){const u=e.useRef(null),{browseFilesText:p}=i;return e.createElement(t,null,e.createElement(l,{className:n.StorageManagerDropZoneButton,onClick:function(){u.current&&(u.current.click(),u.current.value="")},size:"small"},p),e.createElement(r,null,e.createElement("input",{type:"file",tabIndex:-1,ref:u,onChange:o,multiple:c,accept:a.join(",")})))}export{a as FilePicker};
|