@bouko/react 0.1.2 → 0.1.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/components/field.d.ts +10 -0
- package/dist/components/field.js +11 -0
- package/dist/components/input.d.ts +6 -0
- package/dist/components/input.js +5 -0
- package/dist/components/mcq.d.ts +2 -0
- package/dist/components/mcq.js +12 -0
- package/dist/core/types.d.ts +18 -0
- package/dist/core/types.js +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/package.json +1 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { InputHTMLAttributes, ReactNode } from "react";
|
|
2
|
+
type Props = InputHTMLAttributes<HTMLInputElement> & {
|
|
3
|
+
label?: string;
|
|
4
|
+
style?: string;
|
|
5
|
+
required?: boolean;
|
|
6
|
+
note?: string;
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
};
|
|
9
|
+
export default function Field({ style, label, required, note, children }: Props): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "@bouko/style";
|
|
3
|
+
export default function Field({ style, label, required = true, note, children }) {
|
|
4
|
+
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)" }) : ""] }), children, note && _jsx("span", { className: styles.note, children: note })] }));
|
|
5
|
+
}
|
|
6
|
+
const styles = {
|
|
7
|
+
container: "flex flex-col gap-1 overflow-hidden",
|
|
8
|
+
label: "text-xs text-slate-600",
|
|
9
|
+
input: "px-3 py-2 bg-slate-200/50 border border-slate-300 outline-blue-500 rounded text-sm",
|
|
10
|
+
note: "mt-1 text-xs text-slate-500"
|
|
11
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import Field from "./field";
|
|
3
|
+
export default function Input({ style, label, required = true, note, update, ...props }) {
|
|
4
|
+
return (_jsx(Field, { style: style, label: label, required: required, note: note, children: _jsx("input", { className: "px-3 py-2 bg-slate-200/50 border border-slate-300 outline-blue-500 rounded text-sm", onChange: ({ target: { value } }) => update(value), ...props }) }));
|
|
5
|
+
}
|
|
@@ -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) }), 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,18 @@
|
|
|
1
|
+
import type { Dispatch, SetStateAction } from "react";
|
|
2
|
+
export type Field = {
|
|
3
|
+
label?: string;
|
|
4
|
+
style?: string;
|
|
5
|
+
value?: string;
|
|
6
|
+
update: Dispatch<SetStateAction<string>>;
|
|
7
|
+
required?: boolean;
|
|
8
|
+
note?: string;
|
|
9
|
+
};
|
|
10
|
+
export type Option = {
|
|
11
|
+
id: string;
|
|
12
|
+
label?: string;
|
|
13
|
+
active?: boolean;
|
|
14
|
+
select?: () => void;
|
|
15
|
+
};
|
|
16
|
+
export type OptionField = Field & {
|
|
17
|
+
options: Option[];
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED