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.
- Github: https://github.com/toozuuu/ngxsmk-datepicker
- Live Demo: https://stackblitz.com/~/github.com/toozuuu/ngxsmk-datepicker
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
โจ Features
- Multiple Selection Modes: Supports
single,range, andmultipledate 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 startThe 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:analyzeRunning 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
- Fork the repository on GitHub
- Clone your fork to your local machine
- Install dependencies:
npm install - Run the demo app:
npm start - Create a feature branch for your changes
- Commit your changes following conventional commits
- 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
- ๐ง Email: sachindilshan040@gmail.com
- ๐ GitHub: @toozuuu
- ๐ฆ NPM: ngxsmk-datepicker
โญ 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