diff --git a/components/form/Field.tsx b/components/form/Field.tsx index 8e5c353..3c17962 100644 --- a/components/form/Field.tsx +++ b/components/form/Field.tsx @@ -9,6 +9,7 @@ import { TypeTag } from "./field/TypeTag"; import get from "lodash.get"; import { getNumber } from "@/lib/utils/getNumber"; import { useLocal } from "@/lib/utils/use-local"; +import { FieldRadio } from "./field/TypeRadio"; export const Field: React.FC = ({ fm, @@ -80,7 +81,18 @@ export const Field: React.FC = ({ border: 0px !important; box-shadow: none; } - ` + `, + style === "gform" && + css` + .field input { + padding-left: 0px !important; + padding-right: 0px !important; + } + .field textarea { + padding-left: 0px !important; + padding-right: 0px !important; + } + ` )} > {!hidden_label ? ( @@ -105,17 +117,26 @@ export const Field: React.FC = ({ : "border border-gray-300 ", "relative field", !is_disable - ? style === "underline" - ? "focus-within:border-b focus-within:border-b-gray-500" - : "focus-within:border focus-within:border-gray-500" + ? style === "underline" || style === "gform" + ? "focus-within:border-b focus-within:border-b-primary" + : "focus-within:border focus-within:border-primary" : "", - - style === "underline" + style === "underline" || style === "gform" ? "rounded-none border-transparent border-b-gray-300" : "", - ["rating", "color", "single-checkbox", "checkbox"].includes(type) && + [ + "rating", + "color", + "single-checkbox", + "radio", + "checkbox", + ].includes(type) && css` border: 0px !important; + `, + ["upload"].includes(type) && + css` + padding: 0px !important; ` )} > @@ -192,6 +213,18 @@ export const Field: React.FC = ({ className={className} /> + ) : ["radio"].includes(type) ? ( + <> + + ) : ["single-checkbox"].includes(type) ? ( <> = ({ isChecked && "active" )} > - {isChecked ? ( - - - - ) : ( - - - - )} +
+ {isChecked ? ( + + + + ) : ( + + + + )} +
+
{item.label}
); diff --git a/components/form/field/TypeInput.tsx b/components/form/field/TypeInput.tsx index 2ca284b..b84f37c 100644 --- a/components/form/field/TypeInput.tsx +++ b/components/form/field/TypeInput.tsx @@ -2,7 +2,7 @@ import { useLocal } from "@/lib/utils/use-local"; import Datepicker from "../../ui/Datepicker"; import { Input } from "../../ui/input"; import { Textarea } from "../../ui/text-area"; -import { useEffect, useState } from "react"; +import { useEffect, useRef, useState } from "react"; import tinycolor from "tinycolor2"; import { FieldColorPicker } from "../../ui/FieldColorPopover"; import { FaRegStar, FaStar } from "react-icons/fa6"; @@ -22,6 +22,7 @@ export const TypeInput: React.FC = ({ className, }) => { const [hover, setHover] = useState(0); // State untuk menyimpan nilai hover + const textareaRef = useRef(null); let value: any = fm.data?.[name] || ""; const [rating, setRating] = useState(value); // State untuk menyimpan nilai rating @@ -41,6 +42,13 @@ export const TypeInput: React.FC = ({ rgbValue: "", selectedEd: "" as string, }); + const handleInput = () => { + const textarea = textareaRef.current; + if (textarea) { + textarea.style.height = "auto"; // Reset height to calculate new height + textarea.style.height = `${textarea.scrollHeight}px`; // Adjust height based on content + } + }; useEffect(() => { if (type === "color") { meta.inputValue = value || ""; @@ -66,7 +74,9 @@ export const TypeInput: React.FC = ({ return ( <>