@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.
@@ -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,6 @@
1
+ import type { Field as FieldProps } from "../core/types";
2
+ type Props = FieldProps & {
3
+ placeholder?: string;
4
+ };
5
+ export default function Input({ style, label, required, note, update, ...props }: Props): import("react/jsx-runtime").JSX.Element;
6
+ export {};
@@ -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,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) }), 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
@@ -1 +1,4 @@
1
1
  export { default as Button } from "./components/button";
2
+ export { default as Input } from "./components/input";
3
+ export { default as MultipleChoice } from "./components/mcq";
4
+ export * from "./core/types";
package/dist/index.js CHANGED
@@ -1 +1,4 @@
1
1
  export { default as Button } from "./components/button";
2
+ export { default as Input } from "./components/input";
3
+ export { default as MultipleChoice } from "./components/mcq";
4
+ export * from "./core/types";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
 
3
3
  "name": "@bouko/react",
4
- "version": "0.1.2",
4
+ "version": "0.1.4",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "license": "MIT",