hijri-date-time-picker 1.0.3 → 1.0.31
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/QUICKSTART.md +121 -0
- package/docs/INITIAL_DATE_BINDING.md +183 -0
- package/docs/MIN_MAX_DATE.md +326 -0
- package/ng-package.json +11 -0
- package/package.json +2 -8
- package/src/demo.ts +246 -0
- package/src/index.ts +2 -0
- package/src/lib/hijri-date-picker.component.css +524 -0
- package/src/lib/hijri-date-picker.component.html +229 -0
- package/src/lib/hijri-date-picker.component.ts +795 -0
- package/src/lib/hijri-date-picker.types.ts +164 -0
- package/src/types/hijri-date.d.ts +43 -0
- package/tsconfig.json +39 -0
- package/dist/LICENSE +0 -21
- package/dist/README.md +0 -188
- package/dist/fesm2022/hijri-date-time-picker.mjs +0 -786
- package/dist/fesm2022/hijri-date-time-picker.mjs.map +0 -1
- package/dist/types/hijri-date-time-picker.d.ts +0 -179
package/QUICKSTART.md
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# Quick Start Guide
|
|
2
|
+
|
|
3
|
+
## Installation
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
cd C:\Users\Hany\.gemini\antigravity\scratch\hijri-date-picker
|
|
7
|
+
npm install
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Build the Library
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm run build
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## File Overview
|
|
17
|
+
|
|
18
|
+
### Core Component Files
|
|
19
|
+
- **hijri-date-picker.component.ts** - Main component with all logic (350+ lines)
|
|
20
|
+
- **hijri-date-picker.component.html** - Template with calendar UI
|
|
21
|
+
- **hijri-date-picker.component.css** - Comprehensive styles with theming
|
|
22
|
+
- **hijri-date-picker.types.ts** - TypeScript interfaces and constants
|
|
23
|
+
|
|
24
|
+
### Configuration
|
|
25
|
+
- **package.json** - NPM package configuration
|
|
26
|
+
- **tsconfig.json** - TypeScript compiler settings
|
|
27
|
+
- **README.md** - Complete documentation with examples
|
|
28
|
+
|
|
29
|
+
### Demo
|
|
30
|
+
- **demo.ts** - Standalone demo app with 6 different examples
|
|
31
|
+
|
|
32
|
+
## Quick Usage
|
|
33
|
+
|
|
34
|
+
### Basic Example
|
|
35
|
+
```typescript
|
|
36
|
+
import { HijriDatePickerComponent } from 'hijri-date-picker';
|
|
37
|
+
|
|
38
|
+
// In your component
|
|
39
|
+
@Component({
|
|
40
|
+
imports: [HijriDatePickerComponent],
|
|
41
|
+
template: `
|
|
42
|
+
<hijri-date-picker
|
|
43
|
+
[mode]="'greg'"
|
|
44
|
+
[locale]="'en'"
|
|
45
|
+
(dateSelected)="onDateSelected($event)">
|
|
46
|
+
</hijri-date-picker>
|
|
47
|
+
`
|
|
48
|
+
})
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### With Date Range (NEW)
|
|
52
|
+
```typescript
|
|
53
|
+
@Component({
|
|
54
|
+
imports: [HijriDatePickerComponent],
|
|
55
|
+
template: `
|
|
56
|
+
<hijri-date-picker
|
|
57
|
+
[minDate]="minDate"
|
|
58
|
+
[maxDate]="maxDate"
|
|
59
|
+
[futureValidation]="false"
|
|
60
|
+
(dateSelected)="onDateSelected($event)">
|
|
61
|
+
</hijri-date-picker>
|
|
62
|
+
`
|
|
63
|
+
})
|
|
64
|
+
export class MyComponent {
|
|
65
|
+
// Allow only dates within last 30 days
|
|
66
|
+
minDate = new Date(new Date().setDate(new Date().getDate() - 30));
|
|
67
|
+
maxDate = new Date();
|
|
68
|
+
|
|
69
|
+
onDateSelected(date: any) {
|
|
70
|
+
console.log('Selected:', date);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## All Implemented Features
|
|
76
|
+
|
|
77
|
+
✅ **24+ Input Properties**
|
|
78
|
+
- Mode switching (Gregorian/Hijri)
|
|
79
|
+
- Localization (English/Arabic)
|
|
80
|
+
- RTL/LTR support
|
|
81
|
+
- Single/multiple selection
|
|
82
|
+
- Future date validation
|
|
83
|
+
- **Min/Max date constraints (NEW)**
|
|
84
|
+
- Custom labels (5 inputs)
|
|
85
|
+
- Display toggles (5 inputs)
|
|
86
|
+
- Custom styling (13 CSS properties)
|
|
87
|
+
- Time picker support (5 inputs)
|
|
88
|
+
|
|
89
|
+
✅ **2 Output Events**
|
|
90
|
+
- dateSelected
|
|
91
|
+
- modeChanged
|
|
92
|
+
|
|
93
|
+
✅ **Complete Localization**
|
|
94
|
+
- English/Arabic month names
|
|
95
|
+
- Gregorian/Hijri calendar systems
|
|
96
|
+
- RTL layout for Arabic
|
|
97
|
+
|
|
98
|
+
✅ **Professional UI**
|
|
99
|
+
- Responsive design
|
|
100
|
+
- Smooth animations
|
|
101
|
+
- Hover effects
|
|
102
|
+
- Disabled states
|
|
103
|
+
- Today highlighting
|
|
104
|
+
- Custom theming
|
|
105
|
+
|
|
106
|
+
## Project Location
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
C:\Users\Hany\.gemini\antigravity\scratch\hijri-date-picker\
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Next Steps
|
|
113
|
+
|
|
114
|
+
1. Install dependencies: `npm install`
|
|
115
|
+
2. Build: `npm run build`
|
|
116
|
+
3. Publish to NPM: `npm publish`
|
|
117
|
+
4. Or use locally in your Angular project
|
|
118
|
+
|
|
119
|
+
## Support
|
|
120
|
+
|
|
121
|
+
See [README.md](file:///C:/Users/Hany/.gemini/antigravity/scratch/hijri-date-picker/README.md) for complete API documentation and examples.
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# Initial Date Binding - Usage Guide
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
The Hijri Date Picker now supports binding initial/pre-selected dates through input properties. This allows you to programmatically set which date(s) should be selected when the calendar loads.
|
|
6
|
+
|
|
7
|
+
## Single Selection Mode
|
|
8
|
+
|
|
9
|
+
Use the `initialSelectedDate` input to bind a single date:
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { Component } from '@angular/core';
|
|
13
|
+
|
|
14
|
+
@Component({
|
|
15
|
+
selector: 'app-example',
|
|
16
|
+
template: `
|
|
17
|
+
<hijri-date-picker
|
|
18
|
+
[initialSelectedDate]="myDate"
|
|
19
|
+
(dateSelected)="onDateSelected($event)">
|
|
20
|
+
</hijri-date-picker>
|
|
21
|
+
`
|
|
22
|
+
})
|
|
23
|
+
export class ExampleComponent {
|
|
24
|
+
// Set initial date to today
|
|
25
|
+
myDate = new Date();
|
|
26
|
+
|
|
27
|
+
// Or set to a specific date
|
|
28
|
+
// myDate = new Date(2024, 11, 24); // December 24, 2024
|
|
29
|
+
|
|
30
|
+
onDateSelected(date: SelectedDate) {
|
|
31
|
+
console.log('Selected:', date);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Multiple Selection Mode
|
|
37
|
+
|
|
38
|
+
Use the `initialSelectedDates` input to bind multiple dates:
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
import { Component } from '@angular/core';
|
|
42
|
+
|
|
43
|
+
@Component({
|
|
44
|
+
selector: 'app-example',
|
|
45
|
+
template: `
|
|
46
|
+
<hijri-date-picker
|
|
47
|
+
[multiple]="true"
|
|
48
|
+
[initialSelectedDates]="myDates"
|
|
49
|
+
[showConfirmButton]="true"
|
|
50
|
+
(dateSelected)="onDatesSelected($event)">
|
|
51
|
+
</hijri-date-picker>
|
|
52
|
+
`
|
|
53
|
+
})
|
|
54
|
+
export class ExampleComponent {
|
|
55
|
+
// Pre-select multiple dates
|
|
56
|
+
myDates = [
|
|
57
|
+
new Date(2024, 11, 24), // December 24, 2024
|
|
58
|
+
new Date(2024, 11, 25), // December 25, 2024
|
|
59
|
+
new Date(2024, 11, 31) // December 31, 2024
|
|
60
|
+
];
|
|
61
|
+
|
|
62
|
+
onDatesSelected(dates: SelectedDate[]) {
|
|
63
|
+
console.log('Selected dates:', dates);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Dynamic Updates
|
|
69
|
+
|
|
70
|
+
The component automatically updates when the input values change:
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
import { Component } from '@angular/core';
|
|
74
|
+
|
|
75
|
+
@Component({
|
|
76
|
+
selector: 'app-example',
|
|
77
|
+
template: `
|
|
78
|
+
<button (click)="setToday()">Set to Today</button>
|
|
79
|
+
<button (click)="setCustomDate()">Set Custom Date</button>
|
|
80
|
+
|
|
81
|
+
<hijri-date-picker
|
|
82
|
+
[initialSelectedDate]="selectedDate"
|
|
83
|
+
(dateSelected)="onDateSelected($event)">
|
|
84
|
+
</hijri-date-picker>
|
|
85
|
+
`
|
|
86
|
+
})
|
|
87
|
+
export class ExampleComponent {
|
|
88
|
+
selectedDate = new Date();
|
|
89
|
+
|
|
90
|
+
setToday() {
|
|
91
|
+
this.selectedDate = new Date();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
setCustomDate() {
|
|
95
|
+
this.selectedDate = new Date(2024, 0, 1); // January 1, 2024
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
onDateSelected(date: SelectedDate) {
|
|
99
|
+
console.log('Selected:', date);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Hijri Mode Example
|
|
105
|
+
|
|
106
|
+
Works seamlessly with Hijri calendar mode:
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
@Component({
|
|
110
|
+
selector: 'app-hijri-example',
|
|
111
|
+
template: `
|
|
112
|
+
<hijri-date-picker
|
|
113
|
+
[mode]="'hijri'"
|
|
114
|
+
[locale]="'ar'"
|
|
115
|
+
[dir]="'rtl'"
|
|
116
|
+
[initialSelectedDate]="myDate"
|
|
117
|
+
(dateSelected)="onDateSelected($event)">
|
|
118
|
+
</hijri-date-picker>
|
|
119
|
+
`
|
|
120
|
+
})
|
|
121
|
+
export class HijriExampleComponent {
|
|
122
|
+
myDate = new Date(); // Gregorian date - will be converted to Hijri
|
|
123
|
+
|
|
124
|
+
onDateSelected(date: SelectedDate) {
|
|
125
|
+
console.log('Gregorian:', date.gregorian);
|
|
126
|
+
console.log('Hijri:', date.hijri);
|
|
127
|
+
console.log('Formatted Hijri:', date.formatted.hijri);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Key Points
|
|
133
|
+
|
|
134
|
+
- **Single mode**: Use `initialSelectedDate` (singular) with a single `Date` object
|
|
135
|
+
- **Multiple mode**: Use `initialSelectedDates` (plural) with an array of `Date` objects
|
|
136
|
+
- **Automatic conversion**: Gregorian dates are automatically converted to Hijri when in Hijri mode
|
|
137
|
+
- **Reactive**: Changes to the input properties automatically update the calendar
|
|
138
|
+
- **Type-safe**: Full TypeScript support with proper type definitions
|
|
139
|
+
|
|
140
|
+
## Complete Example
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
import { Component } from '@angular/core';
|
|
144
|
+
import { HijriDatePickerComponent, SelectedDate } from 'hijri-date-picker';
|
|
145
|
+
|
|
146
|
+
@Component({
|
|
147
|
+
selector: 'app-date-picker-demo',
|
|
148
|
+
standalone: true,
|
|
149
|
+
imports: [HijriDatePickerComponent],
|
|
150
|
+
template: `
|
|
151
|
+
<div class="demo">
|
|
152
|
+
<h2>Pre-selected Date Example</h2>
|
|
153
|
+
|
|
154
|
+
<hijri-date-picker
|
|
155
|
+
[mode]="'greg'"
|
|
156
|
+
[locale]="'en'"
|
|
157
|
+
[initialSelectedDate]="preselectedDate"
|
|
158
|
+
[canChangeMode]="true"
|
|
159
|
+
(dateSelected)="handleDateSelection($event)">
|
|
160
|
+
</hijri-date-picker>
|
|
161
|
+
|
|
162
|
+
<div *ngIf="result">
|
|
163
|
+
<h3>Selected Date:</h3>
|
|
164
|
+
<p>Gregorian: {{ result.formatted.gregorian }}</p>
|
|
165
|
+
<p>Hijri: {{ result.formatted.hijri }}</p>
|
|
166
|
+
</div>
|
|
167
|
+
</div>
|
|
168
|
+
`
|
|
169
|
+
})
|
|
170
|
+
export class DatePickerDemoComponent {
|
|
171
|
+
// Pre-select tomorrow's date
|
|
172
|
+
preselectedDate = new Date();
|
|
173
|
+
result?: SelectedDate;
|
|
174
|
+
|
|
175
|
+
constructor() {
|
|
176
|
+
this.preselectedDate.setDate(this.preselectedDate.getDate() + 1);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
handleDateSelection(date: SelectedDate) {
|
|
180
|
+
this.result = date;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
```
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
# Min/Max Date Feature Guide
|
|
2
|
+
|
|
3
|
+
This guide demonstrates how to use the `minDate` and `maxDate` features in the Hijri Date Time Picker component to restrict date selection within specific ranges.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The `minDate` and `maxDate` inputs allow you to define the earliest and latest dates that users can select. Dates outside this range will be disabled and cannot be selected.
|
|
8
|
+
|
|
9
|
+
## Basic Usage
|
|
10
|
+
|
|
11
|
+
### Setting a Minimum Date
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { Component } from '@angular/core';
|
|
15
|
+
import { HijriDatePickerComponent } from 'hijri-date-time-picker';
|
|
16
|
+
|
|
17
|
+
@Component({
|
|
18
|
+
selector: 'app-example',
|
|
19
|
+
standalone: true,
|
|
20
|
+
imports: [HijriDatePickerComponent],
|
|
21
|
+
template: `
|
|
22
|
+
<hijri-date-picker
|
|
23
|
+
[minDate]="minDate"
|
|
24
|
+
(dateSelected)="onDateSelected($event)">
|
|
25
|
+
</hijri-date-picker>
|
|
26
|
+
`
|
|
27
|
+
})
|
|
28
|
+
export class ExampleComponent {
|
|
29
|
+
// Only allow dates from today onwards
|
|
30
|
+
minDate = new Date();
|
|
31
|
+
|
|
32
|
+
onDateSelected(date: any) {
|
|
33
|
+
console.log('Selected:', date);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Setting a Maximum Date
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
@Component({
|
|
42
|
+
template: `
|
|
43
|
+
<hijri-date-picker
|
|
44
|
+
[maxDate]="maxDate"
|
|
45
|
+
(dateSelected)="onDateSelected($event)">
|
|
46
|
+
</hijri-date-picker>
|
|
47
|
+
`
|
|
48
|
+
})
|
|
49
|
+
export class ExampleComponent {
|
|
50
|
+
// Only allow dates up to today
|
|
51
|
+
maxDate = new Date();
|
|
52
|
+
|
|
53
|
+
onDateSelected(date: any) {
|
|
54
|
+
console.log('Selected:', date);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Combining Min and Max Dates
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
@Component({
|
|
63
|
+
template: `
|
|
64
|
+
<hijri-date-picker
|
|
65
|
+
[minDate]="minDate"
|
|
66
|
+
[maxDate]="maxDate"
|
|
67
|
+
[futureValidation]="false"
|
|
68
|
+
(dateSelected)="onDateSelected($event)">
|
|
69
|
+
</hijri-date-picker>
|
|
70
|
+
`
|
|
71
|
+
})
|
|
72
|
+
export class ExampleComponent {
|
|
73
|
+
// Allow only dates within the last 30 days
|
|
74
|
+
minDate = new Date(new Date().setDate(new Date().getDate() - 30));
|
|
75
|
+
maxDate = new Date();
|
|
76
|
+
|
|
77
|
+
onDateSelected(date: any) {
|
|
78
|
+
console.log('Selected:', date);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Common Use Cases
|
|
84
|
+
|
|
85
|
+
### 1. Booking System (Future Dates Only)
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
export class BookingComponent {
|
|
89
|
+
// Start from today
|
|
90
|
+
minDate = new Date();
|
|
91
|
+
|
|
92
|
+
// Allow bookings up to 90 days in advance
|
|
93
|
+
maxDate = new Date(new Date().setDate(new Date().getDate() + 90));
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### 2. Historical Data Entry (Past Dates Only)
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
export class HistoricalDataComponent {
|
|
101
|
+
// Allow dates from January 1, 2000
|
|
102
|
+
minDate = new Date('2000-01-01');
|
|
103
|
+
|
|
104
|
+
// Up to yesterday
|
|
105
|
+
maxDate = new Date(new Date().setDate(new Date().getDate() - 1));
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### 3. Event Registration (Specific Date Range)
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
export class EventRegistrationComponent {
|
|
113
|
+
// Registration opens on a specific date
|
|
114
|
+
minDate = new Date('2024-01-15');
|
|
115
|
+
|
|
116
|
+
// Registration closes on event date
|
|
117
|
+
maxDate = new Date('2024-03-30');
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### 4. Age Verification (Date of Birth)
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
export class AgeVerificationComponent {
|
|
125
|
+
// Must be at least 18 years old
|
|
126
|
+
maxDate = new Date(
|
|
127
|
+
new Date().setFullYear(new Date().getFullYear() - 18)
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
// Maximum age of 100 years
|
|
131
|
+
minDate = new Date(
|
|
132
|
+
new Date().setFullYear(new Date().getFullYear() - 100)
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### 5. Dynamic Date Range
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
export class DynamicRangeComponent {
|
|
141
|
+
minDate: Date;
|
|
142
|
+
maxDate: Date;
|
|
143
|
+
|
|
144
|
+
constructor() {
|
|
145
|
+
this.updateDateRange('last30days');
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
updateDateRange(range: string) {
|
|
149
|
+
const today = new Date();
|
|
150
|
+
|
|
151
|
+
switch(range) {
|
|
152
|
+
case 'last7days':
|
|
153
|
+
this.minDate = new Date(today.setDate(today.getDate() - 7));
|
|
154
|
+
this.maxDate = new Date();
|
|
155
|
+
break;
|
|
156
|
+
|
|
157
|
+
case 'last30days':
|
|
158
|
+
this.minDate = new Date(today.setDate(today.getDate() - 30));
|
|
159
|
+
this.maxDate = new Date();
|
|
160
|
+
break;
|
|
161
|
+
|
|
162
|
+
case 'next30days':
|
|
163
|
+
this.minDate = new Date();
|
|
164
|
+
this.maxDate = new Date(today.setDate(today.getDate() + 30));
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Working with Hijri Calendar
|
|
172
|
+
|
|
173
|
+
The `minDate` and `maxDate` work seamlessly with both Gregorian and Hijri calendars. The component automatically converts the dates to the appropriate calendar system.
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
@Component({
|
|
177
|
+
template: `
|
|
178
|
+
<hijri-date-picker
|
|
179
|
+
[mode]="'hijri'"
|
|
180
|
+
[minDate]="minDate"
|
|
181
|
+
[maxDate]="maxDate"
|
|
182
|
+
[locale]="'ar'"
|
|
183
|
+
[dir]="'rtl'"
|
|
184
|
+
(dateSelected)="onDateSelected($event)">
|
|
185
|
+
</hijri-date-picker>
|
|
186
|
+
`
|
|
187
|
+
})
|
|
188
|
+
export class HijriRangeComponent {
|
|
189
|
+
// The dates are in Gregorian, but will be converted to Hijri
|
|
190
|
+
minDate = new Date('2024-01-01');
|
|
191
|
+
maxDate = new Date('2024-12-31');
|
|
192
|
+
|
|
193
|
+
onDateSelected(date: any) {
|
|
194
|
+
// date object contains both Gregorian and Hijri representations
|
|
195
|
+
console.log('Gregorian:', date.gregorian);
|
|
196
|
+
console.log('Hijri:', date.hijri);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Disabling Future Validation
|
|
202
|
+
|
|
203
|
+
When using `minDate` and `maxDate`, you may want to disable the default `futureValidation` feature:
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
@Component({
|
|
207
|
+
template: `
|
|
208
|
+
<hijri-date-picker
|
|
209
|
+
[minDate]="minDate"
|
|
210
|
+
[maxDate]="maxDate"
|
|
211
|
+
[futureValidation]="false"
|
|
212
|
+
(dateSelected)="onDateSelected($event)">
|
|
213
|
+
</hijri-date-picker>
|
|
214
|
+
`
|
|
215
|
+
})
|
|
216
|
+
export class CustomRangeComponent {
|
|
217
|
+
minDate = new Date('2024-01-01');
|
|
218
|
+
maxDate = new Date('2025-12-31');
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## Year and Month Picker Behavior
|
|
223
|
+
|
|
224
|
+
When `minDate` and `maxDate` are set:
|
|
225
|
+
|
|
226
|
+
- The **year dropdown** will only show years within the valid range
|
|
227
|
+
- The **month navigation** remains functional, but disabled dates will be shown as disabled
|
|
228
|
+
- Users cannot select disabled dates even if they navigate to those months
|
|
229
|
+
|
|
230
|
+
## Tips and Best Practices
|
|
231
|
+
|
|
232
|
+
1. **Always set both min and max**: For the best user experience, set both `minDate` and `maxDate` to clearly define the valid range.
|
|
233
|
+
|
|
234
|
+
2. **Disable futureValidation**: When using custom date ranges, set `[futureValidation]="false"` to avoid conflicts.
|
|
235
|
+
|
|
236
|
+
3. **Provide feedback**: Consider showing the valid date range in your UI:
|
|
237
|
+
```html
|
|
238
|
+
<p>Please select a date between {{ minDate | date }} and {{ maxDate | date }}</p>
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
4. **Dynamic ranges**: Update `minDate` and `maxDate` dynamically based on user input or business logic.
|
|
242
|
+
|
|
243
|
+
5. **Time considerations**: The date comparison ignores the time component, so:
|
|
244
|
+
```typescript
|
|
245
|
+
minDate = new Date(); // Today at current time
|
|
246
|
+
// Will allow selection of today's date, regardless of current time
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
## Combining with Other Features
|
|
250
|
+
|
|
251
|
+
### With Multiple Selection
|
|
252
|
+
|
|
253
|
+
```typescript
|
|
254
|
+
@Component({
|
|
255
|
+
template: `
|
|
256
|
+
<hijri-date-picker
|
|
257
|
+
[multiple]="true"
|
|
258
|
+
[minDate]="minDate"
|
|
259
|
+
[maxDate]="maxDate"
|
|
260
|
+
[showConfirmButton]="true"
|
|
261
|
+
(dateSelected)="onDatesSelected($event)">
|
|
262
|
+
</hijri-date-picker>
|
|
263
|
+
`
|
|
264
|
+
})
|
|
265
|
+
export class MultipleWithRangeComponent {
|
|
266
|
+
minDate = new Date(new Date().setDate(new Date().getDate() - 7));
|
|
267
|
+
maxDate = new Date();
|
|
268
|
+
|
|
269
|
+
onDatesSelected(dates: any[]) {
|
|
270
|
+
console.log('Selected dates:', dates);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### With Time Selection
|
|
276
|
+
|
|
277
|
+
```typescript
|
|
278
|
+
@Component({
|
|
279
|
+
template: `
|
|
280
|
+
<hijri-date-picker
|
|
281
|
+
[enableTime]="true"
|
|
282
|
+
[minDate]="minDate"
|
|
283
|
+
[maxDate]="maxDate"
|
|
284
|
+
[futureValidation]="false"
|
|
285
|
+
(dateSelected)="onDateTimeSelected($event)">
|
|
286
|
+
</hijri-date-picker>
|
|
287
|
+
`
|
|
288
|
+
})
|
|
289
|
+
export class DateTimeWithRangeComponent {
|
|
290
|
+
minDate = new Date();
|
|
291
|
+
maxDate = new Date(new Date().setDate(new Date().getDate() + 30));
|
|
292
|
+
|
|
293
|
+
onDateTimeSelected(dateTime: any) {
|
|
294
|
+
console.log('Selected date and time:', dateTime);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
## API Reference
|
|
300
|
+
|
|
301
|
+
| Property | Type | Default | Description |
|
|
302
|
+
|----------|------|---------|-------------|
|
|
303
|
+
| `minDate` | `Date \| undefined` | `undefined` | Minimum selectable date. Dates before this will be disabled. |
|
|
304
|
+
| `maxDate` | `Date \| undefined` | `undefined` | Maximum selectable date. Dates after this will be disabled. |
|
|
305
|
+
|
|
306
|
+
## Browser Compatibility
|
|
307
|
+
|
|
308
|
+
The minDate/maxDate feature works in all modern browsers that support the Date object and Angular framework.
|
|
309
|
+
|
|
310
|
+
## Troubleshooting
|
|
311
|
+
|
|
312
|
+
### Dates not being disabled
|
|
313
|
+
|
|
314
|
+
- Verify that `minDate` and `maxDate` are valid Date objects
|
|
315
|
+
- Check that `futureValidation` is set to `false` if you're using custom ranges
|
|
316
|
+
- Ensure dates are in the correct format
|
|
317
|
+
|
|
318
|
+
### Year dropdown showing wrong years
|
|
319
|
+
|
|
320
|
+
- The year dropdown automatically adjusts based on `minDate` and `maxDate`
|
|
321
|
+
- If you see unexpected years, check your date values
|
|
322
|
+
|
|
323
|
+
### Timezone issues
|
|
324
|
+
|
|
325
|
+
- The component uses local timezone for all date comparisons
|
|
326
|
+
- Be aware of timezone differences when setting dates programmatically
|
package/ng-package.json
ADDED
package/package.json
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hijri-date-time-picker",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.31",
|
|
4
4
|
"description": "Angular standalone component for dual-mode Gregorian and Hijri date selection",
|
|
5
|
-
"
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"files": [
|
|
8
|
-
"dist",
|
|
9
|
-
"README.md",
|
|
10
|
-
"LICENSE"
|
|
11
|
-
],
|
|
5
|
+
"sideEffects": false,
|
|
12
6
|
"scripts": {
|
|
13
7
|
"build": "ng-packagr -p ng-package.json",
|
|
14
8
|
"build:watch": "ng-packagr -p ng-package.json --watch",
|