21 lines
563 B
TypeScript
21 lines
563 B
TypeScript
|
|
import { FieldDescription } from "@repo/shadcn-ui/components/field";
|
||
|
|
|
||
|
|
export function fieldHelpId(controlId: string, text: string | undefined) {
|
||
|
|
return text?.trim() ? `${controlId}-help` : undefined;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** Ayuda discreta y accesible; nunca presenta bloques vacíos. */
|
||
|
|
export function FieldHelp({ id, text }: { id?: string | undefined; text?: string | undefined }) {
|
||
|
|
const help = text?.trim();
|
||
|
|
|
||
|
|
if (!help) {
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
|
||
|
|
return (
|
||
|
|
<FieldDescription className="text-xs whitespace-pre-line" id={id}>
|
||
|
|
{help}
|
||
|
|
</FieldDescription>
|
||
|
|
);
|
||
|
|
}
|