@bouko/react 1.9.1 → 1.9.2
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 { ReactNode } from "react";
|
|
2
|
+
type Option = {
|
|
3
|
+
label: ReactNode;
|
|
4
|
+
action: () => void;
|
|
5
|
+
};
|
|
6
|
+
export default function Dropdown({ options, children }: {
|
|
7
|
+
options: Option[];
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { AnimatePresence, motion } from "framer-motion";
|
|
5
|
+
export default function Dropdown({ options, children }) {
|
|
6
|
+
const [isOpen, setOpen] = useState(false);
|
|
7
|
+
const boom = (action) => {
|
|
8
|
+
action();
|
|
9
|
+
setOpen(false);
|
|
10
|
+
};
|
|
11
|
+
return (_jsxs("div", { className: styles.container, children: [_jsx("div", { onClick: () => setOpen(true), children: children }), _jsx(AnimatePresence, { children: isOpen && (_jsx(motion.div, { className: styles.dropdown, initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, children: options.map(({ label, action }, i) => (_jsx("div", { className: "cursor-pointer duration-200 hover:brightness-115", onClick: () => boom(action), children: label }, i))) }, "dropdown")) })] }));
|
|
12
|
+
}
|
|
13
|
+
const styles = {
|
|
14
|
+
container: "relative shrink-0",
|
|
15
|
+
subcontainer: "flex flex-col gap-1 w-full",
|
|
16
|
+
label: "text-xs text-slate-600",
|
|
17
|
+
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",
|
|
18
|
+
dropdown: "absolute mt-2 z-50 flex flex-col items-end justify-end gap-1 w-full bg-slate-950 rounded border border-border-dark p-3 pr-4 text-sm max-h-46 overflow-y-auto"
|
|
19
|
+
};
|
|
@@ -33,5 +33,5 @@ export function FormBuilder({ fields, validator, data, styles, update, submit, c
|
|
|
33
33
|
return (_jsx(MultipleChoice, { id: id, label: label, options: options || [], value: data[id], update: update, note: note, required: required }, id));
|
|
34
34
|
else if (element === "attachment")
|
|
35
35
|
return (_jsx(Attachment, { id: id, label: label, value: data[id], update: update, note: note, required: required }, id));
|
|
36
|
-
}) }, i))), _jsxs(RowBox, { style: "items-center gap-2 mt-2 w-full", children: [_jsxs(Button, { style: cn("text-sm", styles?.submit), onClick: handleSubmit, children: [_jsx(Spinner, { className: isLoading ? "animate-spin" : "hidden" }), _jsx("div", { className: isLoading ? "hidden" : "", children: submit.icon || _jsx(CheckCircle, {}) }), submit.label || "Submit"] }), submit.cancel !== false && (_jsxs(Button, { style: cn("text-sm text-error hover:text-error-light", styles?.cancel), variant: "ghost", onClick: clear, children: [_jsx(XCircle, {}), "Cancel"] }))] })] }));
|
|
36
|
+
}) }, i))), _jsxs(RowBox, { style: "items-center gap-2 mt-2 w-full", children: [_jsxs(Button, { style: cn("text-sm", styles?.submit), onClick: handleSubmit, disabled: !isValid, children: [_jsx(Spinner, { className: isLoading ? "animate-spin" : "hidden" }), _jsx("div", { className: isLoading ? "hidden" : "", children: submit.icon || _jsx(CheckCircle, {}) }), submit.label || "Submit"] }), submit.cancel !== false && (_jsxs(Button, { style: cn("text-sm text-error hover:text-error-light", styles?.cancel), variant: "ghost", onClick: clear, children: [_jsx(XCircle, {}), "Cancel"] }))] })] }));
|
|
37
37
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { default as Heading, HeadingProps } from "./layout/heading";
|
|
2
2
|
export { default as Separator } from "./layout/separator";
|
|
3
3
|
export { default as Badge } from "./text/badge";
|
|
4
|
+
export { default as Dropdown } from "./dropdown/normal";
|
|
4
5
|
export { default as FileUploader } from "./upload/file";
|
|
5
6
|
export * from "./list";
|
|
6
7
|
export * from "./form";
|
package/dist/components/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { default as Heading } from "./layout/heading";
|
|
2
2
|
export { default as Separator } from "./layout/separator";
|
|
3
3
|
export { default as Badge } from "./text/badge";
|
|
4
|
+
export { default as Dropdown } from "./dropdown/normal";
|
|
4
5
|
export { default as FileUploader } from "./upload/file";
|
|
5
6
|
export * from "./list";
|
|
6
7
|
export * from "./form";
|