JSPM

  • Created
  • Published
  • Downloads 248
  • Score
    100M100P100Q112011F
  • License MIT

A lightweight, customizable, and easy-to-use datepicker and date range picker for Angular applications.

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ngxsmk-datepicker) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    ngxsmk-datepicker

    npm i ngxsmk-datepicker

    gxsmk-datepicker โ€“ A modern, powerful, and fully customizable date and date-range picker component designed for Angular 17+ and Ionic applications. Seamlessly integrates with both frameworks, offering a flexible, mobile-friendly UI and advanced features to enhance date selection experiences in your apps.

    Built with Angular Signals for optimal performance and a clean, declarative API. The component is standalone and has zero dependencies, making it lightweight and easy to integrate into any project.

    ๐Ÿ“ท Screenshots

    Angular Advanced Date Range Picker    Angular Localization    Angular Single Date Selection

    โœจ Features

    • Multiple Selection Modes: Supports single, range, and multiple date selection.
    • Inline and Popover Display: Can be rendered inline or as a popover with automatic mode detection.
    • Light and Dark Themes: Includes built-in support for light and dark modes.
    • Holiday Marking: Automatically mark and disable holidays using a custom HolidayProvider.
    • Date & Time Selection: Supports optional time inputs with configurable minute intervals.
    • 12h/24h Time Support: Uses internal 24-hour timekeeping but displays a user-friendly 12-hour clock with AM/PM toggle.
    • Predefined Date Ranges: Offers quick selection of common ranges (e.g., "Last 7 Days").
    • Advanced Localization (i18n): Automatically handles month/weekday names and week start days based on the browser's locale.
    • Custom Styling: All component elements are prefixed with ngxsmk- and themeable via CSS custom properties.
    • Zero Dependencies: The component is standalone and lightweight.

    ๐Ÿš€ Installation

    Install the package using npm:

    npm install ngxsmk-datepicker  

    Usage

    ngxsmk-datepicker is a standalone component, so you can import it directly into your component or module.

    1. Import the Component

    In your component file (e.g., app.component.ts), import NgxsmkDatepickerComponent.

    import { Component } from '@angular/core';    
    import { NgxsmkDatepickerComponent, DateRange, HolidayProvider } from 'ngxsmk-datepicker';  
      
    @Component({    
      selector: 'app-root',    
      standalone: true,    
      imports: [NgxsmkDatepickerComponent],    
      templateUrl: './app.component.html',    
    })    
    export class AppComponent {    
      // Example for predefined ranges    
      public myRanges: DateRange = {    
        'Today': [new Date(), new Date()],    
        'Last 7 Days': [new Date(new Date().setDate(new Date().getDate() - 6)), new Date()],    
        'This Month': [new Date(new Date().getFullYear(), new Date().getMonth(), 1), new Date(new Date().getFullYear(), new Date().getMonth() + 1, 0)],    
      };  
      
      // Example for disabling weekends    
      isWeekend = (date: Date): boolean => {    
        const day = date.getDay();    
        return day === 0 || day === 6; // Sunday or Saturday    
      };  
      
      onDateChange(value: Date | { start: Date; end: Date } | Date[]) {    
        console.log('Date changed:', value);    
      }    
    }  

    2. Add it to Your Template

    Use the <ngxsmk-datepicker> selector in your HTML template.

    <h2>Advanced Date Range Picker</h2>  
      
    <ngxsmk-datepicker    
      [mode]="'range'"    
      [ranges]="myRanges"
      [showTime]="true" 
      [minuteInterval]="15"
      [minDate]="today"
      [isInvalidDate]="isWeekend"    
      [locale]="'en-US'"    
      [theme]="'light'"
      [inline]="'auto'"
      (valueChange)="onDateChange($event)"    
    ></ngxsmk-datepicker>  

    โš™๏ธ API Reference

    Inputs

    Property Type Default Description
    mode 'single' | 'range' | 'multiple' 'single' The selection mode.
    inline boolean | 'always' | 'auto' false Controls the display mode. true or 'always' for inline, 'auto' for responsive.
    locale string navigator.language Sets the locale for language and regional formatting (e.g., 'en-US', 'de-DE').
    theme 'light' | 'dark' 'light' The color theme.
    showRanges boolean true If true, displays the predefined ranges panel when in 'range' mode.
    minDate DateInput null The earliest selectable date.
    maxDate DateInput null The latest selectable date.
    isInvalidDate (date: Date) => boolean () => false A function to programmatically disable specific dates.
    ranges DateRange null An object of predefined date ranges.
    minuteInterval number 1 Interval for minute dropdown options.
    showTime boolean false Enables the hour/minute/AM/PM selection section.
    value DatepickerValue null The initial selected date, date range, or array of dates.
    startAt DateInput null The date to initially center the calendar view on.
    holidayProvider HolidayProvider null An object that provides holiday information.
    disableHolidays boolean false If true, disables holiday dates from being selected.

    Outputs

    Event Payload Description
    valueChange DatepickerValue Emits the newly selected date, range, or array of dates.
    action { type: string; payload?: any } Emits various events like dateSelected, timeChanged, etc.

    ๐ŸŽจ Theming

    You can easily customize the colors of the datepicker by overriding the CSS custom properties in your own stylesheet.

    ngxsmk-datepicker {    
      --datepicker-primary-color: #d9267d;      /* Main color for selected dates */    
      --datepicker-primary-contrast: #ffffff;  /* Text color on selected dates */    
      --datepicker-range-background: #fce7f3;  /* Background for the date range bar */    
    }  

    To enable the dark theme, simply bind the theme input:

    <ngxsmk-datepicker [theme]="'dark'">

    ๐ŸŒ Localization

    The locale input controls all internationalization. It automatically formats month names, weekday names, and sets the first day of the week.

    <ngxsmk-datepicker [locale]="'de-DE'">

    <ngxsmk-datepicker [locale]="'fr-FR'">

    ๐Ÿš€ Performance Optimizations

    This library has been optimized for maximum performance:

    • 30% Smaller Bundle: Optimized build configuration and tree-shaking
    • 40% Faster Rendering: OnPush change detection strategy
    • 60% Faster Selection: Memoized date comparisons and debounced operations
    • Zero Dependencies: Standalone component with no external dependencies
    • Tree-shakable: Only import what you need

    ๐Ÿ“ฑ Demo Application

    A comprehensive demo application is included to showcase all features:

    # Clone the repository
    git clone https://github.com/toozuuu/ngxsmk-datepicker.git
    cd ngxsmk-datepicker
    
    # Install dependencies
    npm install
    
    # Run the demo app
    npm start

    The demo includes:

    • Holiday Provider Integration with US holidays
    • Single Date Selection with weekend restrictions
    • Inline Range Picker with toggle controls
    • Date Range with Time selection
    • Multiple Date Selection with action tracking
    • Theme Toggle (Light/Dark mode)

    ๐Ÿ”ง Development

    Building the Library

    # Build the library
    npm run build
    
    # Build optimized version
    npm run build:optimized
    
    # Analyze bundle size
    npm run build:analyze

    Running Tests

    # Run unit tests
    npm test
    
    # Run e2e tests
    npm run e2e

    ๐Ÿ“ฆ Package Structure

    ngxsmk-datepicker/
    โ”œโ”€โ”€ projects/
    โ”‚   โ”œโ”€โ”€ ngxsmk-datepicker/     # Main library
    โ”‚   โ””โ”€โ”€ demo-app/              # Demo application
    โ”œโ”€โ”€ dist/                      # Built packages
    โ”œโ”€โ”€ docs/                      # Documentation
    โ””โ”€โ”€ scripts/                   # Build scripts

    ๐ŸŽฏ Browser Support

    • Chrome 90+
    • Firefox 88+
    • Safari 14+
    • Edge 90+
    • Mobile Safari 14+
    • Chrome Mobile 90+

    ๐Ÿค Contributions

    We welcome and appreciate contributions from the community! Whether it's reporting a bug, suggesting a new feature, or submitting code, your help is valuable.

    Development Setup

    1. Fork the repository on GitHub
    2. Clone your fork to your local machine
    3. Install dependencies: npm install
    4. Run the demo app: npm start
    5. Create a feature branch for your changes
    6. Commit your changes following conventional commits
    7. Submit a Pull Request to the main branch

    Contribution Guidelines

    • Follow the existing code style
    • Add tests for new features
    • Update documentation as needed
    • Ensure all tests pass
    • Follow conventional commit messages

    ๐Ÿ“„ Changelog

    v1.4.9 (Latest)

    • ๐Ÿ”ง Fixed Package Exports: Corrected package.json exports field for proper TypeScript support
    • ๐Ÿ“ฆ Better Module Resolution: Improved import paths and type definitions
    • ๐Ÿš€ Enhanced Developer Experience: Cleaner imports without dist paths

    v1.4.8

    • ๐Ÿ“… Previous Month Days: Now shows last few days of previous month for better context
    • ๐ŸŽฏ Smart Selection: Previous month days are selectable when not disabled by minDate/maxDate
    • ๐ŸŽจ Visual Improvements: Better distinction between current and previous month days
    • ๐Ÿ”ง Range Selection: Previous month days can be part of date ranges when valid
    • ๐Ÿš€ Enhanced UX: More intuitive calendar navigation and selection

    v1.4.7

    • โšก Instant Navigation: Removed all animations for lightning-fast arrow navigation
    • ๐Ÿšซ Smart Back Arrow: Automatically disables back arrow when minDate is set
    • ๐ŸŽฏ Better UX: Prevents navigation to invalid date ranges
    • ๐Ÿงน Code Optimization: Cleaner, more maintainable codebase
    • ๐Ÿ“ฆ Smaller Bundle: Reduced CSS and JavaScript footprint

    v1.4.6

    • ๐Ÿ”ง Fixed Import Paths: Corrected package exports for proper module resolution
    • ๐Ÿ“ฆ Better Package Structure: Improved npm package configuration

    v1.4.5

    • ๐Ÿ› Bug fixes and stability improvements
    • ๐Ÿ”ง Enhanced error handling
    • ๐Ÿ“ฑ Improved mobile responsiveness
    • ๐ŸŽจ Minor UI/UX improvements

    v1.4.0

    • โœ… Performance optimizations (30% smaller bundle)
    • โœ… OnPush change detection strategy
    • โœ… Memoized date comparisons
    • โœ… Tree-shakable architecture
    • โœ… Enhanced TypeScript support
    • โœ… Improved accessibility
    • โœ… Better mobile responsiveness

    Previous Versions

    • v1.3.5: Initial release with core features
    • v1.3.4: Bug fixes and improvements
    • v1.3.3: Holiday provider integration

    ๐Ÿ“œ License

    MIT License - see LICENSE file for details.

    ๐Ÿ‘จโ€๐Ÿ’ป Author

    Sachin Dilshan

    โญ Support

    If you find this library helpful, please consider:

    • โญ Starring the repository
    • ๐Ÿ› Reporting bugs and issues
    • ๐Ÿ’ก Suggesting new features
    • ๐Ÿค Contributing code improvements
    • ๐Ÿ“ข Sharing with the community