@bouku/core 0.1.5 → 0.1.6
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.
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
type FileType = "csv";
|
|
1
|
+
type FileType = "csv" | "pdf";
|
|
2
2
|
type Props<T> = {
|
|
3
3
|
type?: FileType | FileType[];
|
|
4
|
+
variant?: "accent" | "surface";
|
|
4
5
|
url: string;
|
|
5
6
|
next?: (data: T) => void;
|
|
6
7
|
oops?: (err: string) => void;
|
|
7
8
|
};
|
|
8
|
-
export default function FileUploader<T>({ type, url, next, oops }: Props<T>): import("react").JSX.Element;
|
|
9
|
+
export default function FileUploader<T>({ type, variant, url, next, oops }: Props<T>): import("react").JSX.Element;
|
|
9
10
|
export {};
|
|
@@ -10,7 +10,7 @@ const react_1 = require("react");
|
|
|
10
10
|
const upload_svg_1 = __importDefault(require("../../assets/icons/upload.svg"));
|
|
11
11
|
const core_1 = require("@bouku/core");
|
|
12
12
|
const snatch_http_1 = require("snatch-http");
|
|
13
|
-
function FileUploader({ type, url, next, oops }) {
|
|
13
|
+
function FileUploader({ type, variant = "accent", url, next, oops }) {
|
|
14
14
|
const inputRef = (0, react_1.useRef)(null);
|
|
15
15
|
const clickButton = () => inputRef.current?.click();
|
|
16
16
|
const [isLoading, setLoading] = (0, react_1.useState)(false);
|
|
@@ -38,5 +38,5 @@ function FileUploader({ type, url, next, oops }) {
|
|
|
38
38
|
if (event.target)
|
|
39
39
|
event.target.value = "";
|
|
40
40
|
};
|
|
41
|
-
return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(core_1.Button, { variant:
|
|
41
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(core_1.Button, { variant: variant, action: clickButton, disabled: isLoading, children: [(0, jsx_runtime_1.jsx)(upload_svg_1.default, {}), "Upload ", typesArray?.length === 1 ? typesArray[0].toUpperCase() : "File"] }), (0, jsx_runtime_1.jsx)("input", { ref: inputRef, type: "file", className: "hidden", accept: acceptAttribute, onChange: handleUpload })] }));
|
|
42
42
|
}
|