@bouko/react 1.8.9 → 1.9.1

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
  }
@@ -20,6 +20,7 @@ type Props<T> = FormSection<T> & {
20
20
  label?: string;
21
21
  icon?: React.ReactNode;
22
22
  action: (data: T) => void;
23
+ cancel?: boolean;
23
24
  };
24
25
  };
25
26
  export declare function FormBuilder<T>({ fields, validator, data, styles, update, submit, clear }: Props<T>): import("react/jsx-runtime").JSX.Element;
@@ -33,5 +33,5 @@ export function FormBuilder({ fields, validator, data, styles, update, submit, c
33
33
  return (_jsx(MultipleChoice, { id: id, label: label, options: options || [], value: data[id], update: update, note: note, required: required }, id));
34
34
  else if (element === "attachment")
35
35
  return (_jsx(Attachment, { id: id, label: label, value: data[id], update: update, note: note, required: required }, id));
36
- }) }, i))), _jsxs(RowBox, { style: "items-center gap-2 mt-2 w-full", children: [_jsxs(Button, { style: cn("text-sm", styles?.submit), onClick: handleSubmit, children: [_jsx(Spinner, { className: isLoading ? "animate-spin" : "hidden" }), _jsx("div", { className: isLoading ? "hidden" : "", children: submit.icon || _jsx(CheckCircle, {}) }), submit.label || "Submit"] }), _jsxs(Button, { style: cn("text-sm text-error hover:text-error-light", styles?.cancel), variant: "ghost", onClick: clear, children: [_jsx(XCircle, {}), "Cancel"] })] })] }));
36
+ }) }, i))), _jsxs(RowBox, { style: "items-center gap-2 mt-2 w-full", children: [_jsxs(Button, { style: cn("text-sm", styles?.submit), onClick: handleSubmit, children: [_jsx(Spinner, { className: isLoading ? "animate-spin" : "hidden" }), _jsx("div", { className: isLoading ? "hidden" : "", children: submit.icon || _jsx(CheckCircle, {}) }), submit.label || "Submit"] }), submit.cancel !== false && (_jsxs(Button, { style: cn("text-sm text-error hover:text-error-light", styles?.cancel), variant: "ghost", onClick: clear, children: [_jsx(XCircle, {}), "Cancel"] }))] })] }));
37
37
  }
@@ -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";
@@ -3,5 +3,5 @@ import Field from "./field";
3
3
  import { cn } from "@bouko/style";
4
4
  import { setField } from "./form";
5
5
  export default function Input({ id, styles, style, label, required = true, note, update, ...props }) {
6
- return (_jsx(Field, { style: styles?.container, label: label, required: required, note: note, children: _jsx("input", { className: cn("px-3 py-2 bg-input border border-outline duration-200 focus:border-outline-light outline-none rounded text-sm disabled:brightness-80 disabled:cursor-not-allowed", styles?.input), onChange: ({ target: { value } }) => setField(update, id, value), ...props }) }));
6
+ return (_jsx(Field, { style: styles?.container, label: label, required: required, note: note, children: _jsx("input", { className: cn("px-3 py-2 bg-input border border-outline duration-200 focus:border-outline-light outline-none rounded text-sm disabled:brightness-90 disabled:cursor-not-allowed", styles?.input), onChange: ({ target: { value } }) => setField(update, id, value), ...props }) }));
7
7
  }
@@ -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 ?? [])[0]);
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.9",
4
+ "version": "1.9.1",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "license": "MIT",
@@ -13,6 +13,7 @@
13
13
  },
14
14
  "author": "",
15
15
  "description": "",
16
+ "engines": {},
16
17
 
17
18
  "scripts": {
18
19
  "build": "tsc"
@@ -23,7 +24,8 @@
23
24
  "clsx": "^2.1.1",
24
25
  "framer-motion": "^12.23.6",
25
26
  "tailwind-merge": "^3.3.0",
26
- "tailwind-variants": "^1.0.0"
27
+ "tailwind-variants": "^1.0.0",
28
+ "zod": "^4.0.13"
27
29
  },
28
30
 
29
31
  "devDependencies": {}
@@ -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
- };