1.0.8 • Published 1 year ago

@nabeeltahir/react-flexible-daterange v1.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

React Flexible DateRange

A flexible and customizable date range picker for React with multiple range selection support. This package was originally developed while working at Coredirection to address specific date range selection requirements in enterprise applications.

Background

This package was developed during my time at Coredirection to solve complex date range selection challenges in enterprise applications. The existing solutions didn't provide the flexibility and customization options we needed for handling multiple date ranges with specific business rules.

Features

  • 📅 Multiple date range selections
  • 📱 Responsive design (mobile-friendly)
  • 🎨 Customizable theme
  • 🌍 Internationalization support
  • ⌨️ Keyboard navigation
  • 🎯 TypeScript support
  • 🎨 Tailwind CSS integration

Installation

npm install react-flexible-daterange
# or
yarn add react-flexible-daterange

Basic Usage

import { Calendar } from 'react-flexible-daterange';
import type { DateRange } from 'react-flexible-daterange';

function App() {
  const [dateRanges, setDateRanges] = useState<DateRange[]>([]);

  return (
    <Calendar
      value={dateRanges}
      onChange={setDateRanges}
      maxDays={7}
    />
  );
}

Props

PropTypeDefaultDescription
valueDateRange[][]Selected date ranges
onChange(ranges: DateRange[]) => void-Callback when ranges change
maxDaysnumber7Maximum total days that can be selected
minDateDate-Minimum selectable date
maxDateDate-Maximum selectable date
disabledDatesDate[]-Array of disabled dates
weekStartsOn0-60First day of week (0 = Sunday)
localestring'en'Locale for date formatting
themeCalendarTheme-Custom theme options
showWeekNumbersbooleanfalseShow week numbers
monthsToShow1 | 22Number of months to display
allowPastDatesbooleanfalseAllow selecting past dates
formatDate(date: Date) => string-Custom date formatting
classNamestring-Additional CSS classes

Theme Customization

const theme: CalendarTheme = {
  colors: {
    primary: '#3B82F6',
    secondary: '#EFF6FF',
    hover: '#DBEAFE',
    disabled: '#E5E7EB',
    text: '#1F2937',
    textDisabled: '#9CA3AF',
  },
  borderRadius: '0.5rem',
  fontFamily: 'Inter, sans-serif',
};

<Calendar
  value={dateRanges}
  onChange={setDateRanges}
  theme={theme}
/>

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT

Author

Muhammad Nabeel Mehmood