@bouko/react 0.2.4 → 0.2.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.
@@ -0,0 +1,2 @@
1
+ import type { OptionField } from "../core/types";
2
+ export default function MultipleChoice({ label, options, style, value, update, required }: OptionField): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,12 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import Field from "./field";
3
+ import { cn } from "@bouko/style";
4
+ export default function MultipleChoice({ label, options, style, value, update, required = true }) {
5
+ return (_jsx(Field, { style: style, label: label, required: required, children: _jsx("div", { className: styles.options, children: options.map((x, i) => (_jsxs("div", { className: styles.item, children: [_jsx(Dot, { ...x, active: x.id === value, select: () => update(x.id) }), x.label] }, i))) }) }));
6
+ }
7
+ const Dot = ({ active, select }) => (_jsx("div", { className: cn(styles.dot, active && "bg-accent border-accent-dark"), onClick: select }));
8
+ const styles = {
9
+ options: "flex flex-col gap-1 w-full",
10
+ item: "flex items-center gap-3 text-sm",
11
+ dot: "size-3 bg-background-dark/50 hover:bg-background-dark duration-200 cursor-pointer border border-background-dark rounded-full"
12
+ };
@@ -0,0 +1 @@
1
+ export declare const getFileData: (files: File[]) => Promise<unknown[]>;
@@ -0,0 +1,15 @@
1
+ export const getFileData = (files) => Promise.all(files.map((file) => {
2
+ return new Promise((resolve, reject) => {
3
+ const reader = new FileReader();
4
+ reader.onload = () => {
5
+ const base64 = reader.result?.toString().split(",")[1]; // Remove data prefix
6
+ resolve({
7
+ filename: file.name,
8
+ mimetype: file.type,
9
+ data: base64,
10
+ });
11
+ };
12
+ reader.onerror = reject;
13
+ reader.readAsDataURL(file);
14
+ });
15
+ }));
package/dist/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  export { default as Input } from "./components/input";
2
2
  export { default as TextArea } from "./components/textarea";
3
3
  export { default as Select } from "./components/select";
4
- export { default as MultipleChoice } from "./components/mcq";
4
+ export { default as MultipleChoice } from "./components/multiple-choice";
5
5
  export { default as Attachment } from "./components/attachment";
6
6
  export { default as Button } from "./components/button";
7
7
  export { default as CheckBox } from "./components/checkbox";
8
8
  export * from "./components/flex";
9
9
  export * from "./core/types";
10
+ export * from "./core/functions";
package/dist/index.js CHANGED
@@ -1,9 +1,10 @@
1
1
  export { default as Input } from "./components/input";
2
2
  export { default as TextArea } from "./components/textarea";
3
3
  export { default as Select } from "./components/select";
4
- export { default as MultipleChoice } from "./components/mcq";
4
+ export { default as MultipleChoice } from "./components/multiple-choice";
5
5
  export { default as Attachment } from "./components/attachment";
6
6
  export { default as Button } from "./components/button";
7
7
  export { default as CheckBox } from "./components/checkbox";
8
8
  export * from "./components/flex";
9
9
  export * from "./core/types";
10
+ export * from "./core/functions";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
 
3
3
  "name": "@bouko/react",
4
- "version": "0.2.4",
4
+ "version": "0.2.5",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "license": "MIT",