@bouko/react 1.8.4 → 1.8.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.
@@ -2,4 +2,4 @@ import type { ReactNode } from "react";
2
2
  export default function Badge({ style, children }: {
3
3
  style?: string;
4
4
  children: ReactNode;
5
- }): import("react/jsx-runtime").JSX.Element;
5
+ }): Promise<import("react/jsx-runtime").JSX.Element>;
@@ -1,4 +1,4 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- export default function Badge({ style, children }) {
2
+ export default async function Badge({ style, children }) {
3
3
  return (_jsx("span", { className: "w-min px-3 py-1 bg-accent/20 border border-accent-dark rounded-full text-xs text-accent-dark font-semibold", children: children }));
4
4
  }
@@ -1,5 +1,6 @@
1
1
  export { default as Heading, HeadingProps } from "./layout/heading";
2
2
  export { default as Separator } from "./layout/separator";
3
3
  export { default as Badge } from "./text/badge";
4
+ export { default as FileUploader } from "./upload/file";
4
5
  export * from "./list";
5
6
  export * from "./form";
@@ -1,5 +1,6 @@
1
1
  export { default as Heading } from "./layout/heading";
2
2
  export { default as Separator } from "./layout/separator";
3
3
  export { default as Badge } from "./text/badge";
4
+ export { default as FileUploader } from "./upload/file";
4
5
  export * from "./list";
5
6
  export * from "./form";
@@ -0,0 +1,8 @@
1
+ import type { SetState } from "../form";
2
+ type Props = {
3
+ style?: string;
4
+ accept?: string[];
5
+ update: SetState<File[]>;
6
+ };
7
+ export default function FileUploader({ style, accept, update }: Props): import("react/jsx-runtime").JSX.Element;
8
+ export {};
@@ -0,0 +1,15 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useRef } from "react";
3
+ import { cn } from "@bouko/style";
4
+ import PaperClip from "../../assets/icons/paperclip.svg";
5
+ export default function FileUploader({ style, accept = [], update }) {
6
+ const ref = useRef(null);
7
+ const upload = () => ref.current?.click();
8
+ const save = (e) => update([...(e.target.files ?? [])]);
9
+ return (_jsxs("div", { className: cn(styles.container, style), onClick: upload, children: [_jsxs("span", { className: styles.title, children: [_jsx(PaperClip, {}), "Drag and drop a file, or"] }), _jsx("span", { className: styles.subtitle, children: "browse" }), _jsx("input", { type: "file", className: "hidden", onChange: save, accept: accept.join(","), multiple: false, ref: ref })] }));
10
+ }
11
+ const styles = {
12
+ container: "flex flex-col justify-center items-center gap-1 w-full py-3 hover:bg-background-light/40 border-2 border-dashed border-border hover:border-border-light rounded overflow-hidden duration-200 cursor-pointer",
13
+ title: "flex gap-2 items-center font-semibold text-sm",
14
+ subtitle: "text-xs text-primary-darker"
15
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
 
3
3
  "name": "@bouko/react",
4
- "version": "1.8.4",
4
+ "version": "1.8.5",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "license": "MIT",
@@ -1,6 +0,0 @@
1
- type Props = {
2
- placeholder?: string;
3
- action: (query: string) => void;
4
- };
5
- export default function SearchBar({ placeholder, action }: Props): import("react/jsx-runtime").JSX.Element;
6
- export {};
@@ -1,12 +0,0 @@
1
- "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useState } from "react";
4
- import { RowBox } from "../flex";
5
- import { Button } from "../button";
6
- export default function SearchBar({ placeholder, action }) {
7
- const [query, search] = useState("");
8
- return (_jsxs(RowBox, { style: styles.container, children: [_jsxs("div", { className: "relative grow", children: [_jsx("input", { className: "w-full outline-none lowercase text-lg placeholder-slate-500 tracking-wide", placeholder: placeholder, value: query, onChange: (e) => search(e.target.value), onKeyUp: (e) => e.key === "Enter" ? action(query) : null }), _jsx("div", { className: "absolute top-0 right-0 w-12 h-full bg-gradient-to-l from-slate-950" })] }), _jsx(Button, { size: "sm", style: "gap-[0.4rem] font-extrabold py-1 px-3 font-mono", onClick: () => action(query), children: "GO" })] }));
9
- }
10
- const styles = {
11
- container: "items-center gap-6 w-xl pl-5 pr-4 py-3 bg-slate-950 border border-border rounded-md"
12
- };