Skip to content

Commit 43286f8

Browse files
committed
rebase pull request #13
1 parent c634a21 commit 43286f8

24 files changed

+2083
-10223
lines changed

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
**/*.js
2+
/dist

.eslintrc.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
3+
extends: [
4+
'plugin:react/recommended', // Uses the recommended rules from @eslint-plugin-react
5+
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
6+
//'prettier/@typescript-eslint', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
7+
//'plugin:prettier/recommended', // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
8+
],
9+
parserOptions: {
10+
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
11+
sourceType: 'module', // Allows for the use of imports
12+
ecmaFeatures: {
13+
jsx: true, // Allows for the parsing of JSX
14+
},
15+
},
16+
rules: {
17+
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
18+
// e.g. "@typescript-eslint/explicit-function-return-type": "off",
19+
},
20+
settings: {
21+
react: {
22+
version: 'detect', // Tells eslint-plugin-react to automatically detect the version of React to use
23+
},
24+
},
25+
}

.prettierrc.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
semi: false,
3+
trailingComma: 'all',
4+
singleQuote: true,
5+
printWidth: 120,
6+
tabWidth: 2,
7+
}

CHANGELOG.md

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,57 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

88

9+
## [1.0.0] - 2023-01-08
10+
11+
### Added
12+
PlaceholderImageDimension
13+
- Support of typescript
14+
15+
- Make `onContextReady` callback optional
16+
17+
- Add prop `showPlaceholderImage` to show or hide the placeholder image
18+
19+
- Add prop `PlaceholderGridProps` to customize the placeholder `Grid` props
20+
21+
- Add prop `LabelsGridProps` to customize the labels `Grid` props
22+
23+
### Changed
24+
25+
- Typecript definition file has been improved
26+
27+
- Update `@babel/core` dependency to v7.20.12 and `rollup` to v3.9.1
28+
29+
- README.md improved by [@mikocot](https://github.com/mikocot) to show a real usecase of the library
30+
31+
### Removed
32+
33+
- `@mui/styles` has been removed
34+
35+
### Fixed
36+
37+
- Improve typo in README.md
38+
39+
### Deprecated
40+
41+
42+
## [0.4.1] - 2023-01-05
43+
44+
### Added
45+
46+
- Add `onFilesChange` callback to return files according to getBase64 prop where input files change
47+
48+
- Add project source map files
49+
50+
### Changed
51+
52+
### Removed
53+
54+
### Fixed
55+
56+
- Improve typo in README.md
57+
58+
### Deprecated
59+
960

1061
## [0.4.0] - 2022-12-31
1162

@@ -22,17 +73,17 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2273
### Changed
2374

2475
- Project npm packages updated
25-
26-
- `containerProps` prop replaced with `ContainerProps`
27-
28-
- `bannerProps` prop replaced with `BannerProps`
2976

3077
### Removed
3178

3279
### Fixed
3380

3481
### Deprecated
3582

83+
- `containerProps` prop replaced with `ContainerProps`
84+
85+
- `bannerProps` prop replaced with `BannerProps`
86+
3687

3788
## [0.3.0] - 2022-11-03
3889

README.md

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ return (
5555
onError={handleFileUploadError}
5656
imageSrc={'path/to/custom/image'}
5757
BannerProps={{ elevation: 0, variant: "outlined" }}
58+
showPlaceholderImage={true}
59+
PlaceholderGridProps={{ md: 4 }}
60+
LabelsGridProps={{ md: 8 }}
5861
onContextReady={context => {
5962
// access to component context here
6063
}}
@@ -71,34 +74,33 @@ return (
7174
}}
7275
/>
7376
)
74-
7577
```
7678

7779
## 🎨 Possible application
7880

7981
```javascript
80-
import React, { useState } from "react";
81-
import { createRoot } from "react-dom/client";
82-
import FileUpload from "react-mui-fileuploader";
82+
import React, { useState } from "react"
83+
import { createRoot } from "react-dom/client"
84+
import FileUpload from "react-mui-fileuploader"
8385

8486
function MuiFileUploader() {
85-
const [filesToUpload, setFilesToUpload] = useState([]);
87+
const [filesToUpload, setFilesToUpload] = useState([])
8688

8789
const handleFilesChange = (files) => {
8890
// Update chosen files
89-
setFilesToUpload([...files]);
91+
setFilesToUpload([ ...files ])
9092
};
9193

9294
const uploadFiles = () => {
9395
// Create a form and post it to server
94-
let formData = new FormData();
95-
filesToUpload.forEach((file) => formData.append("files", file));
96+
let formData = new FormData()
97+
filesToUpload.forEach((file) => formData.append("files", file))
9698

9799
fetch("/file/upload", {
98100
method: "POST",
99101
body: formData
100-
});
101-
};
102+
})
103+
}
102104

103105
return (
104106
<>
@@ -109,11 +111,11 @@ function MuiFileUploader() {
109111
/>
110112
<button onClick={uploadFiles}>Upload</button>
111113
</>
112-
);
114+
)
113115
}
114116

115-
const root = createRoot(document.getElementById("root"));
116-
root.render(<MuiFileUploader />);
117+
const root = createRoot(document.getElementById("root"))
118+
root.render(<MuiFileUploader />)
117119
```
118120

119121
[![Edit react-mui-fileuploader example](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/thirsty-visvesvaraya-r9u6ho?fontsize=14&hidenavigation=1&theme=dark)
@@ -126,6 +128,7 @@ root.render(<MuiFileUploader />);
126128
| multiFile | `boolean` | `false` | Multifile support. Default value `true` |
127129
| title | `string` | `false` | Component title |
128130
| header | `string` | `false` | Banner component big title |
131+
| showPlaceholderImage | `boolean` | `false` | Show or hide placeholder image |
129132
| imageSrc | `string` | `false` | Banner image placeholder source path |
130133
| imageSrcAlt | `string` | `false` | Banner image placeholder label |
131134
| leftLabel | `string` | `false` | Banner left label |
@@ -146,6 +149,8 @@ root.render(<MuiFileUploader />);
146149
| BannerProps | `object` | `false` | Banner props. Only MUI props are accepted |
147150
| ContainerProps | `object` | `false` | Container props. Only MUI props are accepted |
148151
| PlaceholderImageDimension | `object` | `false` | Dimensions (width and height) of the placeholder image. You can specify them in the properties `xs: {width: 64, height: 64}`, `sm: {width: 64, height: 64}`, `md: {width: 64, height: 64}`, `lg: {width: 64, height: 64}`, etc. |
152+
| PlaceholderGridProps | `object` | `false` | Customize the placeholder Grid `xs`, `sm`, `md`, `lg`, `xl` sizes |
153+
| LabelsGridProps | `object` | `false` | Customize the labels Grid `xs`, `sm`, `md`, `lg`, `xl` sizes |
149154

150155
## 😁 Authors
151156

@@ -177,7 +182,7 @@ root.render(<MuiFileUploader />);
177182

178183
MIT License
179184

180-
Copyright (c) 2022 rouftom
185+
Copyright (c) 2023 rouftom
181186

182187
Permission is hereby granted, free of charge, to any person obtaining a copy
183188
of this software and associated documentation files (the "Software"), to deal

dist/index.esm.js

Lines changed: 459 additions & 538 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.esm.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)