✨(react) restrict inputs formats in date picker components
Enforces a standardized approach for end consumers using the component's API. Consumers are now required to provide a date as an ISO string in either UTC or with a UTC offset. The support for native Date objects has been removed to ensure consistent and reliable behavior across all implementations. By adopting this uniform input format, we can simplify usage and avoid potential inconsistencies in date handling.
This commit is contained in:
committed by
aleb_the_flash
parent
8cf8e1eba2
commit
0dc46d1144
@@ -10,17 +10,16 @@ import DatePickerAux, {
|
||||
} from ":/components/Forms/DatePicker/DatePickerAux";
|
||||
import { Calendar } from ":/components/Forms/DatePicker/Calendar";
|
||||
import DateFieldBox from ":/components/Forms/DatePicker/DateField";
|
||||
import { StringOrDate } from ":/components/Forms/DatePicker/types";
|
||||
import {
|
||||
convertDateValueToString,
|
||||
getDefaultPickerOptions,
|
||||
parseCalendarDate,
|
||||
parseDateValue,
|
||||
} from ":/components/Forms/DatePicker/utils";
|
||||
|
||||
export type DatePickerProps = DatePickerAuxSubProps & {
|
||||
value?: null | StringOrDate;
|
||||
value?: null | string;
|
||||
label: string;
|
||||
defaultValue?: StringOrDate;
|
||||
defaultValue?: string;
|
||||
onChange?: (value: string | null) => void | undefined;
|
||||
};
|
||||
|
||||
@@ -39,8 +38,8 @@ export const DatePicker = (props: DatePickerProps) => {
|
||||
// Force clear the component's value when passing null or an empty string.
|
||||
props.value === "" || props.value === null
|
||||
? null
|
||||
: parseCalendarDate(props.value),
|
||||
defaultValue: parseCalendarDate(props.defaultValue),
|
||||
: parseDateValue(props.value),
|
||||
defaultValue: parseDateValue(props.defaultValue),
|
||||
onChange: (value: DateValue | null) => {
|
||||
props.onChange?.(convertDateValueToString(value));
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user