Skip to content

Commit

Permalink
Merge pull request #586 from buildo/579-datefield_allow_disable_dates
Browse files Browse the repository at this point in the history
  • Loading branch information
gabro authored May 3, 2023
2 parents c5d1941 + 061fdd8 commit 866949a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/bento-design-system/src/DateField/DateField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type RangeDateFieldProps = {
type Props = (SingleDateFieldProps | RangeDateFieldProps) & {
minDate?: UseDatepickerProps["minBookingDate"];
maxDate?: UseDatepickerProps["maxBookingDate"];
shouldDisableDate?: UseDatepickerProps["isDateBlocked"];
readOnly?: boolean;
};

Expand Down Expand Up @@ -77,6 +78,7 @@ export function DateField(props: Props) {
},
startDate: props.type === "range" ? props.value[0] : props.value,
endDate: props.type === "range" ? props.value[1] : null,
isDateBlocked: props.shouldDisableDate,
focusedInput,
numberOfMonths: 1,
minBookingDate: props.minDate,
Expand Down
4 changes: 4 additions & 0 deletions packages/storybook/stories/Components/DateField.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,7 @@ export const RangeWithShortcuts = createControlledStory([null, null], {
},
],
});

export const DisabledDates = createControlledStory(null, {
shouldDisableDate: (date: Date) => date.getDay() === 0,
});

2 comments on commit 866949a

@vercel
Copy link

@vercel vercel bot commented on 866949a May 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 866949a May 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.