@bouku/core 0.4.3 → 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?:
|
|
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 {
|
|
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: [
|
|
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
|
}
|
|
@@ -4,8 +4,8 @@ import { Fragment } from "react";
|
|
|
4
4
|
import { RowBox } from "../container/flex.js";
|
|
5
5
|
import { CheckBox } from "../miscellaneous/checkbox/index.js";
|
|
6
6
|
import { cn } from "../../utils/functions/style.js";
|
|
7
|
-
import ArrowUp from "
|
|
8
|
-
import ArrowDown from "
|
|
7
|
+
import ArrowUp from "../../assets/icons/arrow-up.svg";
|
|
8
|
+
import ArrowDown from "../../assets/icons/arrow-down.svg";
|
|
9
9
|
export const Header = ({ columnLabels, sortColumn, sortDirection, hasActions, sortBy, toggleSortDirection, selection }) => (_jsxs(RowBox, { style: s.container, children: [selection && (_jsx(RowBox, { style: s.selection, children: _jsx(CheckBox, { size: "sm", value: selection.allSelected, update: selection.toggleAll }) })), Object.entries(columnLabels).map(([col, label], i) => (_jsxs(RowBox, { style: cn(s.column, i === 0 && "justify-start"), children: [_jsx("span", { className: s.label, onClick: () => sortBy(col), children: label }), col === sortColumn && (_jsxs(Fragment, { children: [sortDirection === "desc" && _jsx(ArrowDown, { className: s.sorter, onClick: () => toggleSortDirection() }), sortDirection === "asc" && _jsx(ArrowUp, { className: s.sorter, onClick: () => toggleSortDirection() })] }))] }, i))), hasActions && (_jsx(RowBox, { style: s.column, children: _jsx("span", { children: "Actions" }) }))] }));
|
|
10
10
|
const s = {
|
|
11
11
|
container: "w-full px-4 h-11 shrink-0 bg-background-light border-b border-border",
|