@bouko/react 0.2.2 → 0.2.4
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.
- package/dist/assets/icons/check.svg +6 -0
- package/dist/components/attachment.d.ts +2 -11
- package/dist/components/attachment.js +8 -3
- package/dist/components/checkbox.d.ts +8 -0
- package/dist/components/checkbox.js +13 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +4 -23
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" width="1em" height="1em">
|
|
2
|
+
<path
|
|
3
|
+
d="M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"
|
|
4
|
+
fill="currentColor"
|
|
5
|
+
/>
|
|
6
|
+
</svg>
|
|
@@ -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",
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import Check from "@/assets/icons/check.svg";
|
|
3
|
+
import { cn } from "@bouko/style";
|
|
4
|
+
export default function Checkbox({ style, label, value, update }) {
|
|
5
|
+
const isChecked = !!value;
|
|
6
|
+
return (_jsxs("div", { className: cn(styles.container, style), children: [_jsx("div", { className: cn(styles.box, isChecked && "bg-accent"), onClick: () => update(!isChecked), children: isChecked && _jsx(Check, { className: styles.check }) }), _jsx("span", { className: styles.label, children: label })] }));
|
|
7
|
+
}
|
|
8
|
+
const styles = {
|
|
9
|
+
container: "flex gap-3 items-center",
|
|
10
|
+
box: "flex justify-center items-center size-4 min-w-4 hover:bg-accent border rounded border-border-light duration-200 cursor-pointer",
|
|
11
|
+
check: "size-2 text-background",
|
|
12
|
+
label: "text-xs text-primary-dark"
|
|
13
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -4,5 +4,6 @@ export { default as Select } from "./components/select";
|
|
|
4
4
|
export { default as MultipleChoice } from "./components/mcq";
|
|
5
5
|
export { default as Attachment } from "./components/attachment";
|
|
6
6
|
export { default as Button } from "./components/button";
|
|
7
|
+
export { default as CheckBox } from "./components/checkbox";
|
|
7
8
|
export * from "./components/flex";
|
|
8
9
|
export * from "./core/types";
|
package/dist/index.js
CHANGED
|
@@ -4,5 +4,6 @@ export { default as Select } from "./components/select";
|
|
|
4
4
|
export { default as MultipleChoice } from "./components/mcq";
|
|
5
5
|
export { default as Attachment } from "./components/attachment";
|
|
6
6
|
export { default as Button } from "./components/button";
|
|
7
|
+
export { default as CheckBox } from "./components/checkbox";
|
|
7
8
|
export * from "./components/flex";
|
|
8
9
|
export * from "./core/types";
|
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.4",
|
|
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
|
+
}
|