Skip to content

Commit 866949a

Browse files
authored
Merge pull request #586 from buildo/579-datefield_allow_disable_dates
2 parents c5d1941 + 061fdd8 commit 866949a

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

packages/bento-design-system/src/DateField/DateField.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type RangeDateFieldProps = {
2828
type Props = (SingleDateFieldProps | RangeDateFieldProps) & {
2929
minDate?: UseDatepickerProps["minBookingDate"];
3030
maxDate?: UseDatepickerProps["maxBookingDate"];
31+
shouldDisableDate?: UseDatepickerProps["isDateBlocked"];
3132
readOnly?: boolean;
3233
};
3334

@@ -77,6 +78,7 @@ export function DateField(props: Props) {
7778
},
7879
startDate: props.type === "range" ? props.value[0] : props.value,
7980
endDate: props.type === "range" ? props.value[1] : null,
81+
isDateBlocked: props.shouldDisableDate,
8082
focusedInput,
8183
numberOfMonths: 1,
8284
minBookingDate: props.minDate,

packages/storybook/stories/Components/DateField.stories.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,7 @@ export const RangeWithShortcuts = createControlledStory([null, null], {
9696
},
9797
],
9898
});
99+
100+
export const DisabledDates = createControlledStory(null, {
101+
shouldDisableDate: (date: Date) => date.getDay() === 0,
102+
});

0 commit comments

Comments
 (0)