Skip to content

Commit aacb968

Browse files
authored
feat: support typescript
Release-As: 2.0.0
1 parent 188fd89 commit aacb968

12 files changed

+1887
-55
lines changed

commitlint.config.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = {
2+
extends: ['@commitlint/config-conventional'],
3+
rules: {
4+
'type-enum': [
5+
2,
6+
'always',
7+
['chore', 'docs', 'feat', 'fix', 'style', 'test', 'release-as']
8+
]
9+
}
10+
};

dist/index.cjs.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -3016,12 +3016,7 @@ function MultiImageInput(_ref) {
30163016
e.preventDefault();
30173017
const maxAllowedImages = max - Object.keys(files).length;
30183018
if (e.target.files.length > maxAllowedImages) {
3019-
if (props.handleError) {
3020-
props.handleError(`You cannot upload more than ${max} ${max > 1 ? 'images' : 'image'}`);
3021-
} else {
3022-
alert(`You cannot upload more than ${max} ${max > 1 ? 'images' : 'image'}`);
3023-
}
3024-
return;
3019+
throw new Error(`You cannot upload more than ${max} ${max > 1 ? 'images' : 'image'}`);
30253020
}
30263021
const selectedFiles = Array.from(e.target.files);
30273022
const imageURIs = await Promise.all(selectedFiles.map(f => {

dist/index.esm.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -2996,12 +2996,7 @@ function MultiImageInput(_ref) {
29962996
e.preventDefault();
29972997
const maxAllowedImages = max - Object.keys(files).length;
29982998
if (e.target.files.length > maxAllowedImages) {
2999-
if (props.handleError) {
3000-
props.handleError(`You cannot upload more than ${max} ${max > 1 ? 'images' : 'image'}`);
3001-
} else {
3002-
alert(`You cannot upload more than ${max} ${max > 1 ? 'images' : 'image'}`);
3003-
}
3004-
return;
2999+
throw new Error(`You cannot upload more than ${max} ${max > 1 ? 'images' : 'image'}`);
30053000
}
30063001
const selectedFiles = Array.from(e.target.files);
30073002
const imageURIs = await Promise.all(selectedFiles.map(f => {

dist/types/index.d.ts

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import * as React from 'react';
2+
3+
interface Images {
4+
[key: number]: string;
5+
}
6+
7+
interface Theme {
8+
background: string,
9+
outlineColor: string,
10+
textColor: string,
11+
buttonColor: string,
12+
modalColor: string
13+
}
14+
15+
interface Crop {
16+
unit: string,
17+
x?: number,
18+
y?: number,
19+
width?: number,
20+
height?: number
21+
}
22+
23+
interface CropConfig {
24+
aspect?: number,
25+
crop?: Crop,
26+
maxWidth: number,
27+
minWidth: number,
28+
ruleOfThirds: boolean
29+
}
30+
31+
interface MultiImageInputProps {
32+
images: Images;
33+
max?: number;
34+
setImages: (images: Images) => void;
35+
allowCrop?: boolean;
36+
cropConfig?: CropConfig;
37+
handleError?: (error: Error) => void;
38+
theme?: Theme;
39+
}
40+
41+
declare const MultiImageInput: React.FC<MultiImageInputProps>;
42+
43+
export { MultiImageInput };

0 commit comments

Comments
 (0)