ng-mo-date-picker 1.0.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/README.ar.md +350 -0
- package/README.md +302 -0
- package/fesm2022/ng-mo-date-picker.mjs +451 -0
- package/fesm2022/ng-mo-date-picker.mjs.map +1 -0
- package/ng-mo-date-picker-1.0.0.tgz +0 -0
- package/package.json +46 -0
- package/types/ng-mo-date-picker.d.ts +150 -0
package/README.ar.md
ADDED
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
# ng-mo-date-picker
|
|
2
|
+
|
|
3
|
+
<div dir="rtl" align="center">
|
|
4
|
+
|
|
5
|
+
[](./README.md)
|
|
6
|
+
[](./README.ar.md)
|
|
7
|
+
|
|
8
|
+
🗓️ **مكتبة Angular لاختيار التاريخ الهجري والميلادي مع دعم كامل للعربية والإنجليزية**
|
|
9
|
+
|
|
10
|
+
[](https://www.npmjs.com/package/ng-mo-date-picker)
|
|
11
|
+
[](https://opensource.org/licenses/MIT)
|
|
12
|
+
|
|
13
|
+
[🎮 معاينة مباشرة](https://3mowafy.github.io/ng-mo-date-picker/) • [📖 التوثيق](#-المدخلات-والمخرجات) • [💡 الأمثلة](#-أمثلة-الاستخدام)
|
|
14
|
+
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## ✨ المميزات
|
|
20
|
+
|
|
21
|
+
- ✅ **نظامان للتقويم**: دعم كامل للتقويم الهجري (الإسلامي) والميلادي
|
|
22
|
+
- ✅ **ثنائي اللغة**: واجهة عربية وإنجليزية بالكامل
|
|
23
|
+
- ✅ **دعم الاتجاه التلقائي**: تبديل تلقائي بين RTL و LTR
|
|
24
|
+
- ✅ **متوافق مع النماذج**: يعمل مع Reactive Forms و Template-driven Forms و Signal Forms
|
|
25
|
+
- ✅ **خفيف وسريع**: حجم صغير (~50KB) مع الاعتماديات
|
|
26
|
+
- ✅ **مكون مستقل**: لا يحتاج استيراد modules (Angular 21+)
|
|
27
|
+
- ✅ **قابل للتخصيص**: تخصيص كامل للأيقونات والألوان والأنماط
|
|
28
|
+
- ✅ **مكتوب بـ TypeScript**: دعم كامل لـ IntelliSense
|
|
29
|
+
- ✅ **إخراج شامل**: الحصول على التاريخ الميلادي والهجري معاً مع التنسيق الكامل
|
|
30
|
+
|
|
31
|
+
## 📦 التثبيت
|
|
32
|
+
```bash
|
|
33
|
+
npm install ng-mo-date-picker
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**ملاحظة**: سيتم تثبيت `moment-hijri` تلقائياً كاعتمادية.
|
|
37
|
+
|
|
38
|
+
## 🚀 البدء السريع
|
|
39
|
+
|
|
40
|
+
### الخطوة الأولى: استيراد المكون
|
|
41
|
+
|
|
42
|
+
**Angular 21 Standalone:**
|
|
43
|
+
```typescript
|
|
44
|
+
import { Component } from '@angular/core';
|
|
45
|
+
import { NgMoDatePicker, DatePickerOutput } from 'ng-mo-date-picker';
|
|
46
|
+
|
|
47
|
+
@Component({
|
|
48
|
+
selector: 'app-root',
|
|
49
|
+
imports: [NgMoDatePicker],
|
|
50
|
+
template: `
|
|
51
|
+
<ng-mo-date-picker
|
|
52
|
+
[locale]="'ar'"
|
|
53
|
+
(dateChange)="onDateChange($event)"
|
|
54
|
+
/>
|
|
55
|
+
`
|
|
56
|
+
})
|
|
57
|
+
export class AppComponent {
|
|
58
|
+
onDateChange(output: DatePickerOutput | null) {
|
|
59
|
+
if (output) {
|
|
60
|
+
console.log('التاريخ الميلادي:', output.gregorianFormatted);
|
|
61
|
+
console.log('التاريخ الهجري:', output.hijriFormatted);
|
|
62
|
+
console.log('اسم الشهر:', output.hijriDate.monthName);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## 📚 أمثلة الاستخدام
|
|
69
|
+
|
|
70
|
+
### مثال أساسي (عربي)
|
|
71
|
+
```html
|
|
72
|
+
<ng-mo-date-picker [locale]="'ar'" />
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### إنجليزي مع نص توضيحي مخصص
|
|
76
|
+
```html
|
|
77
|
+
<ng-mo-date-picker
|
|
78
|
+
[locale]="'en'"
|
|
79
|
+
[placeholder]="'اختر تاريخاً'"
|
|
80
|
+
/>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### البدء بالتقويم الهجري
|
|
84
|
+
```html
|
|
85
|
+
<ng-mo-date-picker
|
|
86
|
+
[calendarType]="'hijri'"
|
|
87
|
+
[locale]="'ar'"
|
|
88
|
+
/>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### تخصيص الأيقونة
|
|
92
|
+
```html
|
|
93
|
+
<!-- أيقونة مخصصة -->
|
|
94
|
+
<ng-mo-date-picker
|
|
95
|
+
[customIcon]="'🗓️'"
|
|
96
|
+
/>
|
|
97
|
+
|
|
98
|
+
<!-- إخفاء الأيقونة -->
|
|
99
|
+
<ng-mo-date-picker
|
|
100
|
+
[showIcon]="false"
|
|
101
|
+
/>
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### الاستخدام مع Reactive Forms
|
|
105
|
+
```typescript
|
|
106
|
+
import { Component } from '@angular/core';
|
|
107
|
+
import { FormControl, ReactiveFormsModule } from '@angular/forms';
|
|
108
|
+
import { NgMoDatePicker } from 'ng-mo-date-picker';
|
|
109
|
+
|
|
110
|
+
@Component({
|
|
111
|
+
imports: [NgMoDatePicker, ReactiveFormsModule],
|
|
112
|
+
template: `
|
|
113
|
+
<ng-mo-date-picker [formControl]="dateControl" />
|
|
114
|
+
<p>التاريخ المختار: {{ dateControl.value | date }}</p>
|
|
115
|
+
`
|
|
116
|
+
})
|
|
117
|
+
export class MyComponent {
|
|
118
|
+
dateControl = new FormControl<Date | null>(null);
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### الاستخدام مع Template-driven Forms
|
|
123
|
+
```typescript
|
|
124
|
+
import { Component } from '@angular/core';
|
|
125
|
+
import { FormsModule } from '@angular/forms';
|
|
126
|
+
import { NgMoDatePicker } from 'ng-mo-date-picker';
|
|
127
|
+
|
|
128
|
+
@Component({
|
|
129
|
+
imports: [NgMoDatePicker, FormsModule],
|
|
130
|
+
template: `
|
|
131
|
+
<ng-mo-date-picker
|
|
132
|
+
[(ngModel)]="selectedDate"
|
|
133
|
+
[locale]="'ar'"
|
|
134
|
+
/>
|
|
135
|
+
`
|
|
136
|
+
})
|
|
137
|
+
export class MyComponent {
|
|
138
|
+
selectedDate: Date | null = null;
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### تخصيص الأنماط
|
|
143
|
+
```html
|
|
144
|
+
<ng-mo-date-picker
|
|
145
|
+
[inputClass]="'my-input'"
|
|
146
|
+
[calendarClass]="'my-calendar'"
|
|
147
|
+
/>
|
|
148
|
+
```
|
|
149
|
+
```css
|
|
150
|
+
.my-input {
|
|
151
|
+
border: 2px solid #3b82f6;
|
|
152
|
+
border-radius: 12px;
|
|
153
|
+
padding: 12px;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.my-calendar {
|
|
157
|
+
box-shadow: 0 20px 40px rgba(0,0,0,0.15);
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## 🎛️ المدخلات والمخرجات
|
|
162
|
+
|
|
163
|
+
### المدخلات (Inputs)
|
|
164
|
+
|
|
165
|
+
| الاسم | النوع | القيمة الافتراضية | الوصف |
|
|
166
|
+
|------|------|---------|-------------|
|
|
167
|
+
| `calendarType` | `'gregorian' \| 'hijri'` | `'gregorian'` | نوع التقويم عند الفتح |
|
|
168
|
+
| `locale` | `'ar' \| 'en'` | `'ar'` | اللغة واتجاه النص |
|
|
169
|
+
| `showIcon` | `boolean` | `true` | إظهار أو إخفاء أيقونة التقويم |
|
|
170
|
+
| `customIcon` | `string` | `'📅'` | أيقونة مخصصة (emoji أو نص) |
|
|
171
|
+
| `inputClass` | `string` | `''` | CSS classes إضافية لحقل الإدخال |
|
|
172
|
+
| `calendarClass` | `string` | `''` | CSS classes إضافية للتقويم المنبثق |
|
|
173
|
+
| `disabled` | `boolean` | `false` | تعطيل المكون |
|
|
174
|
+
| `readonly` | `boolean` | `false` | جعل الحقل للقراءة فقط |
|
|
175
|
+
| `placeholder` | `string` | تلقائي حسب اللغة | النص التوضيحي |
|
|
176
|
+
| `name` | `string` | `undefined` | اسم الحقل (name attribute) |
|
|
177
|
+
| `id` | `string` | `undefined` | معرّف الحقل (id attribute) |
|
|
178
|
+
|
|
179
|
+
### المخرجات (Outputs)
|
|
180
|
+
|
|
181
|
+
| الاسم | النوع | الوصف |
|
|
182
|
+
|------|------|-------------|
|
|
183
|
+
| `dateChange` | `DatePickerOutput \| null` | يُطلق عند اختيار أو مسح التاريخ |
|
|
184
|
+
| `calendarToggle` | `boolean` | يُطلق عند فتح أو إغلاق التقويم |
|
|
185
|
+
|
|
186
|
+
### واجهة DatePickerOutput
|
|
187
|
+
```typescript
|
|
188
|
+
interface DatePickerOutput {
|
|
189
|
+
// بيانات التاريخ الميلادي
|
|
190
|
+
gregorianDate: Date; // كائن Date الأصلي
|
|
191
|
+
gregorianFormatted: string; // "07/01/2026"
|
|
192
|
+
|
|
193
|
+
// بيانات التاريخ الهجري
|
|
194
|
+
hijriDate: {
|
|
195
|
+
year: number; // 1446
|
|
196
|
+
month: number; // 7
|
|
197
|
+
monthName: string; // "رجب" أو "Rajab"
|
|
198
|
+
day: number; // 18
|
|
199
|
+
};
|
|
200
|
+
hijriFormatted: string; // "18 رجب 1446 هـ"
|
|
201
|
+
|
|
202
|
+
// معلومات إضافية
|
|
203
|
+
calendarType: 'gregorian' | 'hijri';
|
|
204
|
+
locale: 'ar' | 'en';
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## 🎨 التخصيص المتقدم
|
|
209
|
+
|
|
210
|
+
### استخدام CSS Variables (قريباً في v2.0)
|
|
211
|
+
```css
|
|
212
|
+
.mo-calendar {
|
|
213
|
+
--primary-color: #10b981;
|
|
214
|
+
--hover-color: #059669;
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### تجاوز الأنماط الافتراضية
|
|
219
|
+
```css
|
|
220
|
+
/* تخصيص اليوم المحدد */
|
|
221
|
+
.mo-day.selected {
|
|
222
|
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
223
|
+
color: white;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/* تخصيص زر التنقل */
|
|
227
|
+
.mo-nav-btn:hover {
|
|
228
|
+
color: #10b981;
|
|
229
|
+
transform: scale(1.1);
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
## 🌍 دعم اللغات (i18n)
|
|
234
|
+
|
|
235
|
+
المكون يتعامل تلقائياً مع:
|
|
236
|
+
- أسماء الأشهر (الميلادية والهجرية)
|
|
237
|
+
- أسماء الأيام
|
|
238
|
+
- نصوص الواجهة (اليوم، مسح، إلخ)
|
|
239
|
+
- اتجاه النص (RTL/LTR)
|
|
240
|
+
|
|
241
|
+
### التبديل بين اللغات
|
|
242
|
+
```typescript
|
|
243
|
+
@Component({
|
|
244
|
+
template: `
|
|
245
|
+
<ng-mo-date-picker [locale]="currentLang" />
|
|
246
|
+
|
|
247
|
+
<button (click)="toggleLang()">
|
|
248
|
+
تبديل اللغة
|
|
249
|
+
</button>
|
|
250
|
+
`
|
|
251
|
+
})
|
|
252
|
+
export class MyComponent {
|
|
253
|
+
currentLang: 'ar' | 'en' = 'ar';
|
|
254
|
+
|
|
255
|
+
toggleLang() {
|
|
256
|
+
this.currentLang = this.currentLang === 'ar' ? 'en' : 'ar';
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
## 🔧 استخدامات متقدمة
|
|
262
|
+
|
|
263
|
+
### الاستماع لفتح وإغلاق التقويم
|
|
264
|
+
```typescript
|
|
265
|
+
@Component({
|
|
266
|
+
template: `
|
|
267
|
+
<ng-mo-date-picker
|
|
268
|
+
(calendarToggle)="onCalendarToggle($event)"
|
|
269
|
+
/>
|
|
270
|
+
`
|
|
271
|
+
})
|
|
272
|
+
export class MyComponent {
|
|
273
|
+
onCalendarToggle(isOpen: boolean) {
|
|
274
|
+
console.log('التقويم الآن:', isOpen ? 'مفتوح' : 'مغلق');
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### الوصول للبيانات الكاملة
|
|
280
|
+
```typescript
|
|
281
|
+
onDateChange(output: DatePickerOutput | null) {
|
|
282
|
+
if (!output) {
|
|
283
|
+
console.log('تم مسح التاريخ');
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// استخدام التاريخ الميلادي
|
|
288
|
+
const jsDate = output.gregorianDate;
|
|
289
|
+
console.log('التاريخ الميلادي:', output.gregorianFormatted);
|
|
290
|
+
|
|
291
|
+
// استخدام التاريخ الهجري
|
|
292
|
+
console.log('السنة الهجرية:', output.hijriDate.year);
|
|
293
|
+
console.log('الشهر الهجري:', output.hijriDate.monthName);
|
|
294
|
+
console.log('منسق:', output.hijriFormatted);
|
|
295
|
+
|
|
296
|
+
// معرفة نوع التقويم المستخدم
|
|
297
|
+
console.log('التقويم المستخدم:', output.calendarType);
|
|
298
|
+
}
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
## 📱 دعم المتصفحات
|
|
302
|
+
|
|
303
|
+
- Chrome (آخر إصدار)
|
|
304
|
+
- Firefox (آخر إصدار)
|
|
305
|
+
- Safari (آخر إصدار)
|
|
306
|
+
- Edge (آخر إصدار)
|
|
307
|
+
|
|
308
|
+
## 🤝 المساهمة
|
|
309
|
+
|
|
310
|
+
المساهمات مرحب بها دائماً! لا تتردد في:
|
|
311
|
+
|
|
312
|
+
1. عمل Fork للمشروع
|
|
313
|
+
2. إنشاء branch للميزة الجديدة (`git checkout -b feature/AmazingFeature`)
|
|
314
|
+
3. Commit التغييرات (`git commit -m 'إضافة ميزة رائعة'`)
|
|
315
|
+
4. Push للـ branch (`git push origin feature/AmazingFeature`)
|
|
316
|
+
5. فتح Pull Request
|
|
317
|
+
|
|
318
|
+
## 🐛 الإبلاغ عن المشاكل
|
|
319
|
+
|
|
320
|
+
وجدت خطأ أو لديك اقتراح لميزة جديدة؟
|
|
321
|
+
👉 [افتح issue على GitHub](https://github.com/3Mowafy/ng-mo-date-picker/issues)
|
|
322
|
+
|
|
323
|
+
## 📄 الترخيص
|
|
324
|
+
|
|
325
|
+
MIT © [Mohamed Mowafy](https://github.com/3Mowafy)
|
|
326
|
+
|
|
327
|
+
## 🔗 روابط مفيدة
|
|
328
|
+
|
|
329
|
+
- [📦 الحزمة على npm](https://www.npmjs.com/package/ng-mo-date-picker)
|
|
330
|
+
- [💻 المستودع على GitHub](https://github.com/3Mowafy/ng-mo-date-picker)
|
|
331
|
+
- [🎮 معاينة مباشرة](https://3mowafy.github.io/ng-mo-date-picker/)
|
|
332
|
+
- [🐛 الإبلاغ عن مشكلة](https://github.com/3Mowafy/ng-mo-date-picker/issues)
|
|
333
|
+
- [📖 التوثيق الكامل](https://github.com/3Mowafy/ng-mo-date-picker#readme)
|
|
334
|
+
|
|
335
|
+
## 🙏 شكر وتقدير
|
|
336
|
+
|
|
337
|
+
- بُني باستخدام [Angular](https://angular.io/)
|
|
338
|
+
- التحويل الهجري بواسطة [moment-hijri](https://github.com/xsoh/moment-hijri)
|
|
339
|
+
|
|
340
|
+
---
|
|
341
|
+
|
|
342
|
+
<div align="center">
|
|
343
|
+
|
|
344
|
+
**صُنع بـ ❤️ في مصر**
|
|
345
|
+
|
|
346
|
+
[Mohamed Mowafy](https://github.com/3Mowafy) • 2026
|
|
347
|
+
|
|
348
|
+
⭐ إذا أعجبتك المكتبة، لا تنسَ إعطائها نجمة على GitHub!
|
|
349
|
+
|
|
350
|
+
</div>
|
package/README.md
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
# ng-mo-date-picker
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
|
|
5
|
+
[](./README.md)
|
|
6
|
+
[](./README.ar.md)
|
|
7
|
+
|
|
8
|
+
🗓️ **Angular Hijri/Gregorian Date Picker with RTL/LTR support**
|
|
9
|
+
|
|
10
|
+
[](https://www.npmjs.com/package/ng-mo-date-picker)
|
|
11
|
+
[](https://opensource.org/licenses/MIT)
|
|
12
|
+
[](https://www.npmjs.com/package/ng-mo-date-picker)
|
|
13
|
+
|
|
14
|
+
[Demo](https://3mowafy.github.io/ng-mo-date-picker/) • [Documentation](#-api-reference) • [Examples](#-usage-examples)
|
|
15
|
+
|
|
16
|
+
</div>
|
|
17
|
+
## ✨ Features
|
|
18
|
+
|
|
19
|
+
- ✅ **Dual Calendar System**: Hijri (Islamic) and Gregorian calendars
|
|
20
|
+
- ✅ **Bilingual**: Full Arabic and English support
|
|
21
|
+
- ✅ **RTL/LTR**: Automatic direction switching
|
|
22
|
+
- ✅ **Forms Ready**: Works with Reactive Forms, Template-driven Forms, and Signal Forms
|
|
23
|
+
- ✅ **Lightweight**: Only ~50KB (with moment-hijri dependency)
|
|
24
|
+
- ✅ **Standalone**: No module imports needed (Angular 21+)
|
|
25
|
+
- ✅ **Customizable**: Custom icons, styles, and behavior
|
|
26
|
+
- ✅ **TypeScript**: Fully typed with excellent IntelliSense support
|
|
27
|
+
- ✅ **Rich Output**: Get both Gregorian and Hijri dates with full formatting
|
|
28
|
+
|
|
29
|
+
## 📦 Installation
|
|
30
|
+
```bash
|
|
31
|
+
npm install ng-mo-date-picker
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**Note**: `moment-hijri` will be installed automatically as a peer dependency.
|
|
35
|
+
|
|
36
|
+
## 🚀 Quick Start
|
|
37
|
+
|
|
38
|
+
### 1. Import the Component
|
|
39
|
+
```typescript
|
|
40
|
+
import { Component } from '@angular/core';
|
|
41
|
+
import { NgMoDatePicker, DatePickerOutput } from 'ng-mo-date-picker';
|
|
42
|
+
|
|
43
|
+
@Component({
|
|
44
|
+
selector: 'app-root',
|
|
45
|
+
imports: [NgMoDatePicker], // Standalone component
|
|
46
|
+
template: `
|
|
47
|
+
<ng-mo-date-picker
|
|
48
|
+
[locale]="'ar'"
|
|
49
|
+
(dateChange)="onDateChange($event)"
|
|
50
|
+
/>
|
|
51
|
+
`
|
|
52
|
+
})
|
|
53
|
+
export class AppComponent {
|
|
54
|
+
onDateChange(output: DatePickerOutput | null) {
|
|
55
|
+
if (output) {
|
|
56
|
+
console.log('Gregorian:', output.gregorianFormatted);
|
|
57
|
+
console.log('Hijri:', output.hijriFormatted);
|
|
58
|
+
console.log('Month Name:', output.hijriDate.monthName);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## 📚 Usage Examples
|
|
65
|
+
|
|
66
|
+
### Basic Usage (Arabic)
|
|
67
|
+
```html
|
|
68
|
+
<ng-mo-date-picker [locale]="'ar'" />
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### English with Custom Placeholder
|
|
72
|
+
```html
|
|
73
|
+
<ng-mo-date-picker
|
|
74
|
+
[locale]="'en'"
|
|
75
|
+
[placeholder]="'Pick a date'"
|
|
76
|
+
/>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Start with Hijri Calendar
|
|
80
|
+
```html
|
|
81
|
+
<ng-mo-date-picker
|
|
82
|
+
[calendarType]="'hijri'"
|
|
83
|
+
[locale]="'ar'"
|
|
84
|
+
/>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Custom Icon
|
|
88
|
+
```html
|
|
89
|
+
<ng-mo-date-picker
|
|
90
|
+
[customIcon]="'🗓️'"
|
|
91
|
+
/>
|
|
92
|
+
|
|
93
|
+
<!-- Or hide icon completely -->
|
|
94
|
+
<ng-mo-date-picker
|
|
95
|
+
[showIcon]="false"
|
|
96
|
+
/>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### With Reactive Forms
|
|
100
|
+
```typescript
|
|
101
|
+
import { FormControl, ReactiveFormsModule } from '@angular/forms';
|
|
102
|
+
|
|
103
|
+
@Component({
|
|
104
|
+
imports: [NgMoDatePicker, ReactiveFormsModule],
|
|
105
|
+
template: `
|
|
106
|
+
<ng-mo-date-picker [formControl]="dateControl" />
|
|
107
|
+
<p>Selected: {{ dateControl.value | date }}</p>
|
|
108
|
+
`
|
|
109
|
+
})
|
|
110
|
+
export class MyComponent {
|
|
111
|
+
dateControl = new FormControl<Date | null>(null);
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### With Template-driven Forms
|
|
116
|
+
```html
|
|
117
|
+
<ng-mo-date-picker
|
|
118
|
+
[(ngModel)]="selectedDate"
|
|
119
|
+
[locale]="'en'"
|
|
120
|
+
/>
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Custom Styling
|
|
124
|
+
```html
|
|
125
|
+
<ng-mo-date-picker
|
|
126
|
+
[inputClass]="'my-custom-input'"
|
|
127
|
+
[calendarClass]="'my-custom-calendar'"
|
|
128
|
+
/>
|
|
129
|
+
```
|
|
130
|
+
```css
|
|
131
|
+
.my-custom-input {
|
|
132
|
+
border: 2px solid #3b82f6;
|
|
133
|
+
border-radius: 8px;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.my-custom-calendar {
|
|
137
|
+
box-shadow: 0 20px 40px rgba(0,0,0,0.2);
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## 🎛️ API Reference
|
|
142
|
+
|
|
143
|
+
### Inputs
|
|
144
|
+
|
|
145
|
+
| Input | Type | Default | Description |
|
|
146
|
+
|-------|------|---------|-------------|
|
|
147
|
+
| `calendarType` | `'gregorian' \| 'hijri'` | `'gregorian'` | Initial calendar type to display |
|
|
148
|
+
| `locale` | `'ar' \| 'en'` | `'ar'` | Language and direction (RTL/LTR) |
|
|
149
|
+
| `showIcon` | `boolean` | `true` | Show/hide calendar icon |
|
|
150
|
+
| `customIcon` | `string` | `'📅'` | Custom icon (emoji or text) |
|
|
151
|
+
| `inputClass` | `string` | `''` | Additional CSS classes for input |
|
|
152
|
+
| `calendarClass` | `string` | `''` | Additional CSS classes for calendar popup |
|
|
153
|
+
| `disabled` | `boolean` | `false` | Disable the datepicker |
|
|
154
|
+
| `readonly` | `boolean` | `false` | Make input readonly |
|
|
155
|
+
| `placeholder` | `string` | Auto (based on locale) | Custom placeholder text |
|
|
156
|
+
| `name` | `string` | `undefined` | Input name attribute |
|
|
157
|
+
| `id` | `string` | `undefined` | Input id attribute |
|
|
158
|
+
|
|
159
|
+
### Outputs
|
|
160
|
+
|
|
161
|
+
| Output | Type | Description |
|
|
162
|
+
|--------|------|-------------|
|
|
163
|
+
| `dateChange` | `DatePickerOutput \| null` | Emits when date is selected or cleared |
|
|
164
|
+
| `calendarToggle` | `boolean` | Emits when calendar opens/closes |
|
|
165
|
+
|
|
166
|
+
### DatePickerOutput Interface
|
|
167
|
+
```typescript
|
|
168
|
+
interface DatePickerOutput {
|
|
169
|
+
// Gregorian date info
|
|
170
|
+
gregorianDate: Date;
|
|
171
|
+
gregorianFormatted: string; // "07/01/2026"
|
|
172
|
+
|
|
173
|
+
// Hijri date info
|
|
174
|
+
hijriDate: {
|
|
175
|
+
year: number; // 1446
|
|
176
|
+
month: number; // 7
|
|
177
|
+
monthName: string; // "Rajab" or "رجب"
|
|
178
|
+
day: number; // 18
|
|
179
|
+
};
|
|
180
|
+
hijriFormatted: string; // "18 Rajab 1446 AH"
|
|
181
|
+
|
|
182
|
+
// Meta info
|
|
183
|
+
calendarType: 'gregorian' | 'hijri';
|
|
184
|
+
locale: 'ar' | 'en';
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## 🎨 Styling
|
|
189
|
+
|
|
190
|
+
The datepicker comes with clean, modern styles out of the box. You can customize it using:
|
|
191
|
+
|
|
192
|
+
1. **CSS Variables** (coming in v2.0)
|
|
193
|
+
2. **Custom Classes**: Use `inputClass` and `calendarClass` inputs
|
|
194
|
+
3. **Override Styles**: Target `.mo-datepicker-wrapper`, `.mo-calendar`, etc.
|
|
195
|
+
|
|
196
|
+
### Example Custom Theme
|
|
197
|
+
```css
|
|
198
|
+
.mo-calendar {
|
|
199
|
+
--primary-color: #10b981;
|
|
200
|
+
--hover-color: #059669;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.mo-day.selected {
|
|
204
|
+
background: var(--primary-color);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.mo-day:hover {
|
|
208
|
+
background: var(--hover-color);
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## 🌍 i18n Support
|
|
213
|
+
|
|
214
|
+
The component automatically handles:
|
|
215
|
+
- Month names (Gregorian and Hijri)
|
|
216
|
+
- Day names
|
|
217
|
+
- UI labels (Today, Clear, etc.)
|
|
218
|
+
- Text direction (RTL/LTR)
|
|
219
|
+
|
|
220
|
+
Switch between languages:
|
|
221
|
+
```html
|
|
222
|
+
<ng-mo-date-picker [locale]="currentLocale" />
|
|
223
|
+
|
|
224
|
+
<button (click)="currentLocale = currentLocale === 'ar' ? 'en' : 'ar'">
|
|
225
|
+
Toggle Language
|
|
226
|
+
</button>
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## 🔧 Advanced Usage
|
|
230
|
+
|
|
231
|
+
### Listen to Calendar Toggle
|
|
232
|
+
```html
|
|
233
|
+
<ng-mo-date-picker
|
|
234
|
+
(calendarToggle)="onCalendarToggle($event)"
|
|
235
|
+
/>
|
|
236
|
+
```
|
|
237
|
+
```typescript
|
|
238
|
+
onCalendarToggle(isOpen: boolean) {
|
|
239
|
+
console.log('Calendar is now:', isOpen ? 'open' : 'closed');
|
|
240
|
+
}
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### Access Full Date Info
|
|
244
|
+
```typescript
|
|
245
|
+
onDateChange(output: DatePickerOutput | null) {
|
|
246
|
+
if (!output) {
|
|
247
|
+
console.log('Date cleared');
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// Use Gregorian
|
|
252
|
+
const jsDate = output.gregorianDate;
|
|
253
|
+
console.log('Gregorian:', output.gregorianFormatted);
|
|
254
|
+
|
|
255
|
+
// Use Hijri
|
|
256
|
+
console.log('Hijri Year:', output.hijriDate.year);
|
|
257
|
+
console.log('Hijri Month:', output.hijriDate.monthName);
|
|
258
|
+
console.log('Formatted:', output.hijriFormatted);
|
|
259
|
+
}
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
## 📱 Browser Support
|
|
263
|
+
|
|
264
|
+
- Chrome (latest)
|
|
265
|
+
- Firefox (latest)
|
|
266
|
+
- Safari (latest)
|
|
267
|
+
- Edge (latest)
|
|
268
|
+
|
|
269
|
+
## 🤝 Contributing
|
|
270
|
+
|
|
271
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
272
|
+
|
|
273
|
+
1. Fork the repo
|
|
274
|
+
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
|
|
275
|
+
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
|
|
276
|
+
4. Push to the branch (`git push origin feature/AmazingFeature`)
|
|
277
|
+
5. Open a Pull Request
|
|
278
|
+
|
|
279
|
+
## 🐛 Issues
|
|
280
|
+
|
|
281
|
+
Found a bug or have a feature request?
|
|
282
|
+
👉 [Open an issue on GitHub](https://github.com/3Mowafy/ng-mo-date-picker/issues)
|
|
283
|
+
|
|
284
|
+
## 📄 License
|
|
285
|
+
|
|
286
|
+
MIT © [Mohamed Mowafy](https://github.com/3Mowafy)
|
|
287
|
+
|
|
288
|
+
## 🔗 Links
|
|
289
|
+
|
|
290
|
+
- [GitHub Repository](https://github.com/3Mowafy/ng-mo-date-picker)
|
|
291
|
+
- [npm Package](https://www.npmjs.com/package/ng-mo-date-picker)
|
|
292
|
+
- [Issues](https://github.com/3Mowafy/ng-mo-date-picker/issues)
|
|
293
|
+
- [Demo](https://github.com/3Mowafy/ng-mo-date-picker#demo) *(coming soon)*
|
|
294
|
+
|
|
295
|
+
## 🙏 Acknowledgments
|
|
296
|
+
|
|
297
|
+
- Built with [Angular](https://angular.io/)
|
|
298
|
+
- Hijri conversion powered by [moment-hijri](https://github.com/xsoh/moment-hijri)
|
|
299
|
+
|
|
300
|
+
---
|
|
301
|
+
|
|
302
|
+
Made with ❤️ by [Mohamed Mowafy](https://github.com/3Mowafy)
|