Skip to content

Commit 2cbc703

Browse files
committed
Updated functionality on DatePicker and DateRangePicker components
1 parent 960a3fd commit 2cbc703

File tree

5 files changed

+15
-11
lines changed

5 files changed

+15
-11
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ dist
44
storybook-static
55
package-lock.json
66
.vscode
7-
yarn.lock
7+
yarn.lock
8+
.idea

src/components/input-elements/Calendar/Calendar.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ import { addYears, format } from "date-fns";
1818
import { Text } from "../../text-elements/Text";
1919
import { NavButton } from "./NavButton";
2020

21-
function Calendar<T extends (PropsSingle | PropsRange) & PropsBase>({
21+
export type DayPickerSingleProps = PropsBase & PropsSingle;
22+
export type DayPickerRangeProps = PropsBase & PropsRange;
23+
24+
function Calendar<T extends DayPickerSingleProps | DayPickerRangeProps>({
2225
mode,
2326
defaultMonth,
2427
selected,
@@ -96,7 +99,7 @@ function Calendar<T extends (PropsSingle | PropsRange) & PropsBase>({
9699
</div>
97100

98101
<Text className="text-tremor-default tabular-nums capitalize text-tremor-content-emphasis dark:text-dark-tremor-content-emphasis font-medium">
99-
{format(calendarMonth.date, "LLLL yyy", { locale })}
102+
{format(calendarMonth.date, "LLLL yyy", { locale: locale as any })}
100103
</Text>
101104

102105
<div className="flex items-center space-x-1">
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { default as Calendar } from "./Calendar";
1+
export { default as Calendar, DayPickerSingleProps, DayPickerRangeProps } from "./Calendar";

src/components/input-elements/DatePicker/DatePicker.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
"use client";
22
import { tremorTwMerge } from "lib";
33
import React, { useMemo } from "react";
4-
import { DayPickerSingleProps } from "react-day-picker";
54

65
import { startOfMonth, startOfToday } from "date-fns";
76
import { enUS } from "date-fns/locale";
87

98
import { Popover, PopoverButton, PopoverPanel, Transition } from "@headlessui/react";
109
import { CalendarIcon, XCircleIcon } from "assets";
11-
import { Calendar } from "components/input-elements/Calendar";
10+
import { Calendar, type DayPickerSingleProps } from "components/input-elements/Calendar";
1211
import { makeDatePickerClassName } from "components/input-elements/DatePicker/datePickerUtils";
1312
import { useInternalState } from "hooks";
1413
import { Color } from "../../../lib/inputTypes";

src/components/input-elements/DateRangePicker/DateRangePicker.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { CalendarIcon, XCircleIcon } from "assets";
44
import { startOfMonth, startOfToday } from "date-fns";
55
import { tremorTwMerge } from "lib";
66
import React, { ReactElement, useMemo, useState } from "react";
7-
import { DateRange, DayPickerRangeProps } from "react-day-picker";
7+
import { DateRange } from "react-day-picker";
88
import {
99
constructValueToNameMapping,
1010
getNodeText,
@@ -19,7 +19,7 @@ import {
1919
parseStartDate,
2020
} from "./dateRangePickerUtils";
2121

22-
import { Calendar } from "components/input-elements/Calendar";
22+
import { Calendar, type DayPickerRangeProps } from "components/input-elements/Calendar";
2323
import { DateRangePickerItemProps } from "components/input-elements/DateRangePicker/DateRangePickerItem";
2424
import { SelectItem } from "components/input-elements/Select";
2525
import { enUS } from "date-fns/locale";
@@ -277,16 +277,17 @@ const DateRangePicker = React.forwardRef<HTMLDivElement, DateRangePickerProps>((
277277
disabled={disabledDays}
278278
enableYearNavigation={enableYearNavigation}
279279
classNames={{
280-
day_range_middle: tremorTwMerge(
280+
range_middle: tremorTwMerge(
281281
"!rounded-none aria-selected:!bg-tremor-background-subtle aria-selected:dark:!bg-dark-tremor-background-subtle aria-selected:!text-tremor-content aria-selected:dark:!bg-dark-tremor-background-subtle",
282282
),
283-
day_range_start:
283+
range_start:
284284
"rounded-r-none rounded-l-tremor-small aria-selected:text-tremor-brand-inverted dark:aria-selected:text-dark-tremor-brand-inverted",
285-
day_range_end:
285+
range_end:
286286
"rounded-l-none rounded-r-tremor-small aria-selected:text-tremor-brand-inverted dark:aria-selected:text-dark-tremor-brand-inverted",
287287
}}
288288
weekStartsOn={weekStartsOn}
289289
{...props}
290+
role={"dialog"}
290291
/>
291292
</PopoverPanel>
292293
</Transition>

0 commit comments

Comments
 (0)