@bouko/react 0.2.2 → 0.2.3
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,2 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
|
|
3
|
-
label?: string;
|
|
4
|
-
style?: string;
|
|
5
|
-
value?: File[];
|
|
6
|
-
required?: boolean;
|
|
7
|
-
update: Dispatch<SetStateAction<File[]>>;
|
|
8
|
-
note?: string;
|
|
9
|
-
};
|
|
10
|
-
export default function Attachment({ style, update, label, required, value, note }: Props): import("react/jsx-runtime").JSX.Element;
|
|
11
|
-
export {};
|
|
1
|
+
import { type Field } from "@bouko/form";
|
|
2
|
+
export default function Attachment<T>({ id, style, label, value, update, required, note }: Field<T, File[]>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useRef } from "react";
|
|
3
3
|
import PaperClip from "../assets/icons/paperclip.svg";
|
|
4
|
+
import { setField } from "@bouko/form";
|
|
4
5
|
import { cn } from "@bouko/style";
|
|
5
|
-
export default function Attachment({
|
|
6
|
+
export default function Attachment({ id, style, label, value, update, required = true, note }) {
|
|
6
7
|
const ref = useRef(null);
|
|
7
|
-
|
|
8
|
+
const handleFileChange = (e) => {
|
|
9
|
+
if (e.target.files)
|
|
10
|
+
setField(update, id, [e.target.files[0]]);
|
|
11
|
+
};
|
|
12
|
+
return (_jsxs("div", { className: cn(styles.container, style), children: [label && _jsxs("span", { className: styles.label, children: [label, " ", !required ? _jsx("span", { className: "italic text-slate-400", children: "(optional)" }) : ""] }), _jsxs("div", { onClick: () => ref.current?.click(), className: "flex flex-col justify-center items-center py-3 gap-1 w-full cursor-pointer duration-200 hover:bg-slate-200/40 rounded border-2 border-slate-300 border-dashed", children: [!value || value.length === 0 && (_jsxs(_Fragment, { children: [_jsxs("span", { className: "flex gap-2 items-center font-semibold text-sm", children: [_jsx(PaperClip, {}), "Drag and drop files, paste screenshots, or"] }), _jsx("span", { className: "text-xs text-slate-500", children: "browse" }), _jsx("input", { type: "file", className: "hidden", onChange: handleFileChange, ref: ref })] })), value && value.length > 0 && value.map((x, i) => (_jsx("span", { className: "text-xs text-slate-500", children: x.name }, i)))] }), note && _jsx("span", { className: styles.note, children: note })] }));
|
|
8
13
|
}
|
|
9
14
|
const styles = {
|
|
10
15
|
container: "flex flex-col gap-2 overflow-hidden",
|
package/package.json
CHANGED
|
@@ -1,50 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
|
|
3
3
|
"name": "@bouko/react",
|
|
4
|
-
|
|
5
|
-
"version": "0.2.2",
|
|
6
|
-
|
|
4
|
+
"version": "0.2.3",
|
|
7
5
|
"main": "./dist/index.js",
|
|
8
|
-
|
|
9
6
|
"types": "./dist/index.d.ts",
|
|
10
|
-
|
|
11
7
|
"license": "MIT",
|
|
12
|
-
|
|
13
8
|
"files": [
|
|
14
|
-
|
|
15
9
|
"dist"
|
|
16
|
-
|
|
17
10
|
],
|
|
18
|
-
|
|
19
11
|
"publishConfig": {
|
|
20
|
-
|
|
21
12
|
"access": "public"
|
|
22
|
-
|
|
23
13
|
},
|
|
24
|
-
|
|
25
14
|
"author": "",
|
|
26
|
-
|
|
27
15
|
"description": "",
|
|
28
16
|
|
|
29
17
|
"scripts": {
|
|
30
|
-
|
|
31
18
|
"build": "tsc"
|
|
32
|
-
|
|
33
19
|
},
|
|
34
20
|
|
|
35
21
|
"dependencies": {
|
|
36
|
-
|
|
37
22
|
"@bouko/style": "^0.1.1",
|
|
38
|
-
|
|
39
23
|
"clsx": "^2.1.1",
|
|
40
|
-
|
|
41
24
|
"framer-motion": "^12.16.0",
|
|
42
|
-
|
|
43
25
|
"tailwind-merge": "^3.3.0",
|
|
44
|
-
|
|
45
26
|
"tailwind-variants": "^1.0.0"
|
|
27
|
+
},
|
|
46
28
|
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
}
|
|
29
|
+
"devDependencies": {}
|
|
50
30
|
|
|
31
|
+
}
|