sprint-asia-custom-component 0.1.147 → 0.1.149
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/index.js
CHANGED
|
@@ -224,7 +224,8 @@
|
|
|
224
224
|
icon = null,
|
|
225
225
|
positionIcon = "left",
|
|
226
226
|
//left, right // Position
|
|
227
|
-
onClick = () => {}
|
|
227
|
+
onClick = () => {},
|
|
228
|
+
isSubmit = false
|
|
228
229
|
}) => {
|
|
229
230
|
const [isPressed, setIsPressed] = React.useState(false);
|
|
230
231
|
const handleButtonPress = () => {
|
|
@@ -238,7 +239,7 @@
|
|
|
238
239
|
};
|
|
239
240
|
return /*#__PURE__*/React__default["default"].createElement("button", {
|
|
240
241
|
className: `
|
|
241
|
-
${isPressed && isActive ?
|
|
242
|
+
${isPressed && isActive ? "bg-primary700 text-white" : isActive ? "bg-primary500 hover:bg-primary600 text-white cursor-pointer" : "bg-neutral30 text-neutral80 cursor-default"}
|
|
242
243
|
${type === "full" && "w-full"}
|
|
243
244
|
${size === "small" && "text-sm h-7"}
|
|
244
245
|
${size === "medium" && "text-md h-8"}
|
|
@@ -253,7 +254,8 @@
|
|
|
253
254
|
onMouseDown: handleButtonPress,
|
|
254
255
|
onMouseUp: handleButtonRelease,
|
|
255
256
|
onTouchStart: handleButtonPress,
|
|
256
|
-
onTouchEnd: handleButtonRelease
|
|
257
|
+
onTouchEnd: handleButtonRelease,
|
|
258
|
+
type: isSubmit ? "submit" : "button"
|
|
257
259
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
258
260
|
className: "flex items-center"
|
|
259
261
|
}, isIconVisible && positionIcon == "left" && icon && /*#__PURE__*/React__default["default"].createElement("span", {
|
|
@@ -26085,7 +26087,8 @@
|
|
|
26085
26087
|
maxFiles = 1,
|
|
26086
26088
|
selectedFile,
|
|
26087
26089
|
error = "",
|
|
26088
|
-
disabled
|
|
26090
|
+
disabled,
|
|
26091
|
+
acceptExcel = false
|
|
26089
26092
|
}) => {
|
|
26090
26093
|
const [errorMessage, setErrorMessage] = React.useState("");
|
|
26091
26094
|
const onDropRejected = rejectedFiles => {
|
|
@@ -26093,20 +26096,31 @@
|
|
|
26093
26096
|
if (file.errors[0]?.code === "file-too-large") {
|
|
26094
26097
|
setErrorMessage("Your file is too large. Max file size is 5 MB");
|
|
26095
26098
|
} else if (file.errors[0]?.code === "file-invalid-type") {
|
|
26096
|
-
setErrorMessage("File format not supported. Please try again with PNG, JPEG, JPG, or PDF file within 5 MB");
|
|
26099
|
+
setErrorMessage(excelAcceptedFiles ? "File format not supported. Please try again with XLSX, XLS, CSV, or TSV file within 5 MB" : "File format not supported. Please try again with PNG, JPEG, JPG, or PDF file within 5 MB");
|
|
26097
26100
|
}
|
|
26098
26101
|
};
|
|
26102
|
+
|
|
26103
|
+
// Default file types
|
|
26104
|
+
const defaultAcceptedFiles = {
|
|
26105
|
+
"image/jpeg": [".jpeg", ".jpg"],
|
|
26106
|
+
"image/png": [".png"],
|
|
26107
|
+
"application/pdf": [".pdf"]
|
|
26108
|
+
};
|
|
26109
|
+
|
|
26110
|
+
// Additional file types
|
|
26111
|
+
const excelAcceptedFiles = {
|
|
26112
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": [".xlsx"],
|
|
26113
|
+
"application/vnd.ms-excel": [".xls"],
|
|
26114
|
+
"text/csv": [".csv"],
|
|
26115
|
+
"text/tab-separated-values": [".tsv"]
|
|
26116
|
+
};
|
|
26099
26117
|
const {
|
|
26100
26118
|
getRootProps,
|
|
26101
26119
|
getInputProps
|
|
26102
26120
|
} = useDropzone({
|
|
26103
26121
|
onDrop,
|
|
26104
26122
|
maxFiles,
|
|
26105
|
-
accept:
|
|
26106
|
-
"image/jpeg": [".jpeg", ".jpg"],
|
|
26107
|
-
"image/png": [".png"],
|
|
26108
|
-
"application/pdf": [".pdf"]
|
|
26109
|
-
},
|
|
26123
|
+
accept: acceptExcel ? excelAcceptedFiles : defaultAcceptedFiles,
|
|
26110
26124
|
noKeyboard: true,
|
|
26111
26125
|
maxSize: 5242881,
|
|
26112
26126
|
onDropRejected,
|
package/package.json
CHANGED
|
@@ -1,33 +1,40 @@
|
|
|
1
|
-
import React, { useState } from
|
|
1
|
+
import React, { useState } from "react";
|
|
2
2
|
|
|
3
3
|
const PrimaryButton = ({
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
title = "Button",
|
|
5
|
+
type = "wrap",
|
|
6
|
+
isActive = true,
|
|
7
|
+
size = "large",
|
|
8
|
+
isIconVisible = false,
|
|
9
|
+
icon = null,
|
|
10
|
+
positionIcon = "left", //left, right // Position
|
|
11
|
+
onClick = () => {},
|
|
12
|
+
isSubmit = false,
|
|
12
13
|
}) => {
|
|
13
|
-
|
|
14
|
+
const [isPressed, setIsPressed] = useState(false);
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
const handleButtonPress = () => {
|
|
17
|
+
setIsPressed(true);
|
|
18
|
+
};
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
const handleButtonRelease = () => {
|
|
21
|
+
setIsPressed(false);
|
|
22
|
+
};
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
const handleClick = (e) => {
|
|
25
|
+
onClick(e);
|
|
26
|
+
};
|
|
26
27
|
|
|
27
28
|
return (
|
|
28
29
|
<button
|
|
29
|
-
|
|
30
|
-
${
|
|
30
|
+
className={`
|
|
31
|
+
${
|
|
32
|
+
isPressed && isActive
|
|
33
|
+
? "bg-primary700 text-white"
|
|
34
|
+
: isActive
|
|
35
|
+
? "bg-primary500 hover:bg-primary600 text-white cursor-pointer"
|
|
36
|
+
: "bg-neutral30 text-neutral80 cursor-default"
|
|
37
|
+
}
|
|
31
38
|
${type === "full" && "w-full"}
|
|
32
39
|
${size === "small" && "text-sm h-7"}
|
|
33
40
|
${size === "medium" && "text-md h-8"}
|
|
@@ -36,26 +43,22 @@ const PrimaryButton = ({
|
|
|
36
43
|
${size === "extra very large" && "text-2xl h-14"}
|
|
37
44
|
${size === "detail division" && "text-sm h-10"}
|
|
38
45
|
${size === "client approval" && "text-sm h-8"}
|
|
39
|
-
rounded-lg drop-shadow-md text-center py-1.5 px-4 flex justify-center items-center`
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
rounded-lg drop-shadow-md text-center py-1.5 px-4 flex justify-center items-center`}
|
|
47
|
+
disabled={!isActive}
|
|
48
|
+
onClick={handleClick}
|
|
49
|
+
onMouseDown={handleButtonPress}
|
|
50
|
+
onMouseUp={handleButtonRelease}
|
|
51
|
+
onTouchStart={handleButtonPress}
|
|
52
|
+
onTouchEnd={handleButtonRelease}
|
|
53
|
+
type={isSubmit ? "submit" : "button"}
|
|
47
54
|
>
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
{
|
|
54
|
-
isIconVisible && positionIcon == "right" && icon && <span className='ml-1'>{icon}</span>
|
|
55
|
-
}
|
|
56
|
-
</div>
|
|
55
|
+
<div className="flex items-center">
|
|
56
|
+
{isIconVisible && positionIcon == "left" && icon && <span className="mr-1">{icon}</span>}
|
|
57
|
+
<p>{title}</p>
|
|
58
|
+
{isIconVisible && positionIcon == "right" && icon && <span className="ml-1">{icon}</span>}
|
|
59
|
+
</div>
|
|
57
60
|
</button>
|
|
58
61
|
);
|
|
59
62
|
};
|
|
60
63
|
|
|
61
|
-
export default PrimaryButton;
|
|
64
|
+
export default PrimaryButton;
|
|
@@ -11,6 +11,7 @@ const DropzoneUploadFile = ({
|
|
|
11
11
|
selectedFile,
|
|
12
12
|
error = "",
|
|
13
13
|
disabled,
|
|
14
|
+
acceptExcel = false,
|
|
14
15
|
}) => {
|
|
15
16
|
const [errorMessage, setErrorMessage] = useState("");
|
|
16
17
|
|
|
@@ -19,18 +20,33 @@ const DropzoneUploadFile = ({
|
|
|
19
20
|
if (file.errors[0]?.code === "file-too-large") {
|
|
20
21
|
setErrorMessage("Your file is too large. Max file size is 5 MB");
|
|
21
22
|
} else if (file.errors[0]?.code === "file-invalid-type") {
|
|
22
|
-
setErrorMessage(
|
|
23
|
+
setErrorMessage(
|
|
24
|
+
excelAcceptedFiles
|
|
25
|
+
? "File format not supported. Please try again with XLSX, XLS, CSV, or TSV file within 5 MB"
|
|
26
|
+
: "File format not supported. Please try again with PNG, JPEG, JPG, or PDF file within 5 MB"
|
|
27
|
+
);
|
|
23
28
|
}
|
|
24
29
|
};
|
|
25
30
|
|
|
31
|
+
// Default file types
|
|
32
|
+
const defaultAcceptedFiles = {
|
|
33
|
+
"image/jpeg": [".jpeg", ".jpg"],
|
|
34
|
+
"image/png": [".png"],
|
|
35
|
+
"application/pdf": [".pdf"],
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// Additional file types
|
|
39
|
+
const excelAcceptedFiles = {
|
|
40
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": [".xlsx"],
|
|
41
|
+
"application/vnd.ms-excel": [".xls"],
|
|
42
|
+
"text/csv": [".csv"],
|
|
43
|
+
"text/tab-separated-values": [".tsv"],
|
|
44
|
+
};
|
|
45
|
+
|
|
26
46
|
const { getRootProps, getInputProps } = useDropzone({
|
|
27
47
|
onDrop,
|
|
28
48
|
maxFiles,
|
|
29
|
-
accept:
|
|
30
|
-
"image/jpeg": [".jpeg", ".jpg"],
|
|
31
|
-
"image/png": [".png"],
|
|
32
|
-
"application/pdf": [".pdf"],
|
|
33
|
-
},
|
|
49
|
+
accept: acceptExcel ? excelAcceptedFiles : defaultAcceptedFiles,
|
|
34
50
|
noKeyboard: true,
|
|
35
51
|
maxSize: 5242881,
|
|
36
52
|
onDropRejected,
|
package/src/templates/index.js
CHANGED
|
@@ -1146,7 +1146,14 @@ const Templates = () => {
|
|
|
1146
1146
|
|
|
1147
1147
|
<div className="m-9"></div>
|
|
1148
1148
|
<p className="text-black font-bold text-2xl text-center py-2">Dropzone</p>
|
|
1149
|
-
<DropzoneUploadFile
|
|
1149
|
+
<DropzoneUploadFile
|
|
1150
|
+
title="Upload Your File"
|
|
1151
|
+
subtitle="Accepts PDF, JPEG, JPG. Max size 5 MB"
|
|
1152
|
+
required={true}
|
|
1153
|
+
onDrop={handleFileChange}
|
|
1154
|
+
selectedFile={currentImage}
|
|
1155
|
+
acceptExcel
|
|
1156
|
+
/>
|
|
1150
1157
|
|
|
1151
1158
|
<div className="m-9"></div>
|
|
1152
1159
|
<DropzoneUploadPhoto
|