afghan-datepicker 0.1.0 → 0.1.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 +107 -64
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,35 +1,38 @@
|
|
|
1
1
|
# afghan-datepicker
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/afghan-datepicker)
|
|
4
|
+
[](https://github.com/Abdulsami-hub/afghan-datepicker/blob/main/LICENSE)
|
|
5
|
+
[](https://www.npmjs.com/package/afghan-datepicker)
|
|
6
|
+
|
|
3
7
|
A TypeScript-first calendar engine, date utilities, and React date-picker
|
|
4
8
|
components for Afghan Solar Hijri, Iranian Jalali, and Gregorian calendars.
|
|
5
|
-
|
|
6
|
-
> **Development status:** This package is in active development and is not yet
|
|
7
|
-
> considered production-ready. It has not been published to npm. Calendar
|
|
8
|
-
> calculations, localization, utilities, `Calendar`, `DatePicker`, and
|
|
9
|
-
> `DateRangePicker` are implemented; month and year picker components remain
|
|
10
|
-
> planned.
|
|
9
|
+
`afghan-datepicker` is available on npm.
|
|
11
10
|
|
|
12
11
|
## Supported calendars and locales
|
|
13
12
|
|
|
14
|
-
The calendar
|
|
13
|
+
The package supports these calendar systems:
|
|
15
14
|
|
|
16
|
-
- Afghan Solar Hijri
|
|
17
|
-
- Iranian Jalali
|
|
18
|
-
- Gregorian
|
|
15
|
+
- Afghan Solar Hijri (`"afghan"`)
|
|
16
|
+
- Iranian Jalali (`"iranian"`)
|
|
17
|
+
- Gregorian (`"gregorian"`)
|
|
19
18
|
|
|
20
|
-
Built-in locales
|
|
21
|
-
Persian (`fa-IR`), and English (`en`). Calendar selection and locale selection
|
|
22
|
-
are independent.
|
|
19
|
+
Built-in locales:
|
|
23
20
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
| Code | Locale | Direction |
|
|
22
|
+
| ------- | --------------- | --------- |
|
|
23
|
+
| `fa-AF` | Afghan Dari | RTL |
|
|
24
|
+
| `ps-AF` | Afghan Pashto | RTL |
|
|
25
|
+
| `fa-IR` | Iranian Persian | RTL |
|
|
26
|
+
| `en` | English | LTR |
|
|
27
|
+
|
|
28
|
+
Calendar and locale selection are independent. Core utilities include date
|
|
29
|
+
conversion, leap-year checks, month lengths, validation, weekday calculation,
|
|
30
|
+
date arithmetic, comparisons, and calendar boundaries. Supported year ranges
|
|
31
|
+
and algorithm sources are documented in
|
|
27
32
|
[calendar rules](./docs/calendar-rules.md).
|
|
28
33
|
|
|
29
34
|
## Installation
|
|
30
35
|
|
|
31
|
-
The package is not published yet. After a release is available, install it with:
|
|
32
|
-
|
|
33
36
|
```sh
|
|
34
37
|
npm install afghan-datepicker
|
|
35
38
|
```
|
|
@@ -49,14 +52,16 @@ The styles are namespaced and do not require a CSS framework. See
|
|
|
49
52
|
|
|
50
53
|
```tsx
|
|
51
54
|
import { Calendar } from "afghan-datepicker";
|
|
52
|
-
import "afghan-datepicker/styles.css";
|
|
53
55
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
function AfghanCalendar() {
|
|
57
|
+
return (
|
|
58
|
+
<Calendar
|
|
59
|
+
calendar="afghan"
|
|
60
|
+
locale="fa-AF"
|
|
61
|
+
defaultValue={{ year: 1405, month: 1, day: 1 }}
|
|
62
|
+
/>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
60
65
|
```
|
|
61
66
|
|
|
62
67
|
### DatePicker
|
|
@@ -64,12 +69,16 @@ import "afghan-datepicker/styles.css";
|
|
|
64
69
|
```tsx
|
|
65
70
|
import { DatePicker } from "afghan-datepicker";
|
|
66
71
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
72
|
+
function IranianDatePicker() {
|
|
73
|
+
return (
|
|
74
|
+
<DatePicker
|
|
75
|
+
calendar="iranian"
|
|
76
|
+
locale="fa-IR"
|
|
77
|
+
defaultValue={{ year: 1405, month: 1, day: 1 }}
|
|
78
|
+
label="تاریخ"
|
|
79
|
+
/>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
73
82
|
```
|
|
74
83
|
|
|
75
84
|
### DateRangePicker
|
|
@@ -77,18 +86,53 @@ import { DatePicker } from "afghan-datepicker";
|
|
|
77
86
|
```tsx
|
|
78
87
|
import { DateRangePicker } from "afghan-datepicker";
|
|
79
88
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
89
|
+
function EnglishDateRangePicker() {
|
|
90
|
+
return (
|
|
91
|
+
<DateRangePicker
|
|
92
|
+
calendar="gregorian"
|
|
93
|
+
locale="en"
|
|
94
|
+
minRangeDays={2}
|
|
95
|
+
maxRangeDays={14}
|
|
96
|
+
/>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Controlled and uncontrolled values
|
|
102
|
+
|
|
103
|
+
Use `value` with `onChange` for controlled selection, or `defaultValue` for
|
|
104
|
+
uncontrolled selection:
|
|
105
|
+
|
|
106
|
+
```tsx
|
|
107
|
+
import { useState } from "react";
|
|
108
|
+
import { DatePicker, DateRangePicker } from "afghan-datepicker";
|
|
109
|
+
import type { CalendarDate, DateRange } from "afghan-datepicker";
|
|
110
|
+
|
|
111
|
+
function ControlledPickers() {
|
|
112
|
+
const [date, setDate] = useState<CalendarDate | null>(null);
|
|
113
|
+
const [range, setRange] = useState<DateRange | null>(null);
|
|
114
|
+
|
|
115
|
+
return (
|
|
116
|
+
<>
|
|
117
|
+
<DatePicker
|
|
118
|
+
calendar="afghan"
|
|
119
|
+
locale="ps-AF"
|
|
120
|
+
value={date}
|
|
121
|
+
onChange={setDate}
|
|
122
|
+
/>
|
|
123
|
+
<DateRangePicker
|
|
124
|
+
calendar="gregorian"
|
|
125
|
+
locale="en"
|
|
126
|
+
value={range}
|
|
127
|
+
onChange={setRange}
|
|
128
|
+
/>
|
|
129
|
+
</>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
86
132
|
```
|
|
87
133
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
components support RTL locales as well as LTR English; direction is set from
|
|
91
|
-
the selected locale.
|
|
134
|
+
See the [component guide](./docs/components.md) for all props, validation,
|
|
135
|
+
range selection, keyboard behavior, and styling.
|
|
92
136
|
|
|
93
137
|
## Date utilities
|
|
94
138
|
|
|
@@ -120,11 +164,12 @@ Month and year arithmetic constrains missing target days by default; pass
|
|
|
120
164
|
[date utilities](./docs/date-utilities.md) for boundaries, validation, and
|
|
121
165
|
complete semantics.
|
|
122
166
|
|
|
123
|
-
## Localization and numerals
|
|
167
|
+
## Localization, direction, and numerals
|
|
124
168
|
|
|
125
169
|
The locale supplies translated interface text, month and weekday names,
|
|
126
|
-
direction, and a default numeral system.
|
|
127
|
-
`
|
|
170
|
+
direction, and a default numeral system. For example, `fa-AF`, `ps-AF`, and
|
|
171
|
+
`fa-IR` provide RTL interfaces; `en` provides LTR. Components set direction
|
|
172
|
+
from the selected locale.
|
|
128
173
|
|
|
129
174
|
```ts
|
|
130
175
|
import {
|
|
@@ -144,32 +189,32 @@ formatCalendarDate(
|
|
|
144
189
|
); // "Saturday, Hamal 1, 1405"
|
|
145
190
|
|
|
146
191
|
getLocaleDirection("fa-AF"); // "rtl"
|
|
147
|
-
toLocalizedDigits("1405/01/01", "
|
|
192
|
+
toLocalizedDigits("1405/01/01", "persian"); // "۱۴۰۵/۰۱/۰۱"
|
|
193
|
+
toLocalizedDigits("1405/01/01", "arabic"); // "١٤٠٥/٠١/٠١"
|
|
148
194
|
```
|
|
149
195
|
|
|
150
|
-
|
|
151
|
-
`
|
|
152
|
-
independently with the `numerals` prop. See the
|
|
196
|
+
The supported numeral systems are `"latin"`, `"persian"`, and `"arabic"`.
|
|
197
|
+
Components accept a `numerals` prop to override the locale default. See the
|
|
153
198
|
[localization guide](./docs/localization.md) for locale data, formatting, and
|
|
154
199
|
custom locale registration.
|
|
155
200
|
|
|
156
|
-
## TypeScript and compatibility
|
|
201
|
+
## TypeScript, accessibility, and compatibility
|
|
157
202
|
|
|
158
203
|
TypeScript declarations and public types are included. Import types such as
|
|
159
204
|
`CalendarDate`, `DateRange`, `CalendarProps`, and `DateRangePickerProps` from
|
|
160
|
-
the package root
|
|
205
|
+
the package root. `DateRange` uses the existing calendar date type and
|
|
206
|
+
represents an incomplete range with `end: null`.
|
|
161
207
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
208
|
+
The components provide localized accessible names, native labels and buttons,
|
|
209
|
+
calendar grid/dialog semantics, visible focus states, and keyboard navigation.
|
|
210
|
+
Calendar navigation supports arrow keys, Home/End, Page Up/Down, and Enter or
|
|
211
|
+
Space selection. Escape closes picker popovers. Horizontal keyboard movement
|
|
212
|
+
follows the RTL/LTR layout. The [component guide](./docs/components.md#keyboard-and-accessibility)
|
|
213
|
+
describes the behavior in more detail.
|
|
168
214
|
|
|
169
|
-
The package targets ES2022 and declares React and React DOM peer
|
|
170
|
-
versions 18 and 19.
|
|
171
|
-
|
|
172
|
-
production-readiness guarantee.
|
|
215
|
+
The package targets ES2022 and declares React and React DOM peer dependencies
|
|
216
|
+
for versions 18 and 19. Browser-specific compatibility is not covered by a
|
|
217
|
+
complete automated browser matrix; test in your target browsers.
|
|
173
218
|
|
|
174
219
|
## Development
|
|
175
220
|
|
|
@@ -189,9 +234,7 @@ npm run format # Format project files with Prettier
|
|
|
189
234
|
|
|
190
235
|
Contributions are welcome. Keep calendar engines independent from React and
|
|
191
236
|
localization, avoid timezone-dependent calendar calculations, and include
|
|
192
|
-
focused tests for new behavior.
|
|
193
|
-
[component guide](./docs/components.md) and the calendar, localization, and
|
|
194
|
-
utility references linked above.
|
|
237
|
+
focused tests for new behavior.
|
|
195
238
|
|
|
196
239
|
## Repository
|
|
197
240
|
|
|
@@ -199,4 +242,4 @@ utility references linked above.
|
|
|
199
242
|
|
|
200
243
|
## License
|
|
201
244
|
|
|
202
|
-
MIT. See [LICENSE](./LICENSE).
|
|
245
|
+
MIT © 2026 Abdul Sami Fazilyar. See [LICENSE](./LICENSE).
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "afghan-datepicker",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "A TypeScript calendar engine, date utilities, and React date-picker components for Afghan Solar Hijri, Iranian Jalali, and Gregorian calendars.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Abdul Sami Fazilyar",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "https://github.com/Abdulsami-hub/afghan-datepicker.git"
|
|
9
|
+
"url": "git+https://github.com/Abdulsami-hub/afghan-datepicker.git"
|
|
10
10
|
},
|
|
11
11
|
"homepage": "https://github.com/Abdulsami-hub/afghan-datepicker#readme",
|
|
12
12
|
"bugs": {
|