// This file is part of Shadcn Admin Kit (https://github.com/marmelab/shadcn-admin-kit) /* eslint-disable @typescript-eslint/no-explicit-any */ import type { HTMLAttributes } from "react"; import { useFieldValue, useTranslate } from "ra-core"; import type { FieldProps } from "@/lib/field.type.ts"; export const TextField = < RecordType extends Record = Record, >({ defaultValue, source, record, empty, ...rest }: TextFieldProps) => { const value = useFieldValue({ defaultValue, source, record }); const translate = useTranslate(); if (value == null) { if (!empty) { return null; } return ( {typeof empty === "string" ? translate(empty, { _: empty }) : empty} ); } return ( {typeof value !== "string" ? value.toString() : value} ); }; export interface TextFieldProps< RecordType extends Record = Record, > extends FieldProps, HTMLAttributes {}