Skip to content

Commit fdc45fa

Browse files
committed
feat: support hide out of range flag
1 parent ba09064 commit fdc45fa

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/components/experimental/DatePicker/DatePicker.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type DateRange = RdpRange | undefined;
3131
type CommonProps = Pick<FieldProps, 'description' | 'errorMessage'> & {
3232
label?: string;
3333
placeholder?: string;
34+
hideOutOfRange?: boolean;
3435
/** date-fns format used for display/parse */
3536
displayFormat?: string;
3637
/** day constraints */
@@ -129,6 +130,7 @@ function DatePickerImpl(props: DatePickerProps): JSX.Element {
129130
placeholder,
130131
id,
131132
visibleMonths,
133+
hideOutOfRange = false,
132134
defaultValue,
133135
minValue,
134136
maxValue,
@@ -358,11 +360,12 @@ function DatePickerImpl(props: DatePickerProps): JSX.Element {
358360
]);
359361

360362
const hiddenMatcher = React.useMemo<Matcher[] | undefined>(() => {
363+
if (!hideOutOfRange) return undefined;
361364
const arr: Matcher[] = [];
362365
if (minDateCompat) arr.push({ before: stripTime(minDateCompat) });
363366
if (maxDateCompat) arr.push({ after: stripTime(maxDateCompat) });
364367
return arr.length > 0 ? arr : undefined;
365-
}, [minDateCompat?.getTime(), maxDateCompat?.getTime()]);
368+
}, [hideOutOfRange, minDateCompat?.getTime(), maxDateCompat?.getTime()]);
366369

367370
// common Calendar props
368371
const commonCalProps = {

0 commit comments

Comments
 (0)