From 061fdd8e81920103ccb90a0a64968c603a6ac5de Mon Sep 17 00:00:00 2001 From: Federico Ercoles Date: Tue, 2 May 2023 17:26:34 +0200 Subject: [PATCH] Allow disabling specific dates in DateField --- packages/bento-design-system/src/DateField/DateField.tsx | 2 ++ packages/storybook/stories/Components/DateField.stories.tsx | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/packages/bento-design-system/src/DateField/DateField.tsx b/packages/bento-design-system/src/DateField/DateField.tsx index 1f693339b..789470717 100644 --- a/packages/bento-design-system/src/DateField/DateField.tsx +++ b/packages/bento-design-system/src/DateField/DateField.tsx @@ -28,6 +28,7 @@ type RangeDateFieldProps = { type Props = (SingleDateFieldProps | RangeDateFieldProps) & { minDate?: UseDatepickerProps["minBookingDate"]; maxDate?: UseDatepickerProps["maxBookingDate"]; + shouldDisableDate?: UseDatepickerProps["isDateBlocked"]; readOnly?: boolean; }; @@ -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, diff --git a/packages/storybook/stories/Components/DateField.stories.tsx b/packages/storybook/stories/Components/DateField.stories.tsx index dfd012883..84a6f6b66 100644 --- a/packages/storybook/stories/Components/DateField.stories.tsx +++ b/packages/storybook/stories/Components/DateField.stories.tsx @@ -96,3 +96,7 @@ export const RangeWithShortcuts = createControlledStory([null, null], { }, ], }); + +export const DisabledDates = createControlledStory(null, { + shouldDisableDate: (date: Date) => date.getDay() === 0, +});