-
onChange(e.target.value)}
- onBlur={onBlurConfirm}
- onKeyDown={(e) => {
- if (e.key === "Enter") {
- e.preventDefault();
- onBlurConfirm();
- }
- if ((e.altKey || e.metaKey) && e.key === "ArrowDown") {
- onOpenRequest?.();
- }
- }}
- readOnly={readOnly}
- disabled={disabled}
- aria-invalid={hasError || undefined}
- aria-describedby={describedBy}
- className={cn(
- "text-ellipsis pr-12",
- disabled && "bg-muted text-muted-foreground cursor-not-allowed",
- readOnly && "bg-muted text-foreground cursor-default",
- !disabled && !readOnly && "bg-white text-foreground",
- hasError && "border-destructive ring-destructive"
- )}
- placeholder={placeholder}
- />
-
- {!readOnly && !required && value && (
-
- )}
- {readOnly ? (
-
- ) : (
- triggerButton ??
- )}
-
-
- );
+ return (
+
+
onChange(e.target.value)}
+ onKeyDown={(e) => {
+ if (e.key === "Enter") {
+ e.preventDefault();
+ onBlurConfirm();
+ }
+ if ((e.altKey || e.metaKey) && e.key === "ArrowDown") {
+ onOpenRequest?.();
+ }
+ }}
+ pattern="\d{2}/\d{2}/\d{4}"
+ placeholder={placeholder}
+ readOnly={readOnly}
+ type="text"
+ value={value}
+ />
+
+ {!(readOnly || required) && value && (
+
+ )}
+ {readOnly ? (
+
+ ) : (
+ (triggerButton ?? )
+ )}
+
+
+ );
}
diff --git a/packages/rdx-ui/src/components/form/date-picker-input-field/date-picker-input-comp.tsx b/packages/rdx-ui/src/components/form/date-picker-input-field/date-picker-input-comp.tsx
index a95a5df7..ec4dc6a0 100644
--- a/packages/rdx-ui/src/components/form/date-picker-input-field/date-picker-input-comp.tsx
+++ b/packages/rdx-ui/src/components/form/date-picker-input-field/date-picker-input-comp.tsx
@@ -1,205 +1,231 @@
import {
Button,
- Calendar,
+ type Calendar,
Field,
FieldDescription,
FieldError,
- FieldLabel,
Popover,
- PopoverTrigger
+ PopoverTrigger,
} from "@repo/shadcn-ui/components";
-import { CalendarIcon } from "lucide-react";
-
import { cn } from "@repo/shadcn-ui/lib/utils";
import { format, isValid, parse } from "date-fns";
-import { useCallback, useEffect, useMemo, useState } from "react";
-import { ControllerFieldState, ControllerRenderProps, FieldValues, Path, UseFormStateReturn } from "react-hook-form";
+import { CalendarIcon } from "lucide-react";
+import * as React from "react";
+import type {
+ ControllerFieldState,
+ ControllerRenderProps,
+ FieldValues,
+ Path,
+} from "react-hook-form";
+
import { useTranslation } from "../../../locales/i18n.ts";
-import { DateInputField } from './date-input-field.tsx';
-import { DatePopoverCalendar } from './date-popover-calendar.tsx';
+import { FormFieldLabel } from "../form-field-label.tsx";
+import { DateInputField } from "./date-input-field.tsx";
+import { DatePopoverCalendar } from "./date-popover-calendar.tsx";
-export type SUICalendarProps = Omit