@@ -3,9 +3,8 @@ import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
33import _slicedToArray from '@babel/runtime/helpers/slicedToArray' ;
44import React , { useState , useRef , useCallback , useEffect } from 'react' ;
55import PropTypes from 'prop-types' ;
6- import { styled , ThemeProvider } from '@mui/system' ;
7- import { Paper , Typography , Avatar , IconButton , useTheme as useTheme$1 , Box , Grid , Hidden , Button , Alert } from '@mui/material' ;
8- import { useTheme } from '@mui/material/styles' ;
6+ import { Box , Avatar , Typography , IconButton , Paper , Grid , Hidden , Button , Alert } from '@mui/material' ;
7+ import { useTheme , styled } from '@mui/material/styles' ;
98import CloseIcon from '@mui/icons-material/Close' ;
109import ArchiveOutlinedIcon from '@mui/icons-material/ArchiveOutlined' ;
1110import PlayCircleOutlineIcon from '@mui/icons-material/PlayCircleOutline' ;
@@ -40,16 +39,16 @@ function FileAttachment(props) {
4039 } ) ;
4140 }
4241
43- return /*#__PURE__*/ React . createElement ( Paper , {
44- elevation : 0 ,
45- variant : "outlined" ,
42+ return /*#__PURE__*/ React . createElement ( Box , {
4643 sx : {
44+ mb : 0 ,
4745 display : 'flex' ,
48- mb : 1 ,
49- alignItems : 'center'
46+ alignItems : 'center' ,
47+ '&:nth-of-type(even)' : {
48+ backgroundColor : theme . palette . action . hover
49+ }
5050 }
51- } , /*#__PURE__*/ React . createElement ( Typography , {
52- component : "div" ,
51+ } , /*#__PURE__*/ React . createElement ( Box , {
5352 sx : {
5453 display : 'flex' ,
5554 flexGrow : 1 ,
@@ -61,10 +60,10 @@ function FileAttachment(props) {
6160 variant : "rounded" ,
6261 sx : {
6362 m : .5 ,
63+ width : 32 ,
64+ height : 32 ,
6465 display : 'flex' ,
65- background : 'transparent' ,
66- width : theme . spacing ( 5 ) ,
67- height : theme . spacing ( 5 )
66+ background : 'transparent'
6867 }
6968 } , icon ) , /*#__PURE__*/ React . createElement ( Typography , {
7069 component : "div" ,
@@ -124,32 +123,33 @@ var StyledContainer = styled(Typography)(function (_ref) {
124123} ) ;
125124/**
126125 * @name FileUpload
127- * @description
128- * @param props
129- * @returns
126+ * @description Upload file component wrapper
127+ * @param props object
128+ * @returns React.Component
130129 */
131130
132131function FileUpload ( props ) {
133- var theme = useTheme$1 ( ) ;
134- var disabled = props . disabled ,
135- multiFile = props . multiFile ,
136- title = props . title ,
132+ var title = props . title ,
137133 header = props . header ,
134+ onError = props . onError ,
135+ disabled = props . disabled ,
136+ imageSrc = props . imageSrc ,
137+ multiFile = props . multiFile ,
138138 leftLabel = props . leftLabel ,
139139 rightLabel = props . rightLabel ,
140140 buttonLabel = props . buttonLabel ,
141+ maxFileSize = props . maxFileSize ,
142+ bannerProps = props . bannerProps ,
141143 defaultFiles = props . defaultFiles ,
142- onError = props . onError ,
143- errorSizeMessage = props . errorSizeMessage ,
144144 onFilesChange = props . onFilesChange ,
145145 maxUploadFiles = props . maxUploadFiles ,
146- maxFileSize = props . maxFileSize ,
147- filesContainerHeight = props . filesContainerHeight ,
148- maxFilesContainerHeight = props . maxFilesContainerHeight ,
149- allowedExtensions = props . allowedExtensions ,
150146 containerProps = props . containerProps ,
151- bannerProps = props . bannerProps ,
152- imageSrc = props . imageSrc ;
147+ errorSizeMessage = props . errorSizeMessage ,
148+ allowedExtensions = props . allowedExtensions ,
149+ buttonRemoveLabel = props . buttonRemoveLabel ,
150+ filesContainerHeight = props . filesContainerHeight ,
151+ maxFilesContainerHeight = props . maxFilesContainerHeight ;
152+ var theme = useTheme ( ) ;
153153
154154 var _useState = useState ( ) ,
155155 _useState2 = _slicedToArray ( _useState , 2 ) ,
@@ -193,14 +193,11 @@ function FileUpload(props) {
193193 }
194194
195195 if ( maxUploadFiles ) {
196- var _filesTab ;
197-
198- if ( maxUploadFiles - ( files . length + ( ( _filesTab = filesTab ) === null || _filesTab === void 0 ? void 0 : _filesTab . length ) ) <= 0 ) {
196+ if ( maxUploadFiles - files . length <= 0 ) {
199197 setError ( "You cannot attach more than " . concat ( maxUploadFiles , " files" ) ) ;
200198 return onError ( "You cannot attach more than " . concat ( maxUploadFiles , " files" ) ) ;
201199 }
202- } //
203-
200+ }
204201
205202 if ( window . File && window . FileReader && window . FileList && window . Blob ) {
206203 var _event$dataTransfer ;
@@ -209,7 +206,7 @@ function FileUpload(props) {
209206 var _file$type ;
210207
211208 var file = filesTab [ i ] ;
212- var extension = file === null || file === void 0 ? void 0 : ( _file$type = file . type ) === null || _file$type === void 0 ? void 0 : _file$type . split ( '/' ) [ 1 ] ; //
209+ var extension = file === null || file === void 0 ? void 0 : ( _file$type = file . type ) === null || _file$type === void 0 ? void 0 : _file$type . split ( '/' ) [ 1 ] ;
213210
214211 if ( maxFileSize && maxFileSize > 0 ) {
215212 if ( file . size > 1024 * 1024 * maxFileSize ) {
@@ -218,8 +215,7 @@ function FileUpload(props) {
218215 onError ( message ) ;
219216 return "break" ;
220217 }
221- } //
222-
218+ }
223219
224220 if ( ( allowedExtensions === null || allowedExtensions === void 0 ? void 0 : allowedExtensions . length ) > 0 ) {
225221 var isAllowed = allowedExtensions . findIndex ( function ( ext ) {
@@ -233,27 +229,26 @@ function FileUpload(props) {
233229 onError ( _message ) ;
234230 return "break" ;
235231 }
236- } //
237-
232+ }
238233
239234 var reader = new FileReader ( ) ;
240235 reader . addEventListener ( "load" , function ( ) {
241236 var obj = {
242- lastModified : file . lastModified ,
243237 name : file . name ,
244238 size : file . size ,
245239 path : this . result ,
246- extension : extension === null || extension === void 0 ? void 0 : extension . toLowerCase ( ) ,
247- contentType : file . type
240+ contentType : file . type ,
241+ lastModified : file . lastModified ,
242+ extension : extension === null || extension === void 0 ? void 0 : extension . toLowerCase ( )
248243 } ;
249244 files . push ( obj ) ;
250245 setFiles ( _toConsumableArray ( files ) ) ;
251246 } , false ) ;
252247 reader . readAsDataURL ( file ) ;
253248 } ;
254249
255- for ( var i = 0 ; i < ( ( _filesTab2 = filesTab ) === null || _filesTab2 === void 0 ? void 0 : _filesTab2 . length ) ; i ++ ) {
256- var _filesTab2 ;
250+ for ( var i = 0 ; i < ( ( _filesTab = filesTab ) === null || _filesTab === void 0 ? void 0 : _filesTab . length ) ; i ++ ) {
251+ var _filesTab ;
257252
258253 var _ret = _loop ( i ) ;
259254
@@ -280,7 +275,10 @@ function FileUpload(props) {
280275 return onFilesChange ( [ ] ) ;
281276 }
282277
283- if ( index < 0 || index > files . length - 1 ) return ;
278+ if ( index < 0 || index > files . length - 1 ) {
279+ return ;
280+ }
281+
284282 files === null || files === void 0 ? void 0 : files . splice ( index , 1 ) ;
285283 setFiles ( _toConsumableArray ( files ) ) ;
286284 } ;
@@ -349,12 +347,9 @@ function FileUpload(props) {
349347 onFilesChange ( _toConsumableArray ( files ) ) ;
350348 } // eslint-disable-next-line
351349
352- } , [ files ] ) ; //
353-
350+ } , [ files ] ) ;
354351 var background = animate ? theme . palette . secondary . light : theme . palette . primary . light ;
355- return /*#__PURE__*/ React . createElement ( ThemeProvider , {
356- theme : theme
357- } , /*#__PURE__*/ React . createElement ( Paper , _extends ( {
352+ return /*#__PURE__*/ React . createElement ( Paper , _extends ( {
358353 sx : {
359354 p : 1
360355 } ,
@@ -498,7 +493,7 @@ function FileUpload(props) {
498493 size : "small" ,
499494 disabled : disabled ,
500495 onClick : handleRemoveFile
501- } , " Remove all" ) ) ) ) ) ;
496+ } , buttonRemoveLabel || ' Remove all' ) ) ) ) ;
502497}
503498
504499FileUpload . propTypes = {
0 commit comments