Skip to content

Commit

Permalink
feat(react-big-calendar): showMore component
Browse files Browse the repository at this point in the history
The library now accepts a `showMore` custom component to provide access
to the events overflowing the available cell space.

See: jquense/react-big-calendar#2537
  • Loading branch information
davidmh committed Oct 9, 2024
1 parent ca02214 commit a24f55d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
10 changes: 10 additions & 0 deletions types/react-big-calendar/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,15 @@ export interface DateCellWrapperProps {
children: React.JSX.Element;
}

export interface ShowMoreProps<TEvent extends object = Event> {
localizer: DateLocalizer;
slot: number;
slotDate: Date;
count: number;
events: TEvent[];
remainingEvents: TEvent[];
}

export interface Components<TEvent extends object = Event, TResource extends object = object> {
event?: React.ComponentType<EventProps<TEvent>> | undefined;
eventWrapper?: React.ComponentType<EventWrapperProps<TEvent>> | undefined;
Expand Down Expand Up @@ -235,6 +244,7 @@ export interface Components<TEvent extends object = Event, TResource extends obj
*/
header?: React.ComponentType<HeaderProps> | undefined;
resourceHeader?: React.ComponentType<ResourceHeaderProps<TResource>> | undefined;
showMore?: React.ComponentType<ShowMoreProps<TEvent>>;
}

export interface ToolbarProps<TEvent extends object = Event, TResource extends object = object> {
Expand Down
2 changes: 1 addition & 1 deletion types/react-big-calendar/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@types/react-big-calendar",
"version": "1.8.9999",
"version": "1.15.9999",
"projects": [
"https://github.com/jquense/react-big-calendar"
],
Expand Down
12 changes: 12 additions & 0 deletions types/react-big-calendar/react-big-calendar-tests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
Navigate,
NavigateAction,
ResourceHeaderProps,
ShowMoreProps,
stringOrDate,
TimeGrid,
ToolbarProps,
Expand Down Expand Up @@ -368,6 +369,7 @@ class CalendarResource {
eventWrapper: EventWrapper,
header: CustomHeader,
resourceHeader: ResourceHeader,
showMore: ShowMoreButton,
}}
dayPropGetter={customDayPropGetter}
slotPropGetter={customSlotPropGetter}
Expand Down Expand Up @@ -533,6 +535,16 @@ function ResourceHeader(props: ResourceHeaderProps<CalendarResource>) {
);
}

function ShowMoreButton(props: ShowMoreProps<CalendarEvent>) {
return (
<div>
<div>Show more</div>
<p>All events: {props.events.length}</p>
<p>Remaining: {props.remainingEvents.length}</p>
</div>
);
}

class Toolbar extends React.Component<ToolbarProps<CalendarEvent, CalendarResource>> {
render() {
const { date, label, view } = this.props;
Expand Down

0 comments on commit a24f55d

Please sign in to comment.