@bouko/react 0.1.5 → 0.1.7

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,6 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="1em" height="1em">
2
+ <path
3
+ d="M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"
4
+ fill="currentColor"
5
+ />
6
+ </svg>
@@ -0,0 +1,2 @@
1
+ import type { OptionField } from "../core/types";
2
+ export default function Select({ style, label, required, value, options, update, note }: OptionField): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,22 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { AnimatePresence, motion } from "framer-motion";
4
+ import Chevron from "../assets/icons/chevron.svg";
5
+ import { cn } from "@bouko/style";
6
+ export default function Select({ style, label, required = true, value, options, update, note }) {
7
+ const [isOpen, setOpen] = useState(false);
8
+ const active = options.find(x => x.id === value);
9
+ const select = (x) => {
10
+ update(x);
11
+ setOpen(false);
12
+ };
13
+ return (_jsxs("div", { className: cn(styles.container, style), children: [_jsxs("div", { className: styles.subcontainer, children: [label && _jsxs("span", { className: styles.label, children: [label, " ", !required ? _jsx("span", { className: "italic text-slate-400", children: "(optional)" }) : ""] }), _jsxs("div", { className: cn(styles.trigger, !active?.label && "capitalize"), onClick: () => setOpen(x => !x), children: [active ? active.label ?? active.id : "None", _jsx(Chevron, { className: cn("text-xs text-slate-400 duration-200", isOpen && "rotate-180") })] }), note && !isOpen && _jsx("span", { className: styles.note, children: note })] }), _jsx(AnimatePresence, { children: isOpen && (_jsx(motion.div, { className: styles.dropdown, initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, children: options.map(({ id, label }) => (_jsx("span", { className: cn("w-full p-2 border-l-3 border-transparent hover:text-blue-600 duration-200 cursor-pointer", active?.id === id && "border-blue-600 bg-blue-500/10", !label && "capitalize"), onClick: () => select(id), children: label ?? id }, id))) }, "dropdown")) })] }));
14
+ }
15
+ const styles = {
16
+ container: "relative",
17
+ subcontainer: "flex flex-col gap-1 w-full",
18
+ label: "text-xs text-slate-600",
19
+ trigger: "flex justify-between items-center px-3 py-2 bg-slate-200/50 hover:bg-slate-200/80 border border-slate-300 outline-blue-500 rounded text-sm duration-200 cursor-pointer",
20
+ dropdown: "absolute mt-2 z-50 flex flex-col gap-1 w-full bg-slate-100 rounded border border-slate-300 py-1 text-xs max-h-46 overflow-y-auto",
21
+ note: "mt-1 text-xs text-slate-500"
22
+ };
@@ -0,0 +1,8 @@
1
+ import type { ReactNode, TextareaHTMLAttributes } from "react";
2
+ type Props = TextareaHTMLAttributes<HTMLTextAreaElement> & {
3
+ label?: string;
4
+ style?: string;
5
+ note?: ReactNode;
6
+ };
7
+ export default function TextArea({ style, label, required, note, ...props }: Props): import("react/jsx-runtime").JSX.Element;
8
+ 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 TextArea({ style, label, required = true, note, ...props }) {
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)" }) : ""] }), _jsx("textarea", { className: styles.textarea, ...props }), 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
+ textarea: "px-3 py-2 bg-slate-200/50 border border-slate-300 outline-blue-500 rounded text-sm resize-none",
10
+ note: "mt-1 text-xs text-slate-500"
11
+ };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
- export { default as Button } from "./components/button";
2
1
  export { default as Input } from "./components/input";
2
+ export { default as TextArea } from "./components/textarea";
3
+ export { default as Select } from "./components/select";
3
4
  export { default as MultipleChoice } from "./components/mcq";
4
5
  export { default as Attachment } from "./components/attachment";
6
+ export { default as Button } from "./components/button";
5
7
  export * from "./core/types";
package/dist/index.js CHANGED
@@ -1,5 +1,7 @@
1
- export { default as Button } from "./components/button";
2
1
  export { default as Input } from "./components/input";
2
+ export { default as TextArea } from "./components/textarea";
3
+ export { default as Select } from "./components/select";
3
4
  export { default as MultipleChoice } from "./components/mcq";
4
5
  export { default as Attachment } from "./components/attachment";
6
+ export { default as Button } from "./components/button";
5
7
  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.5",
4
+ "version": "0.1.7",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "license": "MIT",
@@ -21,6 +21,7 @@
21
21
  "dependencies": {
22
22
  "@bouko/style": "^0.1.1",
23
23
  "clsx": "^2.1.1",
24
+ "framer-motion": "^12.16.0",
24
25
  "tailwind-merge": "^3.3.0",
25
26
  "tailwind-variants": "^1.0.0"
26
27
  },