UNPKG

ngxsmk-datepicker

Version:

<!-- SEO Keywords: Angular DatePicker, Angular Date Range Picker, Lightweight Calendar Component, Angular Signals DatePicker, SSR Ready DatePicker, Zoneless Angular, A11y DatePicker, Mobile-Friendly DatePicker, Ionic DatePicker Meta Description: The

458 lines (349 loc) β€’ 16.9 kB
# Version Compatibility Matrix **Last updated:** May 2, 2026 Β· **Current stable:** v2.2.12 This document provides comprehensive compatibility information for `ngxsmk-datepicker` across different Angular versions, Zone.js configurations, and SSR/CSR setups. ## πŸ“‹ Angular Version Compatibility ### Compatibility Matrix | Angular Version | Status | Core Features | Signal Features | Signal Forms | SSR Support | Notes | |----------------|--------|--------------|----------------|--------------|-------------|-------| | **Angular 17** | βœ… Fully Supported | βœ… All | βœ… Signals, Computed | ❌ Not Available | βœ… Full | Minimum supported version | | **Angular 18** | βœ… Fully Supported | βœ… All | βœ… Signals, Computed, Effects | ❌ Not Available | βœ… Full | Enhanced signal support | | **Angular 19** | βœ… Fully Supported | βœ… All | βœ… Signals, Computed, Effects | ❌ Not Available | βœ… Full | Optimized performance | | **Angular 20** | βœ… Fully Supported | βœ… All | βœ… Signals, Computed, Effects | ❌ Not Available | βœ… Full | Fully supported | | **Angular 21** | βœ… Fully Supported | βœ… All | βœ… Signals, Computed, Effects | βœ… Signal Forms `[field]` | βœ… Full | **Officially released - Current development target**<br/>βœ… Signal Forms (experimental)<br/>βœ… Zoneless by default<br/>βœ… Compatible with Vitest-based apps<br/>βœ… Angular Aria compatible | | **Angular 22+** | πŸ”„ Future Support | βœ… All | βœ… Signals, Computed, Effects | βœ… Signal Forms `[field]` | βœ… Full | Peer dependency: `<24.0.0` | ### Feature Availability by Angular Version #### Core Features (Available in all versions) - βœ… Date selection (single, range, multiple) - βœ… Time selection - βœ… Calendar views (month, year, decade, timeline, time-slider) - βœ… Keyboard navigation - βœ… Touch gestures - βœ… RTL support - βœ… Timezone support - βœ… Custom formatting - βœ… Holiday provider integration - βœ… Custom hooks and extensions - βœ… Accessibility (ARIA, keyboard) - βœ… Theming (light/dark) - βœ… Translations/i18n #### Signal Features (Angular 17+) - βœ… `signal()` - Reactive state management - βœ… `computed()` - Derived reactive values - βœ… `effect()` - Side effects (Angular 18+) - βœ… `inject()` - Dependency injection #### Signal Forms (Angular 21+) - βœ… `[field]` input binding (experimental Angular 21 feature) - βœ… Automatic field synchronization - βœ… Reactive form field updates - βœ… Signal-based value management - βœ… Works with `form()`, `objectSchema()`, and `validators` - βœ… Compatible with `httpResource` and `linkedSignal` patterns #### Angular 21 New Features Compatibility - βœ… **Zoneless by Default**: Fully compatible with Angular 21 apps that don't include Zone.js - βœ… **Vitest Test Runner**: Library works in apps using Vitest-based setups - βœ… **Angular Aria**: Compatible with Angular Aria components; uses custom ARIA implementation for screen reader support ### Peer Dependencies ```json { "@angular/common": ">=17.0.0 <24.0.0", "@angular/core": ">=17.0.0 <24.0.0", "@angular/forms": ">=17.0.0 <24.0.0" } ``` **Zone.js**: Optional (declared in `peerDependenciesMeta`) ## πŸ”„ Zone.js vs Zoneless Compatibility ### Overview `ngxsmk-datepicker` is designed to work **with or without Zone.js**, making it compatible with both traditional Angular applications and modern zoneless applications. ### Zone.js Required Features | Feature | With Zone.js | Without Zone.js | Notes | |---------|--------------|-----------------|-------| | **Change Detection** | βœ… Automatic | βœ… Manual (OnPush) | Component uses `OnPush` strategy | | **Form Integration** | βœ… Works | βœ… Works | Uses `ControlValueAccessor` | | **Event Handling** | βœ… Works | βœ… Works | Native event listeners | | **Signal Updates** | βœ… Works | βœ… Works | Signals trigger change detection | | **Reactive Forms** | βœ… Works | βœ… Works | FormControl integration | | **Signal Forms** | βœ… Works | βœ… Works | Angular 21+ signal forms | ### Zoneless Setup The component uses **OnPush change detection strategy** and **signals** for reactive updates, making it fully compatible with zoneless applications: ```typescript @Component({ selector: 'ngxsmk-datepicker', changeDetection: ChangeDetectionStrategy.OnPush, // βœ… Zoneless compatible // ... }) ``` #### Manual Change Detection When using without Zone.js, the component handles change detection internally: ```typescript // Component automatically calls markForCheck() when needed private scheduleChangeDetection(): void { if (!this._changeDetectionScheduled) { this._changeDetectionScheduled = true; Promise.resolve().then(() => { this._changeDetectionScheduled = false; this.cdr.markForCheck(); }); } } ``` #### Signal-Based Reactivity The component uses Angular signals for reactive state: ```typescript // Reactive calendar open state private _isCalendarOpen = signal<boolean>(false); // Computed dependencies for memoization private _memoDependencies = computed(() => ({ month: this._currentMonthSignal(), year: this._currentYearSignal(), // ... })); ``` ### Zone.js Configuration #### With Zone.js (Default) ```typescript // main.ts import { bootstrapApplication } from '@angular/platform-browser'; import { AppComponent } from './app/app.component'; bootstrapApplication(AppComponent); // Zone.js is automatically included ``` #### Without Zone.js (Zoneless) ```typescript // main.ts import { bootstrapApplication } from '@angular/platform-browser'; import { AppComponent } from './app/app.component'; bootstrapApplication(AppComponent, { providers: [ // No Zone.js provider needed // Component works with OnPush + signals ] }); ``` ### Migration Guide: Zone.js β†’ Zoneless 1. **Remove Zone.js dependency** (if desired) 2. **Ensure OnPush strategy** (already used by component) 3. **Use signals for state** (component already uses signals) 4. **No code changes needed** - component is zoneless-ready ## 🌐 SSR vs CSR Compatibility ### Server-Side Rendering (SSR) The component is **fully compatible** with Angular Universal and SSR. #### SSR-Safe Features | Feature | SSR Support | Implementation | |---------|-------------|----------------| | **Platform Detection** | βœ… Safe | Uses `isPlatformBrowser()` and `PLATFORM_ID` | | **DOM Access** | βœ… Safe | Guarded with `isBrowser` checks | | **Event Listeners** | βœ… Safe | Only attached in browser | | **Date Formatting** | βœ… Safe | Uses `Intl` API (available in Node.js) | | **Local Storage** | βœ… Safe | Not used | | **Window/Document** | βœ… Safe | Guarded with platform checks | #### SSR Implementation Details ```typescript // Platform detection private readonly platformId = inject(PLATFORM_ID); private readonly isBrowser = isPlatformBrowser(this.platformId); // Safe DOM access if (this.isBrowser && typeof document !== 'undefined') { // Browser-only code document.documentElement.dir === 'rtl'; } // Safe event listeners if (this.isBrowser) { // Attach event listeners } ``` #### SSR-Specific Considerations 1. **Initial Render**: Component renders safely on server 2. **Hydration**: Client-side hydration works correctly 3. **Date Formatting**: Uses `Intl.DateTimeFormat` (available in Node.js 13+) 4. **Locale Detection**: Falls back to 'en-US' on server if `navigator` is unavailable ### Client-Side Rendering (CSR) All features work identically in CSR mode. No special configuration needed. ### SSR vs CSR Differences | Aspect | SSR | CSR | Notes | |--------|-----|-----|-------| | **Initial Render** | Server | Browser | Component renders on both | | **DOM Access** | ❌ Not Available | βœ… Available | Guarded with `isPlatformBrowser()` | | **Event Listeners** | ❌ Not Attached | βœ… Attached | Only in browser | | **Date Formatting** | βœ… Works | βœ… Works | Uses `Intl` API | | **Locale Detection** | ⚠️ Limited | βœ… Full | Server uses default, browser detects | | **Performance** | βœ… Fast Initial Load | βœ… Interactive | SSR improves SEO and initial load | ### SSR Setup Example ```typescript // app.config.ts import { ApplicationConfig } from '@angular/core'; import { provideClientHydration } from '@angular/platform-browser'; export const appConfig: ApplicationConfig = { providers: [ provideClientHydration(), // Enable SSR hydration // ... other providers ] }; ``` ```typescript // Component usage (works in both SSR and CSR) @Component({ template: ` <ngxsmk-datepicker [locale]="'en-US'" mode="single"> </ngxsmk-datepicker> ` }) export class MyComponent { // Component automatically handles SSR/CSR differences } ``` ## πŸ”§ Feature Compatibility Matrix ### By Angular Version | Feature | Angular 17 | Angular 18 | Angular 19 | Angular 20 | Angular 21+ | |---------|------------|-----------|------------|------------|-------------| | **Standalone Component** | βœ… | βœ… | βœ… | βœ… | βœ… | | **Signals** | βœ… | βœ… | βœ… | βœ… | βœ… | | **Computed Signals** | βœ… | βœ… | βœ… | βœ… | βœ… | | **Effects** | ⚠️ Limited | βœ… | βœ… | βœ… | βœ… | | **Signal Forms** | ❌ | ❌ | ❌ | ❌ | βœ… | | **ControlValueAccessor** | βœ… | βœ… | βœ… | βœ… | βœ… | | **Reactive Forms** | βœ… | βœ… | βœ… | βœ… | βœ… | | **OnPush Strategy** | βœ… | βœ… | βœ… | βœ… | βœ… | | **SSR Support** | βœ… | βœ… | βœ… | βœ… | βœ… | | **Zoneless Support** | βœ… | βœ… | βœ… | βœ… | βœ… | | **Translations/i18n** | βœ… | βœ… | βœ… | βœ… | βœ… | | **Locale Registry** | βœ… | βœ… | βœ… | βœ… | βœ… | ### By Configuration | Configuration | Zone.js | Zoneless | SSR | CSR | |---------------|---------|----------|-----|-----| | **Change Detection** | βœ… Auto | βœ… Manual | βœ… Works | βœ… Works | | **Form Integration** | βœ… Works | βœ… Works | βœ… Works | βœ… Works | | **Event Handling** | βœ… Works | βœ… Works | ⚠️ Browser Only | βœ… Works | | **Signal Updates** | βœ… Works | βœ… Works | βœ… Works | βœ… Works | | **Date Formatting** | βœ… Works | βœ… Works | βœ… Works | βœ… Works | | **Keyboard Navigation** | βœ… Works | βœ… Works | ⚠️ Browser Only | βœ… Works | | **Touch Gestures** | βœ… Works | βœ… Works | ⚠️ Browser Only | βœ… Works | ## πŸ“ Migration Guides ### Upgrading from Angular 17 to 21 1. **Update Angular dependencies**: ```bash ng update @angular/core @angular/cli ``` 2. **Enable Signal Forms** (Angular 21+): ```typescript // Before (Angular 17-20) <ngxsmk-datepicker [value]="dateValue" (valueChange)="dateValue = $event"> </ngxsmk-datepicker> // After (Angular 21+) <ngxsmk-datepicker [field]="myForm.myDate"> </ngxsmk-datepicker> ``` 3. **No breaking changes** - all existing code continues to work ### Migrating to Zoneless 1. **Remove Zone.js** (optional): ```bash npm uninstall zone.js ``` 2. **Update bootstrap** (if needed): ```typescript // No changes needed - component is already zoneless-ready ``` 3. **Verify OnPush strategy** (already used): ```typescript // Component already uses OnPush changeDetection: ChangeDetectionStrategy.OnPush ``` ### Enabling SSR 1. **Install Angular Universal**: ```bash ng add @angular/ssr ``` 2. **Configure SSR**: ```typescript // app.config.ts import { provideClientHydration } from '@angular/platform-browser'; export const appConfig: ApplicationConfig = { providers: [provideClientHydration()] }; ``` 3. **No component changes needed** - component is SSR-safe ## ⚠️ Known Limitations ### Angular 17 - Effects support is limited (use signals/computed instead) - Signal Forms not available (use `[value]` binding) ### SSR - DOM-dependent features only work in browser (keyboard navigation, touch gestures) - Locale auto-detection falls back to 'en-US' on server ### Zoneless - Requires manual change detection (handled automatically by component) - Form integration works the same as with Zone.js ## πŸ§ͺ Testing Compatibility The component is tested against: - βœ… Angular 17, 18, 19, 20, 21 - βœ… With and without Zone.js - βœ… SSR and CSR modes - βœ… Various browser environments - βœ… **Vitest Compatible**: Works in Angular 21 applications using Vitest-based test setups - Library tests use Karma/Jasmine, but the library itself is fully compatible with Vitest-based apps - No changes needed when using Vitest in your Angular 21 application ## πŸ†• Angular 21 New Features Support ### Signal Forms (Experimental) - βœ… **Full Support**: `[field]` input binding for direct Signal Forms integration - βœ… **Automatic Sync**: Two-way binding with signal form fields - βœ… **Validation**: Respects field validation and disabled state - βœ… **Server Integration**: Works with `httpResource` and `linkedSignal` patterns ### Zoneless by Default - βœ… **Fully Compatible**: Works in Angular 21 apps without Zone.js - βœ… **OnPush Strategy**: Uses OnPush change detection for optimal performance - βœ… **Signal-Based**: Leverages signals for reactive updates - βœ… **No Changes Needed**: Existing code works without modification ### Vitest Test Runner - βœ… **Compatible**: Library works in apps using Vitest-based setups - βœ… **No Migration Required**: Use the library as-is in Vitest-based projects - βœ… **Test Suite**: Library tests use Karma/Jasmine but library is Vitest-compatible ### Angular Aria Compatibility - βœ… **ARIA Support**: Built-in ARIA attributes and screen reader support - βœ… **AriaLiveService**: Custom service for live region announcements - βœ… **Compatible**: Works alongside Angular Aria components - βœ… **Accessibility First**: All interactive elements have proper ARIA labels ## πŸ“š Additional Resources - [Angular Signals Documentation](https://angular.dev/guide/signals) - [Angular SSR Guide](https://angular.dev/guide/ssr) - [Zoneless Angular Guide](https://angular.dev/guide/zoneless) - [Signal Forms Documentation](https://angular.dev/guide/forms/signal-forms) - [Vitest Documentation](https://vitest.dev/) - [Angular Aria Documentation](https://angular.dev/guide/accessibility/angular-aria) ## πŸ” Version Detection To check your Angular version: ```bash ng version ``` To verify compatibility: ```bash npm list @angular/core @angular/common @angular/forms ``` ## πŸ’‘ Best Practices 1. **Use Signal Forms** (Angular 21+): Prefer `[field]` input for better integration 2. **Enable SSR**: Improves SEO and initial load performance 3. **Consider Zoneless**: Better performance, component is ready 4. **Use OnPush**: Already enabled, ensures optimal change detection 5. **Platform Checks**: Component handles SSR/CSR automatically ## πŸ†˜ Troubleshooting ### Issue: Component not updating in zoneless app **Solution**: Component uses `markForCheck()` internally. Ensure you're using signals for reactive updates. ### Issue: SSR errors with DOM access **Solution**: Component guards all DOM access. Check if you're using any custom code that accesses DOM directly. ### Issue: Signal Forms not working (Angular 21+) **Solution**: Ensure you're using Angular 21+ and the `[field]` input with a signal form field. ### Issue: Translations not working in SSR **Solution**: Translations work in SSR. Ensure locale is explicitly set if auto-detection fails on server. ## CI and Angular peer matrix (maintainers) Recommended validation before tagging a release: | Step | Command | Notes | |------|---------|--------| | Library build | `npx ng build ngxsmk-datepicker --configuration production` | Ensures `dist/ngxsmk-datepicker` artifacts | | Unit tests | `npm run test:coverage` | Karma/Jasmine for `ngxsmk-datepicker` project | | Demo build | `npx ng build demo-app --configuration production` | Catches app integration issues | | Lint | `npm run lint` | ESLint across workspace | | E2E (optional CI) | `npm run e2e` with `BASE_URL` pointing at served demo | Playwright; set `CI=1` and start demo separately in pipelines | **Angular minors**: Keep `@angular/*` on the same minor within the workspace (`package.json`). Bump peers in library `projects/ngxsmk-datepicker/package.json` when raising supported ceiling; update this doc’s matrix table and peer JSON block together. **Ionic/Capacitor sample**: The `examples/ionic-test-app` project may require `npm install --legacy-peer-deps` when Ionic’s peers lag Angularβ€”see [examples/ionic-test-app/README.md](../../../examples/ionic-test-app/README.md).