Logic
Calendar Controller
A flexible and powerful calendar management system for building interactive date pickers, schedulers, and calendar applications.
Examples
Explore interactive examples of Calendar Controller in action, including the new disabled weekdays feature from v0.2.1.
Basic Calendar Usage
A simple example of creating a calendar component with basic functionality.
Calendar Component Demo
Code Example
1import { createCalendarController } from '@uplink-protocol/calendar-controller';23// Create a new calendar controller instance4const calendar = createCalendarController({5 // Initial date to display6 initialDate: new Date(),78 // First day of week (0 = Sunday, 1 = Monday, etc.)9 firstDayOfWeek: 0,1011 // Event handlers12 onDateSelect: (date) => {13 console.log('Selected date:', date);14 }15});1617// Get the current month view18const currentMonth = calendar.getMonthView();1920// Generate the calendar UI21function renderCalendar() {22 return (23 <div className="calendar">24 <div className="calendar-header">25 <button onClick={() => calendar.prevMonth()}>Previous</button>26 <h2>{calendar.getFormattedMonth()}</h2>27 <button onClick={() => calendar.nextMonth()}>Next</button>28 </div>2930 <div className="calendar-grid">31 {/* Render weekday headers */}32 {calendar.getWeekdayLabels().map(day => (33 <div key={day} className="calendar-day-header">34 {day}35 </div>36 ))}3738 {/* Render calendar days */}39 {currentMonth.days.map(day => (40 <div41 key={day.date.toString()}42 className={`calendar-day ${day.isCurrentMonth ? 'current-month' : 'other-month'}43 ${day.isToday ? 'today' : ''}44 ${day.isSelected ? 'selected' : ''}`}45 onClick={() => calendar.selectDate(day.date)}46 >47 {day.dayOfMonth}48 </div>49 ))}50 </div>51 </div>52 );53}