44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
import * as React from "react"
|
|
|
|
import { cn } from "../lib/utils"
|
|
import { Label } from "../ui/label"
|
|
|
|
/** Подзаголовок группы полей формы. */
|
|
export function FormSection({ title, children }: { title: string; children: React.ReactNode }) {
|
|
return (
|
|
<section className="space-y-4">
|
|
<h2 className="text-xs font-semibold tracking-[0.12em] text-muted-foreground uppercase">{title}</h2>
|
|
{children}
|
|
</section>
|
|
)
|
|
}
|
|
|
|
/** Подпись, поле, подсказка или ошибка под ним. */
|
|
export function FormField({
|
|
label,
|
|
htmlFor,
|
|
hint,
|
|
error,
|
|
className,
|
|
children,
|
|
}: {
|
|
label: string
|
|
htmlFor?: string
|
|
hint?: string
|
|
error?: string
|
|
className?: string
|
|
children: React.ReactNode
|
|
}) {
|
|
return (
|
|
<div className={cn("space-y-1.5", className)}>
|
|
<Label htmlFor={htmlFor}>{label}</Label>
|
|
{children}
|
|
{error ? (
|
|
<p className="text-xs text-destructive">{error}</p>
|
|
) : hint ? (
|
|
<p className="text-xs text-muted-foreground">{hint}</p>
|
|
) : null}
|
|
</div>
|
|
)
|
|
}
|