@uplink-protocol/calendar-controller
Version:
Flexible calendar and time picker API supporting both calendar, date-picker, and time-picker integrations for any JavaScript framework or library
255 lines (217 loc) • 8.59 kB
Markdown
# Date Controller Capabilities
## Overview
The Date Controller provides comprehensive calendar and date picker functionality with advanced features for building sophisticated date selection interfaces.
## Core Features
### 📅 Date Selection
- **Single Date Selection**: Select individual dates with full validation
- **Date Range Selection**: Select start and end dates for booking systems
- **Programmatic Selection**: Set dates via API calls or user interaction
- **Selection Validation**: Automatic validation against constraints
### 🧭 Calendar Navigation
- **Month Navigation**: Previous/next month with year boundary handling
- **Year Navigation**: Jump between years with smooth transitions
- **Decade Navigation**: Browse years in configurable decade ranges
- **Direct Navigation**: Jump to specific months, years, or dates
- **Today Navigation**: Quick return to current date
### 🗓️ Calendar Views
- **Month View**: Traditional calendar grid with weeks and days
- **Year View**: 12-month overview for year-level navigation
- **Decade View**: Multi-year selection with configurable ranges
- **Week Numbers**: ISO week number support for business applications
- **Multi-Month Display**: Support for displaying multiple months
### 🚫 Date Constraints
- **Date Range Limits**: Set minimum and maximum selectable dates
- **Disabled Dates**: Block specific dates (holidays, blackout dates)
- **Disabled Weekdays**: Block days of the week (e.g., weekends)
- **Custom Validation**: Implement complex business rules
- **Dynamic Constraints**: Update constraints based on selections
### 🌐 Internationalization
- **Locale Support**: Full i18n with 100+ locales
- **Month Names**: Localized month names (full and abbreviated)
- **Weekday Names**: Localized weekday names with configurable formats
- **Date Formatting**: Locale-appropriate date formatting
- **First Day of Week**: Configurable week start (Sunday/Monday)
- **Text Direction**: RTL language support
### ♿ Accessibility
- **Keyboard Navigation**: Full keyboard support (arrows, home, end, page up/down)
- **Screen Reader Support**: ARIA labels and descriptions
- **Focus Management**: Proper focus handling and visual indicators
- **Accessible Labels**: Descriptive labels for dates and states
- **Date Announcements**: Clear announcements for state changes
### 🎭 Event System
- **Date Selection Events**: Fired when dates are selected
- **Navigation Events**: Month/year change notifications
- **View Change Events**: Calendar view transitions
- **Range Events**: Date range selection notifications
- **Focus Events**: Focus change notifications for accessibility
### 📊 Data Generation
- **Calendar Days**: Generate complete month view with metadata
- **Calendar Months**: Generate year view with month information
- **Calendar Years**: Generate decade view with year data
- **Week Information**: Calculate week numbers and week boundaries
- **Date Metadata**: Rich information about each date (today, weekend, etc.)
### 🛠️ Utilities
- **Date Formatting**: Flexible date formatting with Intl support
- **Date Validation**: Check if dates are valid, today, weekends, etc.
- **Week Calculations**: ISO week numbers and week boundaries
- **Date Arithmetic**: Add/subtract days, months, years
- **State Descriptions**: Generate accessibility descriptions
## Advanced Features
### 🏢 Business Logic Integration
- **Holiday Support**: Integration with holiday calendars
- **Business Rules**: Complex validation and constraint systems
- **Booking Systems**: Support for reservation and availability systems
- **Recurring Events**: Handle recurring date patterns
- **Time Zone Handling**: Work with dates across time zones
### 📈 Performance
- **Lazy Generation**: Generate calendar data only when needed
- **Efficient Updates**: Minimal re-rendering with reactive bindings
- **Large Data Sets**: Handle years of calendar data efficiently
- **Memory Management**: Automatic cleanup and optimization
- **Caching**: Smart caching of generated calendar data
### 🔗 Integration
- **Framework Agnostic**: Works with React, Vue, Angular, vanilla JS
- **State Management**: Reactive bindings for automatic UI updates
- **External Calendars**: Integration with Google Calendar, Outlook, etc.
- **Form Libraries**: Easy integration with form validation systems
- **Testing**: Comprehensive test utilities and mocking support
## API Structure
### Bindings (Reactive State)
```javascript
{
selectedDate: Date | null, // Currently selected date
selectedDateRange: DateRange, // Selected date range (start/end)
focusedDate: Date | null, // Currently focused date
currentDate: Date, // Current navigation date
currentMonth: number, // Current month (0-11)
currentYear: number, // Current year
monthName: string, // Localized month name
calendarDays: CalendarDate[], // Month view calendar days
calendarMonths: CalendarMonth[], // Year view months
calendarYears: CalendarYear[], // Decade view years
weekdays: string[], // Localized weekday names
isRangeSelection: boolean, // Range selection mode
currentYearRangeBase: number // Current decade base year
}
```
### Methods (Actions)
```javascript
{
// Date Selection
selectDate(date),
selectDate(year, month, day),
clearSelection(),
// Navigation
goToNextMonth(),
goToPreviousMonth(),
goToNextYear(),
goToPreviousYear(),
goToToday(),
goToMonth(month, year),
goToYear(year),
goToDate(date),
// Year Range Navigation
goToNextYearRange(),
goToPreviousYearRange(),
setYearRangeSize(size),
getCurrentYearRange(),
setCurrentYearRange(date),
// Constraints
setMinDate(date),
setMaxDate(date),
setDisabledDates(dates[]),
addDisabledDate(date),
removeDisabledDate(date),
setDisabledDaysOfWeek(days[]),
addDisabledDayOfWeek(day),
removeDisabledDayOfWeek(day),
// Validation
isDateDisabled(date),
isToday(date),
// Generation
generateCalendarDays(),
generateCalendarMonths(),
generateCalendarYears(),
generateMonthView(),
// Accessibility
setFocusedDate(date),
clearFocusedDate(),
focusDate(date),
moveFocusRight(),
moveFocusLeft(),
moveFocusUp(),
moveFocusDown(),
moveFocusToStartOfMonth(),
moveFocusToEndOfMonth(),
moveFocusToPreviousMonth(),
moveFocusToNextMonth(),
selectFocusedDate(),
getAccessibleDateLabel(date),
getDateStateDescription(date),
// Formatting
formatDate(date, options),
getFormattedDate(),
setDateFormatOptions(options),
getDateFormatOptions(),
// Localization
setLocale(locale),
getLocale(),
getMonthNames(),
getWeekdayNames(short),
// Utilities
getWeekNumber(date),
setRangeSelectionMode(enabled)
}
```
### Events (Notifications)
```javascript
{
dateSelected: Observable<Date>,
dateRangeSelected: Observable<DateRange>,
monthChanged: Observable<number>,
yearChanged: Observable<number>,
viewChanged: Observable<{month, year}>,
yearRangeChanged: Observable<YearRange>
}
```
## Use Cases
### 📱 Date Picker Components
- Single date selection for forms
- Date range selection for bookings
- Inline calendar widgets
- Dropdown date pickers
### 🏨 Booking Systems
- Hotel reservation calendars
- Meeting room scheduling
- Event planning interfaces
- Availability management
### 📊 Business Applications
- Report date ranges
- Financial period selection
- Project timeline planning
- Audit date tracking
### 🌍 International Applications
- Multi-language date pickers
- Cultural calendar variations
- Regional date formats
- Time zone considerations
### ♿ Accessible Interfaces
- Screen reader compatible calendars
- Keyboard-only navigation
- High contrast date pickers
- Voice control integration
## Browser Support
- Modern browsers (Chrome 80+, Firefox 78+, Safari 13+, Edge 80+)
- Mobile browsers (iOS Safari 13+, Chrome Mobile 80+)
- Internationalization requires Intl API support
## Bundle Size
- Core functionality: ~15KB gzipped
- Full features: ~25KB gzipped
- Tree-shakable for minimal builds
## Framework Compatibility
- ✅ React (16.8+)
- ✅ Vue (3.0+)
- ✅ Angular (12+)
- ✅ Svelte (3.0+)
- ✅ Vanilla JavaScript
- ✅ TypeScript (4.0+)