2025-08-05 19:06:47 +03:00
|
|
|
import { ComponentChildren, RefObject } from "preact";
|
2025-08-04 20:34:47 +03:00
|
|
|
|
|
|
|
|
interface FormGroupProps {
|
2025-08-05 19:06:47 +03:00
|
|
|
labelRef?: RefObject<HTMLLabelElement>;
|
2025-08-06 18:38:52 +03:00
|
|
|
label?: string;
|
2025-08-04 21:17:35 +03:00
|
|
|
title?: string;
|
|
|
|
|
className?: string;
|
2025-08-04 20:34:47 +03:00
|
|
|
children: ComponentChildren;
|
2025-08-07 19:20:35 +03:00
|
|
|
description?: string | ComponentChildren;
|
2025-08-14 22:27:07 +03:00
|
|
|
disabled?: boolean;
|
2025-08-04 20:34:47 +03:00
|
|
|
}
|
|
|
|
|
|
2025-08-14 22:27:07 +03:00
|
|
|
export default function FormGroup({ label, title, className, children, description, labelRef, disabled }: FormGroupProps) {
|
2025-08-04 20:34:47 +03:00
|
|
|
return (
|
2025-08-14 22:27:07 +03:00
|
|
|
<div className={`form-group ${className} ${disabled ? "disabled" : ""}`} title={title}
|
2025-08-06 11:39:31 +03:00
|
|
|
style={{ "margin-bottom": "15px" }}>
|
2025-08-18 11:21:09 +03:00
|
|
|
{ label
|
|
|
|
|
? <label style={{ width: "100%" }} ref={labelRef}>
|
2025-08-06 18:38:52 +03:00
|
|
|
{label && <div style={{ "margin-bottom": "10px" }}>{label}</div> }
|
2025-08-06 11:39:31 +03:00
|
|
|
{children}
|
2025-08-04 20:34:47 +03:00
|
|
|
</label>
|
2025-08-18 11:21:09 +03:00
|
|
|
: children}
|
2025-08-04 21:17:35 +03:00
|
|
|
|
2025-08-05 22:11:16 +03:00
|
|
|
{description && <small className="form-text">{description}</small>}
|
2025-08-04 20:34:47 +03:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|