Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ export default function Playground() {
start: new Date(),
end: new Date(new Date().setDate(new Date().getDate() + 8))
}
},
last6Months: {
text: "Last 6 months",
period: {
start: new Date(new Date().setMonth(new Date().getMonth() - 6)),
end: new Date()
}
}
},
footer: {
Expand Down
4 changes: 3 additions & 1 deletion src/components/Datepicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ const Datepicker = (props: DatepickerType) => {
toggleClassName,
toggleIcon,
updateFirstDate: (newDate: Date) => firstGotoDate(newDate),
updateLastDate: (newDate: Date) => secondGotoDate(newDate),
value
};
}, [
Expand Down Expand Up @@ -368,7 +369,8 @@ const Datepicker = (props: DatepickerType) => {
toggleClassName,
toggleIcon,
value,
firstGotoDate
firstGotoDate,
secondGotoDate
]);

const containerClassNameOverload = useMemo(() => {
Expand Down
5 changes: 4 additions & 1 deletion src/components/Shortcuts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const ItemTemplate = memo((props: ItemTemplateProps) => {
period,
changePeriod,
updateFirstDate,
updateLastDate,
dayHover,
changeDayHover,
hideDatepicker,
Expand Down Expand Up @@ -53,6 +54,7 @@ const ItemTemplate = memo((props: ItemTemplateProps) => {
);

if (item.start) updateFirstDate(item.start);
if (item.end) updateLastDate(item.end);
hideDatepicker();
},
[
Expand All @@ -64,7 +66,8 @@ const ItemTemplate = memo((props: ItemTemplateProps) => {
input,
period.end,
period.start,
updateFirstDate
updateFirstDate,
updateLastDate
]
);

Expand Down
2 changes: 2 additions & 0 deletions src/contexts/DatepickerContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ interface DatepickerStore {
toggleIcon?: (open: boolean) => ReactNode;

updateFirstDate: (date: Date) => void;
updateLastDate: (date: Date) => void;

value: DateValueType;
}
Expand Down Expand Up @@ -122,6 +123,7 @@ const DatepickerContext = createContext<DatepickerStore>({
toggleIcon: undefined,

updateFirstDate: () => {},
updateLastDate: () => {},

value: null
});
Expand Down