@bouku/core 0.4.4 → 0.4.5

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,11 +1,13 @@
1
+ import { type ReactNode } from "react";
1
2
  type FileType = "csv" | "pdf" | "xlsx";
2
3
  type Props = {
3
4
  size?: "xs" | "sm" | "md" | "lg";
4
5
  variant?: "surface" | "accent" | "outline" | "ghost" | "error";
5
- icon?: React.ReactNode;
6
+ icon?: ReactNode;
6
7
  accept?: FileType | FileType[];
7
8
  action: (file: File) => Promise<void>;
8
9
  disabled?: boolean;
10
+ children?: ReactNode;
9
11
  };
10
- export default function FileUploader({ accept, action, disabled, ...props }: Props): import("react").JSX.Element;
12
+ export default function FileUploader({ accept, action, disabled, children, ...props }: Props): import("react").JSX.Element;
11
13
  export {};
@@ -1,9 +1,9 @@
1
1
  "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Fragment as _Fragment, jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
3
3
  import { useRef, useState, Fragment } from "react";
4
4
  import Button from "./normal.js";
5
5
  import UploadIcon from "../../assets/icons/upload.svg";
6
- export default function FileUploader({ accept, action, disabled, ...props }) {
6
+ export default function FileUploader({ accept, action, disabled, children, ...props }) {
7
7
  const ref = useRef(null);
8
8
  const [isLoading, setLoading] = useState(false);
9
9
  const fileTypes = accept ? (Array.isArray(accept) ? accept : [accept]) : undefined;
@@ -25,5 +25,5 @@ export default function FileUploader({ accept, action, disabled, ...props }) {
25
25
  if (event.target)
26
26
  event.target.value = "";
27
27
  };
28
- return (_jsxs(Fragment, { children: [_jsxs(Button, { ...props, icon: _jsx(UploadIcon, {}), action: () => ref.current?.click(), disabled: disabled || isLoading, children: ["Upload ", " ", fileTypes?.length === 1 ? fileTypes[0].toUpperCase() : "File"] }), _jsx("input", { type: "file", className: "hidden", accept: acceptAttribute, onChange: handleUpload, ref: ref })] }));
28
+ return (_jsxs(Fragment, { children: [_jsx(Button, { ...props, icon: _jsx(UploadIcon, {}), action: () => ref.current?.click(), disabled: disabled || isLoading, children: children ? children : (_jsxs(_Fragment, { children: ["Upload ", " ", fileTypes?.length === 1 ? fileTypes[0].toUpperCase() : "File"] })) }), _jsx("input", { type: "file", className: "hidden", accept: acceptAttribute, onChange: handleUpload, ref: ref })] }));
29
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bouku/core",
3
- "version": "0.4.4",
3
+ "version": "0.4.5",
4
4
  "main": "./dist/index.js",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",