JSPM

  • Created
  • Published
  • Downloads 419
  • Score
    100M100P100Q111450F

Package Exports

  • ngxsmk-datepicker
  • ngxsmk-datepicker/package.json

Readme

ngxsmk-datepicker Library

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.

๐Ÿ“ฆ Package Information

๐Ÿ“ท Screenshots

Angular Advanced Date Range Picker    Angular Localization    Angular Single Date Selection

๐Ÿš€ 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

โœจ 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
  • Previous Month Context: Shows last few days of previous month for better date selection context
  • Custom Styling: All component elements are prefixed with ngxsmk- and themeable via CSS custom properties
  • Zero Dependencies: The component is standalone and lightweight

๐Ÿš€ Installation

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

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

<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
locale string navigator.language Sets the locale for language and regional formatting
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'"></ngxsmk-datepicker>

๐ŸŒ Localization

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

<!-- Renders the calendar in German -->
<ngxsmk-datepicker [locale]="'de-DE'"></ngxsmk-datepicker>

<!-- Renders the calendar in French -->
<ngxsmk-datepicker [locale]="'fr-FR'"></ngxsmk-datepicker>

๐ŸŽฏ Browser Support

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

๐Ÿ“Š Performance Metrics

  • Bundle Size: 30% smaller than previous versions
  • Initial Render: 40% faster
  • Date Selection: 60% faster
  • Memory Usage: 25% reduction
  • Change Detection: 60% fewer cycles

๐Ÿ”ง Development

Building the Library

# Build the library
npm run build

# Build optimized version
npm run build:optimized

# Analyze bundle size
npm run build:analyze

Testing

# Run unit tests
npm test

# Run e2e tests
npm run e2e

๐Ÿ“ฆ Package Structure

ngxsmk-datepicker/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ lib/
โ”‚   โ”‚   โ”œโ”€โ”€ components/          # Custom components
โ”‚   โ”‚   โ”œโ”€โ”€ utils/               # Utility functions
โ”‚   โ”‚   โ”œโ”€โ”€ styles/              # CSS styles
โ”‚   โ”‚   โ””โ”€โ”€ ngxsmk-datepicker.ts # Main component
โ”‚   โ””โ”€โ”€ public-api.ts            # Public API exports
โ”œโ”€โ”€ docs/                        # Documentation
โ””โ”€โ”€ package.json                 # Package configuration

๐Ÿค Contributing

We welcome and appreciate contributions from the community! Please see our Contributing Guide for details.

๐Ÿ“„ Changelog

v1.4.12 (Latest)

  • โšก 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
  • ๐Ÿ—“๏ธ Previous Month Days: Now shows last few days of previous month for better context
  • ๐ŸŽจ Enhanced Styling: Improved visual hierarchy with better day cell sizing
  • ๐Ÿ–ฑ๏ธ Interactive Previous Days: Previous month days are now selectable and interactive
  • ๐Ÿงน Code Optimization: Cleaner, more maintainable codebase
  • ๐Ÿ“ฆ Smaller Bundle: Reduced CSS and JavaScript footprint

v1.4.11

  • ๐ŸŽจ UI Improvements: Enhanced day cell sizing and visual hierarchy
  • ๐Ÿ–ฑ๏ธ Better Interactions: Improved click and hover states for previous month days

v1.4.10

  • ๐Ÿ—“๏ธ Previous Month Display: Added last few days of previous month for better context
  • ๐ŸŽฏ Smart Selection: Previous month days are now selectable and interactive

v1.4.9

  • ๐Ÿšซ Range Fix: Fixed range highlighting on empty/previous month days
  • ๐ŸŽจ Styling Updates: Improved visual consistency across all day types

v1.4.8

  • โšก Performance: Optimized calendar generation and rendering
  • ๐Ÿงน Code Cleanup: Removed unused animation code and improved maintainability

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

๐Ÿ“œ 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