@oneluiz/dual-datepicker 2.5.0 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.nojekyll ADDED
File without changes
@@ -0,0 +1,82 @@
1
+ # GitHub Pages Setup
2
+
3
+ This project includes a live demo hosted on GitHub Pages.
4
+
5
+ ## 🚀 Viewing the Demo
6
+
7
+ Visit [https://oneluiz.github.io/ng-dual-datepicker/](https://oneluiz.github.io/ng-dual-datepicker/) to see the component in action.
8
+
9
+ ## 🛠️ Building the Demo Locally
10
+
11
+ To build and preview the demo locally:
12
+
13
+ ```bash
14
+ # Install dependencies
15
+ npm install
16
+
17
+ # Serve the demo locally
18
+ npm run demo:serve
19
+
20
+ # Build the demo for production
21
+ npm run demo:build
22
+ ```
23
+
24
+ The built demo will be placed in the `docs/` directory, which is configured for GitHub Pages deployment.
25
+
26
+ ## 📝 GitHub Pages Configuration
27
+
28
+ To enable GitHub Pages for this repository:
29
+
30
+ 1. Go to your repository settings on GitHub
31
+ 2. Navigate to **Pages** in the left sidebar
32
+ 3. Under **Source**, select:
33
+ - **Branch**: `main` (or your default branch)
34
+ - **Folder**: `/docs`
35
+ 4. Click **Save**
36
+ 5. Your site will be published at `https://[username].github.io/ng-dual-datepicker/`
37
+
38
+ ## 🔄 Updating the Demo
39
+
40
+ After making changes to the demo:
41
+
42
+ ```bash
43
+ # Rebuild the demo
44
+ npm run demo:build
45
+
46
+ # Move files from browser subfolder to docs root
47
+ cd docs && mv browser/* . && rm -r browser && cd ..
48
+
49
+ # Commit and push changes
50
+ git add docs/
51
+ git commit -m "Update demo"
52
+ git push
53
+ ```
54
+
55
+ GitHub Pages will automatically deploy the updated demo within a few minutes.
56
+
57
+ ## 📁 Project Structure
58
+
59
+ ```
60
+ ng-dual-datepicker/
61
+ ├── src/ # Source code for the component
62
+ ├── demo/ # Demo application source
63
+ │ └── src/
64
+ │ ├── app/ # Demo app components
65
+ │ ├── index.html # Demo HTML template
66
+ │ └── styles.scss # Demo styles
67
+ ├── docs/ # Built demo (GitHub Pages)
68
+ │ ├── .nojekyll # Tells GitHub not to use Jekyll
69
+ │ ├── index.html
70
+ │ └── *.js, *.css # Compiled assets
71
+ └── dist/ # Built library package
72
+ ```
73
+
74
+ ## 🎨 Customizing the Demo
75
+
76
+ The demo source code is in `demo/src/app/`. You can:
77
+
78
+ - Edit `app.component.html` to change the layout
79
+ - Edit `app.component.ts` to add new examples
80
+ - Edit `app.component.scss` or `styles.scss` for styling
81
+
82
+ After making changes, rebuild with `npm run demo:build`.
package/README.md CHANGED
@@ -22,6 +22,7 @@ npm install @oneluiz/dual-datepicker
22
22
  | **Dependencies** | Zero | Requires @angular/material, @angular/cdk |
23
23
  | **Standalone** | ✅ Native | ⚠️ Requires module setup |
24
24
  | **Signals Support** | ✅ Built-in | ❌ Not yet |
25
+ | **Multi-Range Support** | ✅ NEW v2.7.0 | ❌ Not available |
25
26
  | **Customization** | Full styling control | Theme-constrained |
26
27
  | **Learning Curve** | Minimal | Requires Material knowledge |
27
28
  | **Change Detection** | OnPush optimized | Default |
@@ -33,6 +34,7 @@ npm install @oneluiz/dual-datepicker
33
34
  - 🎯 **Standalone Component** – No NgModule imports needed
34
35
  - ⚡ **Angular Signals** – Modern reactive state management
35
36
  - 🔄 **Reactive Forms** – Full ControlValueAccessor implementation
37
+ - 🔥 **Multi-Range Support** – Select multiple date ranges (NEW v2.7.0 - Material CAN'T do this!)
36
38
  - 🎨 **Fully Customizable** – Every color, padding, border configurable
37
39
  - 📦 **Lightweight** – ~60 KB gzipped total bundle
38
40
  - 🚀 **Performance** – OnPush change detection + trackBy optimization
@@ -211,6 +213,73 @@ export class SignalsExampleComponent {
211
213
  }
212
214
  ```
213
215
 
216
+ ### 5. Multi-Range Support 🔥 NEW v2.7.0!
217
+
218
+ **Material CAN'T do this!** Select multiple date ranges in a single picker - perfect for booking systems, blackout periods, and complex scheduling.
219
+
220
+ ```typescript
221
+ import { Component } from '@angular/core';
222
+ import { DualDatepickerComponent, MultiDateRange } from '@oneluiz/dual-datepicker';
223
+
224
+ @Component({
225
+ selector: 'app-multi-range',
226
+ standalone: true,
227
+ imports: [DualDatepickerComponent],
228
+ template: `
229
+ <ngx-dual-datepicker
230
+ [multiRange]="true"
231
+ [showClearButton]="true"
232
+ (multiDateRangeChange)="onMultiRangeChange($event)">
233
+ </ngx-dual-datepicker>
234
+
235
+ @if (selectedRanges && selectedRanges.ranges.length > 0) {
236
+ <div class="selected-ranges">
237
+ <h3>Selected Ranges ({{ selectedRanges.ranges.length }})</h3>
238
+ @for (range of selectedRanges.ranges; track $index) {
239
+ <div class="range-item">
240
+ <strong>Range {{ $index + 1 }}:</strong> {{ range.rangoTexto }}
241
+ <br>
242
+ <span>{{ range.fechaInicio }} → {{ range.fechaFin }}</span>
243
+ </div>
244
+ }
245
+ </div>
246
+ }
247
+ `
248
+ })
249
+ export class MultiRangeExample {
250
+ selectedRanges: MultiDateRange | null = null;
251
+
252
+ onMultiRangeChange(ranges: MultiDateRange) {
253
+ this.selectedRanges = ranges;
254
+ console.log('Selected ranges:', ranges.ranges);
255
+ // Output example:
256
+ // [
257
+ // { fechaInicio: '2026-01-01', fechaFin: '2026-01-05', rangoTexto: 'Jan 1 – Jan 5' },
258
+ // { fechaInicio: '2026-01-10', fechaFin: '2026-01-15', rangoTexto: 'Jan 10 – Jan 15' },
259
+ // { fechaInicio: '2026-02-01', fechaFin: '2026-02-07', rangoTexto: 'Feb 1 – Feb 7' }
260
+ // ]
261
+ }
262
+ }
263
+ ```
264
+
265
+ #### Perfect Use Cases
266
+
267
+ - 🏨 **Hotel Booking Systems** - Block multiple periods for reservations
268
+ - 📅 **Event Blackout Periods** - Mark multiple dates as unavailable
269
+ - 🔧 **Maintenance Windows** - Schedule multiple maintenance periods
270
+ - 📊 **Availability Calendars** - Show multiple available/unavailable periods
271
+ - 👷 **Shift Scheduling** - Select multiple work periods
272
+ - 💼 **Business Meetings** - Block out multiple date ranges
273
+
274
+ #### Key Features
275
+
276
+ - ✅ Select unlimited date ranges
277
+ - ✅ Visual feedback - all ranges highlighted in calendar
278
+ - ✅ Easy management - add/remove ranges with one click
279
+ - ✅ Separate events for multi-range (`multiDateRangeChange`, `multiDateRangeSelected`)
280
+ - ✅ Clear all ranges with one button
281
+ - ❌ **Angular Material CANNOT do this!**
282
+
214
283
  ## 🔌 Date Adapter System
215
284
 
216
285
  The library supports custom date adapters, allowing you to use different date libraries (DayJS, date-fns, Luxon) or custom backend models instead of native JavaScript `Date` objects.
@@ -456,7 +525,11 @@ export class DayJSAdapter extends DateAdapter<Dayjs> {
456
525
  </ngx-dual-datepicker>
457
526
  ```
458
527
 
459
- ### Custom Presets
528
+ ### Custom Presets (Power Feature)
529
+
530
+ **This is where our library shines!** Unlike Angular Material, we offer an incredibly flexible preset system perfect for dashboards, reporting, POS, BI apps, and ERP systems.
531
+
532
+ #### Simple Pattern (Backward Compatible)
460
533
 
461
534
  ```typescript
462
535
  customPresets: PresetConfig[] = [
@@ -467,6 +540,132 @@ customPresets: PresetConfig[] = [
467
540
  ];
468
541
  ```
469
542
 
543
+ #### **NEW v2.6.0** - Flexible Pattern with `getValue()` 🔥
544
+
545
+ The real power comes with the `getValue()` pattern. Define **any custom logic** you need:
546
+
547
+ ```typescript
548
+ import { PresetConfig } from '@oneluiz/dual-datepicker';
549
+
550
+ customPresets: PresetConfig[] = [
551
+ {
552
+ label: 'Today',
553
+ getValue: () => {
554
+ const today = new Date();
555
+ return {
556
+ start: formatDate(today),
557
+ end: formatDate(today)
558
+ };
559
+ }
560
+ },
561
+ {
562
+ label: 'This Month',
563
+ getValue: () => {
564
+ const today = new Date();
565
+ const start = new Date(today.getFullYear(), today.getMonth(), 1);
566
+ const end = new Date(today.getFullYear(), today.getMonth() + 1, 0);
567
+ return {
568
+ start: formatDate(start),
569
+ end: formatDate(end)
570
+ };
571
+ }
572
+ },
573
+ {
574
+ label: 'Last Month',
575
+ getValue: () => {
576
+ const today = new Date();
577
+ const start = new Date(today.getFullYear(), today.getMonth() - 1, 1);
578
+ const end = new Date(today.getFullYear(), today.getMonth(), 0);
579
+ return {
580
+ start: formatDate(start),
581
+ end: formatDate(end)
582
+ };
583
+ }
584
+ },
585
+ {
586
+ label: 'Quarter to Date',
587
+ getValue: () => {
588
+ const today = new Date();
589
+ const currentMonth = today.getMonth();
590
+ const quarterStartMonth = Math.floor(currentMonth / 3) * 3;
591
+ const start = new Date(today.getFullYear(), quarterStartMonth, 1);
592
+ return {
593
+ start: formatDate(start),
594
+ end: formatDate(today)
595
+ };
596
+ }
597
+ }
598
+ ];
599
+ ```
600
+
601
+ #### **Even Better** - Use Pre-built Utilities 🚀
602
+
603
+ We provide **ready-to-use preset utilities** for common scenarios:
604
+
605
+ ```typescript
606
+ import { CommonPresets } from '@oneluiz/dual-datepicker';
607
+
608
+ // Dashboard presets
609
+ presets = CommonPresets.dashboard;
610
+ // → Today, Yesterday, Last 7 days, Last 30 days, This month, Last month
611
+
612
+ // Reporting presets
613
+ presets = CommonPresets.reporting;
614
+ // → Today, This week, Last week, This month, Last month, This quarter, Last quarter
615
+
616
+ // Financial/ERP presets
617
+ presets = CommonPresets.financial;
618
+ // → Month to date, Quarter to date, Year to date, Last month, Last quarter, Last year
619
+
620
+ // Analytics/BI presets
621
+ presets = CommonPresets.analytics;
622
+ // → Last 7/14/30/60/90/180/365 days
623
+
624
+ // Simple presets
625
+ presets = CommonPresets.simple;
626
+ // → Today, Last 7 days, Last 30 days, This year
627
+ ```
628
+
629
+ #### Create Your Own Utilities
630
+
631
+ Import individual utilities and mix them:
632
+
633
+ ```typescript
634
+ import {
635
+ getToday,
636
+ getThisMonth,
637
+ getLastMonth,
638
+ getQuarterToDate,
639
+ getYearToDate,
640
+ PresetConfig
641
+ } from '@oneluiz/dual-datepicker';
642
+
643
+ customPresets: PresetConfig[] = [
644
+ { label: 'Today', getValue: getToday },
645
+ { label: 'This Month', getValue: getThisMonth },
646
+ { label: 'Last Month', getValue: getLastMonth },
647
+ { label: 'Quarter to Date', getValue: getQuarterToDate },
648
+ { label: 'Year to Date', getValue: getYearToDate },
649
+ {
650
+ label: 'Custom Logic',
651
+ getValue: () => {
652
+ // Your custom date calculation
653
+ return { start: '2026-01-01', end: '2026-12-31' };
654
+ }
655
+ }
656
+ ];
657
+ ```
658
+
659
+ #### Why This Is Powerful
660
+
661
+ ✅ **Perfect for Dashboards** - "Last 7 days", "Month to date", "Quarter to date"
662
+ ✅ **Perfect for Reporting** - "This week", "Last week", "This quarter"
663
+ ✅ **Perfect for Financial Systems** - "Quarter to date", "Year to date", "Fiscal year"
664
+ ✅ **Perfect for Analytics** - Consistent date ranges for BI tools
665
+ ✅ **Perfect for ERP** - Custom business logic and fiscal calendars
666
+
667
+ **Angular Material doesn't offer this level of flexibility!** 🎯
668
+
470
669
  ```html
471
670
  <ngx-dual-datepicker
472
671
  [(ngModel)]="dateRange"
@@ -534,14 +733,23 @@ export class MyComponent {
534
733
  ### Types
535
734
 
536
735
  ```typescript
537
- infechaInicio: string; // ISO date format: 'YYYY-MM-DD'
736
+ interface DateRange {
737
+ fechaInicio: string; // ISO date format: 'YYYY-MM-DD'
538
738
  fechaFin: string; // ISO date format: 'YYYY-MM-DD'
539
739
  rangoTexto: string; // Display text: 'DD Mon - DD Mon'
540
740
  }
541
741
 
742
+ interface PresetRange {
743
+ start: string; // ISO date format: 'YYYY-MM-DD'
744
+ end: string; // ISO date format: 'YYYY-MM-DD'
745
+ }
746
+
542
747
  interface PresetConfig {
543
748
  label: string;
544
- daysAgo: number;
749
+ /** @deprecated Use getValue() instead for more flexibility */
750
+ daysAgo?: number;
751
+ /** NEW v2.6.0 - Function that returns date range with custom logic */
752
+ getValue?: () => PresetRange;
545
753
  }
546
754
 
547
755
  interface LocaleConfig {
@@ -550,7 +758,6 @@ interface LocaleConfig {
550
758
  dayNames?: string[]; // Full day names (7 items, starting Sunday)
551
759
  dayNamesShort?: string[]; // Short day names (7 items, starting Sunday)
552
760
  firstDayOfWeek?: number; // 0 = Sunday, 1 = Monday, etc. (not yet implemented)
553
- daysAgo: number;
554
761
  }
555
762
  ```
556
763
 
@@ -678,17 +885,26 @@ export class ExampleComponent {
678
885
  - Angular 19.0.0 or higher
679
886
  - Angular 20.0.0 or higher
680
887
 
681
- ## �️ Roadmap
888
+ ## 🗺️ Roadmap
889
+
890
+ Recently shipped:
891
+
892
+ **v2.6.0:**
893
+ - ✅ **Flexible Preset System** - `getValue()` pattern for custom date logic (This month, Last month, Quarter to date, etc.)
894
+ - ✅ **Pre-built Preset Utilities** - CommonPresets for Dashboard, Reporting, Financial, Analytics
895
+ - ✅ **Real Differentiator** - Perfect for ERP, BI, POS, and Reporting systems
896
+
897
+ **v2.5.0:**
898
+ - ✅ **Date Adapter System** - Support for DayJS, date-fns, Luxon, and custom date libraries
682
899
 
683
900
  Planned features and improvements:
684
901
 
685
902
  - ⬜ **Complete keyboard navigation** - Arrow keys, Enter/Space, Tab, Escape
686
903
  - ⬜ **Full accessibility audit** - WCAG 2.1 AA compliance
687
- - ⬜ **Presets improvements** - More flexible preset configurations
688
904
  - ⬜ **Multi-range support** - Select multiple date ranges
689
905
  - ⬜ **Theming system** - Pre-built theme presets
690
906
 
691
- ## �📄 License
907
+ ## 📄 License
692
908
 
693
909
  MIT © Luis Cortes
694
910
 
package/angular.json ADDED
@@ -0,0 +1,75 @@
1
+ {
2
+ "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3
+ "version": 1,
4
+ "newProjectRoot": "projects",
5
+ "projects": {
6
+ "demo": {
7
+ "projectType": "application",
8
+ "schematics": {
9
+ "@schematics/angular:component": {
10
+ "style": "scss"
11
+ }
12
+ },
13
+ "root": "demo",
14
+ "sourceRoot": "demo/src",
15
+ "prefix": "app",
16
+ "architect": {
17
+ "build": {
18
+ "builder": "@angular-devkit/build-angular:application",
19
+ "options": {
20
+ "outputPath": "docs",
21
+ "index": "demo/src/index.html",
22
+ "browser": "demo/src/main.ts",
23
+ "polyfills": [
24
+ "zone.js"
25
+ ],
26
+ "tsConfig": "demo/tsconfig.app.json",
27
+ "inlineStyleLanguage": "scss",
28
+ "assets": [
29
+ "demo/src/favicon.svg"
30
+ ],
31
+ "styles": [
32
+ "demo/src/styles.scss"
33
+ ],
34
+ "scripts": []
35
+ },
36
+ "configurations": {
37
+ "production": {
38
+ "budgets": [
39
+ {
40
+ "type": "initial",
41
+ "maximumWarning": "500kB",
42
+ "maximumError": "1MB"
43
+ },
44
+ {
45
+ "type": "anyComponentStyle",
46
+ "maximumWarning": "4kB",
47
+ "maximumError": "10kB"
48
+ }
49
+ ],
50
+ "outputHashing": "all"
51
+ },
52
+ "development": {
53
+ "optimization": false,
54
+ "extractLicenses": false,
55
+ "sourceMap": true
56
+ }
57
+ },
58
+ "defaultConfiguration": "production"
59
+ },
60
+ "serve": {
61
+ "builder": "@angular-devkit/build-angular:dev-server",
62
+ "configurations": {
63
+ "production": {
64
+ "buildTarget": "demo:build:production"
65
+ },
66
+ "development": {
67
+ "buildTarget": "demo:build:development"
68
+ }
69
+ },
70
+ "defaultConfiguration": "development"
71
+ }
72
+ }
73
+ }
74
+ }
75
+ }
package/dist/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Luis Cortes
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.