Files
HiveGrid-Wireframes/03 Quellen und Referenzen/hivegrid-cloud/apps/web/app/components/screens/tasks/DateField.tsx
T

37 lines
1.5 KiB
TypeScript

// Interim-UI helper (AD-28): a labeled native <input type="date"> for server forms.
// Deliberate exception to "compose from ~/ui" — the ~/ui TextInput.Input type prop
// excludes "date" and the ~/ui DatePicker is a controlled component that does not
// submit a form field. Styled with the same design tokens as ~/ui inputs (control
// height Medium 36 = h-9, radius small 4, neutral border/text) so it reads David-near.
export type DateFieldProps = {
label: string;
name: string;
defaultValue?: string;
value?: string;
onChange?: (value: string) => void;
required?: boolean;
/** Width override; the field fills its column by default. */
className?: string;
};
export function DateField({ label, name, defaultValue, value, onChange, required, className }: DateFieldProps) {
return (
<label className={`flex w-full flex-col gap-1 ${className ?? ""}`}>
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-tertiary">
{label}
{required ? " *" : ""}
</span>
<input
type="date"
name={name}
defaultValue={defaultValue}
value={value}
onChange={onChange ? (event) => onChange(event.target.value) : undefined}
required={required}
className="h-9 w-full rounded-[4px] border border-solid border-border-default bg-transparent px-3 text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-primary outline-none"
/>
</label>
);
}