Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2498 from teamleadercrm/TIDAL-3184-allow-configur…
Browse files Browse the repository at this point in the history
…ing-initial-month

[Date picker] Allow configuring initial month
  • Loading branch information
lorgan3 authored Dec 19, 2022
2 parents 5e14d6f + 1f25c0e commit f136851
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@

### Dependency updates

## [18.2.3] - 2022-12-16
## [18.3.0] - 2022-12-19

### Added

- `DatePicker`: Allow changing the initialMonth if no date is selected ([@lorgan3](https://github.com/lorgan3)) in ([#2498](https://github.com/teamleadercrm/ui/pull/2498))

### Fixed

Expand Down
7 changes: 6 additions & 1 deletion src/components/datepicker/DatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ export interface DatePickerProps extends Omit<BoxProps & DayPickerProps, 'size'
selectedDate?: Date;
/** Size of the DatePicker component. */
size?: Exclude<typeof SIZES[number], 'tiny' | 'fullscreen' | 'hero'>;
/** Show a dropdown for the month? */
withMonthPicker?: boolean;
/** Show week numbers? */
showWeekNumbers?: boolean;
/** The initial month to display if no date is selected. */
initialMonth?: Date;
}

const DatePicker: GenericComponent<DatePickerProps> = ({
Expand All @@ -37,6 +41,7 @@ const DatePicker: GenericComponent<DatePickerProps> = ({
size = 'medium',
withMonthPicker,
showWeekNumbers,
initialMonth,
onChange,
...others
}) => {
Expand Down Expand Up @@ -89,7 +94,7 @@ const DatePicker: GenericComponent<DatePickerProps> = ({
<DayPicker
{...others}
localeUtils={localeUtils}
initialMonth={others.selectedDate}
initialMonth={others.selectedDate ?? initialMonth}
month={selectedMonth}
className={classNames}
classNames={theme as any}
Expand Down
1 change: 1 addition & 0 deletions src/components/datepicker/datePicker.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ singleDate.args = {
size: 'medium',
withMonthPicker: true,
showWeekNumbers: false,
initialMonth: new Date(),
};
singleDate.parameters = {
design: [
Expand Down

0 comments on commit f136851

Please sign in to comment.