1.0.11 • Published 4 months ago

react-calendar-resource v1.0.11

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

React Calendar Resource

React Calendar Resource is an interactive and customizable React component for resource scheduling. It provides a timeline-based calendar view where users can manage events and resources efficiently with drag-and-drop functionality.

Features

  • Resource-based scheduling – Organize and display events per resource.
  • Drag-and-drop support – Easily move and reschedule events.
  • Customizable UI – Adjust styles, time slots, and event rendering.
  • Interactive event management – Create, edit, and delete events dynamically.
  • Zero dependencies – No using 3rd-party libraries.

Installation

npm install react-calendar-resource

or

yarn add react-calendar-resource

Usage

import React from 'react';
import { ResourceCalendar } from 'react-calendar-resource';

const data = [
  {
    resource: { id: 1, title: 'Resource 1' },
    events: [
      { id: 1, title: 'Event 1', start: '2024-03-15T09:00:00', end: '2024-03-15T10:00:00' }
    ]
  }
];

const App = () => (
  <ResourceCalendarTimeline
    data={data}
    onEventDragEnd={(start, resource, event) => console.log('Event moved', start, resource, event)}
  />
);

export default App;

Props

PropTypeDefaultDescription
dataCalendarData[]NoneAn array of calendar data objects. Each object contains a resource and its associated events. This is the primary dataset for rendering the calendar.
selectedDateDateNoneThe current date used as the reference for the timeline. It determines the time slots and event display.
containerStyleReact.CSSProperties{}Optional inline styles applied to the overall calendar container for custom appearance.
renderResource(resource: Resource) => React.ReactNodeRenders the resource's titleA custom render function for displaying a resource in the left column. Override this to provide a custom layout or additional details.
renderEvent(event: CalendarEvent, resource: Resource) => React.ReactNodeRenders a default event viewA custom render function for displaying calendar events in the timeline. Customize this to include icons, custom formatting, or additional UI elements.
onEventDragEnd(newDate: Date, resource: Resource, event: CalendarEvent) => voidNoneCallback triggered when an event drag-and-drop action is completed. It provides the new start time, the resource, and the event to update your data accordingly.
onDoubleClick(time: Date, resource: Resource) => voidNoneCallback fired when a double-click occurs on a time slot. This can be used to create new events or trigger custom actions.
eventContainerStyleReact.CSSProperties{}Optional inline styles applied to the container holding event elements. Useful for customizing event block appearance such as background color, borders, or padding.
startHournumber0The starting hour for the calendar timeline. This defines the beginning of the time slots displayed in the calendar.
endHournumber23The ending hour for the timeline, determining the last time slot of the day.
dragConstraintsDragConstraintsProps{ minuteStep: 10, preventOverlap: true }An object that defines constraints for event dragging: minuteStep specifies the snapping increment in minutes, and preventOverlap prevents events from overlapping if set to true.
groupBykeyof ResourceNoneOptional property to group resources based on a specific key from the Resource type (e.g., department, floor, specialty). When provided, the calendar groups resources internally and displays toggles.

License

This project is licensed under the MIT License.

1.0.11

4 months ago

1.0.10

4 months ago

1.0.9

4 months ago

1.0.8

4 months ago

1.0.7

4 months ago

1.0.6

4 months ago

1.0.5

4 months ago

1.0.4

4 months ago

1.0.3

4 months ago

1.0.2

4 months ago

1.0.1

4 months ago

1.0.0

4 months ago