Skip to content

Commit 7e0b7e3

Browse files
committed
fix(date-picker): add alignment and side props for popover customization and show date picker in cleanup setting as center align and bottom side
1 parent 54e89aa commit 7e0b7e3

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

dashboard/src/components/common/date-picker.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ import { useIsMobile } from '@/hooks/use-mobile'
1616

1717
export type DatePickerMode = 'single' | 'range'
1818

19+
export type DatePickerAlign = 'start' | 'center' | 'end'
20+
21+
export type DatePickerSide = 'top' | 'right' | 'bottom' | 'left'
22+
1923
export interface DatePickerProps {
2024
/**
2125
* Mode of the date picker: 'single' for single date selection, 'range' for date range selection
@@ -94,6 +98,14 @@ export interface DatePickerProps {
9498
* Callback for field change (for form integration)
9599
*/
96100
onFieldChange?: (fieldName: string, value: any) => void
101+
/**
102+
* Alignment of the popover
103+
*/
104+
align?: DatePickerAlign
105+
/**
106+
* Side of the popover
107+
*/
108+
side?: DatePickerSide
97109
}
98110

99111
/**
@@ -145,6 +157,8 @@ export function DatePicker({
145157
formatDate: customFormatDate,
146158
fieldName = 'date',
147159
onFieldChange,
160+
align,
161+
side,
148162
}: DatePickerProps) {
149163
const { t, i18n } = useTranslation()
150164
const isPersianLocale = i18n.language === 'fa'
@@ -332,8 +346,8 @@ export function DatePicker({
332346
</PopoverTrigger>
333347
<PopoverContent
334348
className="w-auto p-0"
335-
align="end"
336-
side={isMobile ? 'bottom' : 'left'}
349+
align={align ? align : "end"}
350+
side={side ? side : isMobile ? 'bottom' : 'left'}
337351
onInteractOutside={() => {
338352
setIsOpen(false)
339353
}}
@@ -453,7 +467,7 @@ export function DatePicker({
453467
)}
454468
</Button>
455469
</PopoverTrigger>
456-
<PopoverContent className="w-auto p-0" align="start" side="bottom" sideOffset={4} collisionPadding={8}>
470+
<PopoverContent className="w-auto p-0" align={align ? align : "start"} side={side ? side : "bottom"} sideOffset={4} collisionPadding={8}>
457471
{isPersianLocale ? (
458472
<PersianCalendar
459473
mode="range"

dashboard/src/pages/_dashboard.settings.cleanup.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,8 @@ export default function CleanupSettings() {
356356
minDate={new Date('1900-01-01')}
357357
maxDate={new Date()}
358358
formatDate={formatDate}
359+
side={"bottom"}
360+
align={"center"}
359361
/>
360362
</div>
361363

@@ -369,6 +371,8 @@ export default function CleanupSettings() {
369371
minDate={new Date('1900-01-01')}
370372
maxDate={new Date()}
371373
formatDate={formatDate}
374+
side={"bottom"}
375+
align={"center"}
372376
/>
373377
</div>
374378
</div>

0 commit comments

Comments
 (0)