@rushdi94/hijri-datepicker 1.0.1

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.md ADDED
@@ -0,0 +1,212 @@
1
+ # @rushdi94/hijri-datepicker
2
+
3
+ A fully customizable **Hijri (Islamic) date picker** component.
4
+
5
+ - No framework required — works in React, Angular, Vue, or plain HTML
6
+ - Pure Hijri calendar (Tabular Islamic Calendar algorithm)
7
+ - RTL **and** LTR layout support
8
+ - Fully customizable colors via simple options
9
+ - TypeScript types included
10
+ - Zero runtime dependencies
11
+
12
+ ---
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install @rushdi94/hijri-datepicker
18
+ ```
19
+
20
+ ---
21
+
22
+ ## Quick Start
23
+
24
+ ```html
25
+ <div id="my-picker"></div>
26
+ ```
27
+
28
+ ```js
29
+ import { HijriDatePicker } from '@rushdi94/hijri-datepicker';
30
+
31
+ const picker = new HijriDatePicker({
32
+ container: '#my-picker',
33
+ onSelect(date, formatted) {
34
+ console.log(date); // { year: 1447, month: 11, day: 30 }
35
+ console.log(formatted); // "30/11/1447"
36
+ },
37
+ });
38
+ ```
39
+
40
+ ---
41
+
42
+ ## Custom Colors
43
+
44
+ ```js
45
+ new HijriDatePicker({
46
+ container: '#my-picker',
47
+ primaryColor: '#1565c0', // header, selected day, today ring
48
+ onPrimaryColor: '#ffffff', // text on colored surfaces
49
+ bodyBg: '#f0f4ff', // calendar background
50
+ dayColor: '#1a237e', // regular day number color
51
+ format: 'YYYY/MM/DD',
52
+ });
53
+ ```
54
+
55
+ ---
56
+
57
+ ## RTL & LTR Support
58
+
59
+ **RTL (Arabic / Urdu / Persian) — default:**
60
+ ```js
61
+ new HijriDatePicker({
62
+ container: '#picker',
63
+ dir: 'rtl', // default, Arabic labels
64
+ });
65
+ ```
66
+
67
+ **LTR (English / European interfaces):**
68
+ ```js
69
+ new HijriDatePicker({
70
+ container: '#picker',
71
+ dir: 'ltr',
72
+ primaryColor: '#1565c0',
73
+ weekdayLabels: ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],
74
+ monthLabels: [
75
+ 'Muharram','Safar',"Rabi' I","Rabi' II",
76
+ 'Jumada I','Jumada II','Rajab',"Sha'ban",
77
+ 'Ramadan','Shawwal',"Dhu al-Qi'dah","Dhu al-Hijjah",
78
+ ],
79
+ });
80
+ ```
81
+
82
+ ---
83
+
84
+ ## Inline Mode
85
+
86
+ ```js
87
+ new HijriDatePicker({
88
+ container: '#calendar-area',
89
+ inline: true, // always visible, no input field
90
+ primaryColor: '#2e7d32',
91
+ });
92
+ ```
93
+
94
+ ---
95
+
96
+ ## All Options
97
+
98
+ | Option | Type | Default | Description |
99
+ |---|---|---|---|
100
+ | `container` | `string \| HTMLElement` | **required** | CSS selector or DOM element |
101
+ | `dir` | `'rtl' \| 'ltr'` | `'rtl'` | Layout direction |
102
+ | `inline` | `boolean` | `false` | Show calendar without an input |
103
+ | `placeholder` | `string` | Arabic text | Input placeholder |
104
+ | `primaryColor` | `string` | `'#8b1a2e'` | Main color (header, selected, today) |
105
+ | `onPrimaryColor` | `string` | `'#ffffff'` | Text on primary-colored surfaces |
106
+ | `bodyBg` | `string` | `'#ffffff'` | Calendar body background |
107
+ | `dayColor` | `string` | `'#1f2937'` | Regular day number color |
108
+ | `format` | `string` | `'DD/MM/YYYY'` | Date format (tokens: `DD` `MM` `YYYY`) |
109
+ | `weekdayLabels` | `string[7]` | Arabic | Column headers Sun→Sat |
110
+ | `monthLabels` | `string[12]` | Arabic | Muharram→Dhu al-Hijjah |
111
+ | `editable` | `boolean` | `false` | Allow typing in the input |
112
+ | `initialDate` | `HijriDate` | today | Initial calendar view |
113
+ | `onSelect` | `(date, fmt) => void` | — | Date selection callback |
114
+ | `onOpen` | `() => void` | — | Called when picker opens |
115
+ | `onClose` | `() => void` | — | Called when picker closes |
116
+
117
+ ---
118
+
119
+ ## Programmatic API
120
+
121
+ ```js
122
+ picker.getValue() // → HijriDate | null
123
+ picker.setValue({ year: 1447, month: 9, day: 1 }) // select a date
124
+ picker.goTo(1447, 12) // navigate calendar view
125
+ picker.clear() // clear selection
126
+ picker.setColors({ primaryColor: '#e53935' }) // live color update
127
+ picker.open() // open programmatically
128
+ picker.close() // close programmatically
129
+ picker.destroy() // remove from DOM
130
+ ```
131
+
132
+ ---
133
+
134
+ ## Helper Functions
135
+
136
+ ```js
137
+ import { toHijri, toGregorian, formatHijri, todayHijri } from '@rushdi94/hijri-datepicker';
138
+
139
+ toHijri(new Date('2026-05-17'))
140
+ // → { year: 1447, month: 11, day: 30 }
141
+
142
+ toGregorian(1447, 9, 1)
143
+ // → Date object (2026-02-28)
144
+
145
+ formatHijri({ year: 1447, month: 11, day: 30 }, 'YYYY/MM/DD')
146
+ // → "1447/11/30"
147
+
148
+ todayHijri()
149
+ // → current Hijri date
150
+ ```
151
+
152
+ ---
153
+
154
+ ## CDN / Script Tag
155
+
156
+ ```html
157
+ <script src="https://unpkg.com/@rushdi94/hijri-datepicker/dist/hijri-datepicker.umd.js"></script>
158
+ <script>
159
+ const { HijriDatePicker } = HijriDatePickerLib;
160
+ new HijriDatePicker({ container: '#el' });
161
+ </script>
162
+ ```
163
+
164
+ ---
165
+
166
+ ## Angular
167
+
168
+ ```ts
169
+ import { Component, AfterViewInit, ElementRef, ViewChild } from '@angular/core';
170
+ import { HijriDatePicker } from '@rushdi94/hijri-datepicker';
171
+
172
+ @Component({ template: `<div #picker></div>` })
173
+ export class MyComponent implements AfterViewInit {
174
+ @ViewChild('picker') pickerRef!: ElementRef;
175
+ private hdp!: HijriDatePicker;
176
+
177
+ ngAfterViewInit() {
178
+ this.hdp = new HijriDatePicker({
179
+ container: this.pickerRef.nativeElement,
180
+ onSelect: (date, fmt) => console.log(date, fmt),
181
+ });
182
+ }
183
+ ngOnDestroy() { this.hdp.destroy(); }
184
+ }
185
+ ```
186
+
187
+ ## React
188
+
189
+ ```tsx
190
+ import { useEffect, useRef } from 'react';
191
+ import { HijriDatePicker, HijriDate } from '@rushdi94/hijri-datepicker';
192
+
193
+ export function HijriPicker({ onSelect }: { onSelect: (d: HijriDate) => void }) {
194
+ const ref = useRef<HTMLDivElement>(null);
195
+
196
+ useEffect(() => {
197
+ const picker = new HijriDatePicker({
198
+ container: ref.current!,
199
+ onSelect: (date) => onSelect(date),
200
+ });
201
+ return () => picker.destroy();
202
+ }, []);
203
+
204
+ return <div ref={ref} />;
205
+ }
206
+ ```
207
+
208
+ ---
209
+
210
+ ## License
211
+
212
+ MIT