Skip to content

Commit

Permalink
🤖 Merge PR #64211 Add dayjs type for react-big-calendar by @levani132
Browse files Browse the repository at this point in the history
* Update index.d.ts

Added dayjsLocalizer type that was added in this PR: jquense/react-big-calendar#2264

* Added example test for dayjs localizer type

* Update index.d.ts to include newer version name

* Update index.d.ts

* Fixed incorrect test

* Added timeslot wrapper too, to address dangerbot suggestion

---------

Co-authored-by: Levan Beroshvili <v-levanbe@microsoft.com>
  • Loading branch information
levani132 and Levan Beroshvili authored Feb 3, 2023
1 parent 8e8c5b1 commit 170311d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
4 changes: 3 additions & 1 deletion types/react-big-calendar/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Type definitions for react-big-calendar 0.38
// Type definitions for react-big-calendar 1.6
// Project: https://github.com/jquense/react-big-calendar
// Definitions by: Piotr Witek <https://github.com/piotrwitek>
// Austin Turner <https://github.com/paustint>
Expand Down Expand Up @@ -537,6 +537,7 @@ export class Calendar<TEvent extends object = Event, TResource extends object =
> {}

export interface components {
timeSlotWrapper: React.ComponentType;
dateCellWrapper: React.ComponentType;
eventWrapper: React.ComponentType<Event>;
}
Expand All @@ -554,6 +555,7 @@ export function luxonLocalizer(
firstDayOfWeek: number;
},
): DateLocalizer;
export function dayjsLocalizer(dayjs: object): DateLocalizer;

export const Navigate: {
PREVIOUS: 'PREV';
Expand Down
23 changes: 23 additions & 0 deletions types/react-big-calendar/react-big-calendar-tests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
globalizeLocalizer,
dateFnsLocalizer,
luxonLocalizer,
dayjsLocalizer,
move,
Views,
components,
Expand Down Expand Up @@ -37,6 +38,7 @@ declare const globalize: any;
declare const moment: any;
declare const dateFnsConfig: any;
declare const luxonConfig: any;
declare const dayjs: any;

declare const allViews: View[];

Expand Down Expand Up @@ -157,6 +159,27 @@ class CalendarResource {
ReactDOM.render(<Basic localizer={localizer} />, document.body);
}

// dayjs Example Test
{
interface Props {
localizer: DateLocalizer;
}
const Basic = ({ localizer }: Props) => (
<Calendar
events={getEvents()}
views={allViews}
step={60}
showMultiDayTimes
defaultDate={new Date(2015, 3, 1)}
localizer={localizer}
/>
);

const localizer = dayjsLocalizer(dayjs);

ReactDOM.render(<Basic localizer={localizer} />, document.body);
}

// Drag and Drop Example Test
{
class MyCalendar extends Calendar<CalendarEvent, CalendarResource> { }
Expand Down

0 comments on commit 170311d

Please sign in to comment.