Skip to content

Commit

Permalink
chore: review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tewarig committed Jan 14, 2025
1 parent 944542a commit d58d7f8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
14 changes: 7 additions & 7 deletions packages/blade/src/components/DatePicker/DateInput.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const _DatePickerInput = (
successText,
errorText,
helpText,
dateFormat,
format,
placeholder,
...props
}: DatePickerInputProps,
Expand All @@ -110,7 +110,7 @@ const _DatePickerInput = (
if (selectionType == 'single') {
const dateValue = getFormattedDate({
date,
format: dateFormat,
format,
labelSeparator: '-',
locale,
type: 'default',
Expand All @@ -128,7 +128,7 @@ const _DatePickerInput = (
id="start-date"
labelPosition={labelPosition}
label={label}
placeholder={placeholder || dateFormat}
placeholder={placeholder || format}
popupId={referenceProps['aria-controls']}
isPopupExpanded={referenceProps['aria-expanded']}
size={size}
Expand Down Expand Up @@ -165,14 +165,14 @@ const _DatePickerInput = (
const startValue = getFormattedDate({
type: 'default',
date: date[0],
format: dateFormat,
format,
labelSeparator: '-',
locale,
});
const endValue = getFormattedDate({
type: 'default',
date: date[1],
format: dateFormat,
format,
labelSeparator: '-',
locale,
});
Expand All @@ -198,7 +198,7 @@ const _DatePickerInput = (
leadingIcon={CalendarIcon}
label={label?.start}
labelPosition={labelPosition}
placeholder={placeholder || dateFormat}
placeholder={placeholder}
popupId={referenceProps['aria-controls']}
isPopupExpanded={referenceProps['aria-expanded']}
size={size}
Expand Down Expand Up @@ -236,7 +236,7 @@ const _DatePickerInput = (
/>
<DateInput
id="end-date"
placeholder={placeholder || dateFormat}
placeholder={placeholder}
leadingIcon={CalendarIcon}
label={shouldRenderEndLabel()}
labelPosition={isLabelPositionLeft ? undefined : labelPosition}
Expand Down
12 changes: 6 additions & 6 deletions packages/blade/src/components/DatePicker/DatePicker.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const DatePicker = <Type extends DateSelectionType = 'single'>({
picker,
onPickerChange,
zIndex = componentZIndices.popover,
dateFormat,
format,
inputPlaceHolder,
...props
}: DatePickerProps<Type> & StyledPropsBlade & DataAnalyticsAttribute): React.ReactElement => {
Expand All @@ -85,9 +85,9 @@ const DatePicker = <Type extends DateSelectionType = 'single'>({
onPickerChange?.(picker);
},
});
const finalDateFormat = React.useMemo(() => {
if (dateFormat) {
return dateFormat;
const finalFormat = React.useMemo(() => {
if (format) {
return format;
}
if (picker === 'day') {
return 'DD';
Expand All @@ -99,7 +99,7 @@ const DatePicker = <Type extends DateSelectionType = 'single'>({
return 'YYYY';
}
return 'DD/MM/YYYY';
}, [dateFormat, picker]);
}, [format, picker]);

const finalInputPlaceHolder = React.useMemo(() => {
if (inputPlaceHolder) {
Expand Down Expand Up @@ -337,7 +337,7 @@ const DatePicker = <Type extends DateSelectionType = 'single'>({
validationState={validationState}
autoFocus={autoFocus}
necessityIndicator={necessityIndicator}
dateFormat={finalDateFormat}
format={finalFormat}
placeholder={finalInputPlaceHolder}
{...makeAnalyticsAttribute(props)}
/>
Expand Down
4 changes: 2 additions & 2 deletions packages/blade/src/components/DatePicker/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ type DatePickerProps<Type extends DateSelectionType> = Omit<
* Sets the date format to be displayed in the input field.
* @default 'DD/MM/YYYY' if pickerType is 'date' then 'DD', if pickerType is 'month' then 'MMMM', 'YYYY' if pickerType is 'year'
*/
dateFormat?: string;
format?: string;
/**
* Placeholder text for the datepicker input , when no date is selected.
* @default 'DD/MM/YYYY' if pickerType is 'date' then 'DD', if pickerType is 'month' then 'MMMM', 'YYYY' if pickerType is 'year'
Expand Down Expand Up @@ -206,7 +206,7 @@ type DatePickerCommonInputProps = {

type DatePickerInputProps = DatePickerCommonInputProps &
(DatePickerRangeInputProps | DatePickerSingleInputProps) & {
dateFormat: string;
format: string;
placeholder?: string;
};

Expand Down

0 comments on commit d58d7f8

Please sign in to comment.