expo-persian-date-wheel 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/LICENSE +21 -0
- package/README.md +110 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +410 -0
- package/package.json +44 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ali Sabet
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# expo-persian-date-wheel / انتخابگر تاریخ و زمان چرخمانند فارسی
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/expo-persian-date-wheel)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
A beautiful, customizable Persian/Jalali date wheel picker for React Native and Expo with multiple elegant themes.
|
|
7
|
+
|
|
8
|
+
یک انتخابگر تاریخ و زمان چرخمانند فارسی زیبا و قابل تنظیم برای ریاکت نیتیو و اکسپو با چندین تم زیبا
|
|
9
|
+
با استفاده از moment-jalaali
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 📸 Screenshots / تصاویر
|
|
14
|
+
|
|
15
|
+
| Theme | Screenshot |
|
|
16
|
+
| -------------- | -------------------------------- |
|
|
17
|
+
| Adeleh (Light) |  |
|
|
18
|
+
| Atlas (Dark) |  |
|
|
19
|
+
| Shadi (Dark) |  |
|
|
20
|
+
| Esi (Light) |  |
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## ✨ Features / ویژگیها
|
|
25
|
+
|
|
26
|
+
**English:**
|
|
27
|
+
|
|
28
|
+
- 🎨 4 Beautiful themes (Adeleh, Atlas, Shadi, Esi)
|
|
29
|
+
- 📅 Full Persian/Jalali calendar support
|
|
30
|
+
- ⏰ Optional time picker (hour & minute)
|
|
31
|
+
- 🎯 Auto-scroll to selected values
|
|
32
|
+
- 🖌️ Custom font support (use any Persian font)
|
|
33
|
+
- 🔘 "Now" button to jump to current date/time
|
|
34
|
+
- 🔢 Persian numeral support (optional)
|
|
35
|
+
- 🚀 Lightweight with zero extra dependencies
|
|
36
|
+
- 📱 Works with Expo & React Native CLI
|
|
37
|
+
|
|
38
|
+
**فارسی:**
|
|
39
|
+
|
|
40
|
+
- 🎨 ۴ تم زیبا (Adeleh، Atlas، Shadi، Esi)
|
|
41
|
+
- 📅 پشتیبانی کامل از تقویم شمسی (جلالی)
|
|
42
|
+
- ⏰ انتخابگر زمان (ساعت و دقیقه)
|
|
43
|
+
- 🎯 اسکرول خودکار به مقدار انتخاب شده
|
|
44
|
+
- 🖌️ پشتیبانی از فونتهای دلخواه
|
|
45
|
+
- 🔘 دکمه "اکنون" برای رفتن به زمان حال
|
|
46
|
+
- 🔢 پشتیبانی از اعداد فارسی
|
|
47
|
+
- 🚀 سبک و بدون وابستگی اضافی
|
|
48
|
+
- 📱 کار با Expo و React Native CLI
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## 📦 Installation / نصب
|
|
53
|
+
|
|
54
|
+
**English:**
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npm install expo-persian-date-wheel moment-jalaali
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## 📚 Full Documentation
|
|
61
|
+
|
|
62
|
+
### How It Works
|
|
63
|
+
|
|
64
|
+
The picker uses `moment-jalaali` for Persian calendar conversion and provides a smooth wheel-style interface similar to iOS date pickers.
|
|
65
|
+
|
|
66
|
+
**Key Features Explained:**
|
|
67
|
+
|
|
68
|
+
1. **Auto-scroll** - Automatically scrolls to selected date/time when opened
|
|
69
|
+
2. **Persian Numbers** - Converts English numbers to Persian (optional)
|
|
70
|
+
3. **RTL Support** - Full right-to-left layout for Persian text
|
|
71
|
+
4. **Themes** - 4 built-in themes with light/dark options
|
|
72
|
+
|
|
73
|
+
### API Reference
|
|
74
|
+
|
|
75
|
+
#### PersianDateWheel Props
|
|
76
|
+
|
|
77
|
+
| Prop | Type | Required | Default | Description |
|
|
78
|
+
| ------------------- | ----------------------------- | -------- | ---------------- | ------------------------- |
|
|
79
|
+
| `visible` | `boolean` | ✅ Yes | - | Controls modal visibility |
|
|
80
|
+
| `onConfirm` | `(timestamp: number) => void` | ✅ Yes | - | Called when user confirms |
|
|
81
|
+
| `onCancel` | `() => void` | ✅ Yes | - | Called when user cancels |
|
|
82
|
+
| `value` | `number` | ❌ No | `Date.now()` | Initial timestamp |
|
|
83
|
+
| `showTime` | `boolean` | ❌ No | `false` | Show time picker |
|
|
84
|
+
| `variant` | `string` | ❌ No | `'atlas'` | Theme name |
|
|
85
|
+
| `minYear` | `number` | ❌ No | `1320` | Minimum selectable year |
|
|
86
|
+
| `maxYear` | `number` | ❌ No | `1440` | Maximum selectable year |
|
|
87
|
+
| `title` | `string` | ❌ No | `'انتخاب تاریخ'` | Modal title |
|
|
88
|
+
| `cancelText` | `string` | ❌ No | `'انصراف'` | Cancel button text |
|
|
89
|
+
| `confirmText` | `string` | ❌ No | `'تأیید'` | Confirm button text |
|
|
90
|
+
| `showNowButton` | `boolean` | ❌ No | `false` | Show "Now" button |
|
|
91
|
+
| `nowButtonText` | `string` | ❌ No | `'اکنون'` | Custom "Now" button text |
|
|
92
|
+
| `fontFamily` | `string` | ❌ No | `'System'` | Custom font name |
|
|
93
|
+
| `usePersianNumbers` | `boolean` | ❌ No | `true` | Use Persian numerals |
|
|
94
|
+
|
|
95
|
+
### Understanding the Value
|
|
96
|
+
|
|
97
|
+
The picker returns a **JavaScript timestamp** (milliseconds since Unix epoch). You can convert it using moment-jalaali:
|
|
98
|
+
|
|
99
|
+
```tsx
|
|
100
|
+
import moment from "moment-jalaali";
|
|
101
|
+
|
|
102
|
+
// Convert timestamp to Persian date
|
|
103
|
+
const persianDate = moment(timestamp);
|
|
104
|
+
console.log(persianDate.format("jYYYY/jMM/jDD HH:mm"));
|
|
105
|
+
// Output: ۱۴۰۳/۰۴/۱۵ ۱۴:۳۰
|
|
106
|
+
|
|
107
|
+
// Convert to Gregorian if needed
|
|
108
|
+
const gregorian = new Date(timestamp);
|
|
109
|
+
console.log(gregorian.toLocaleDateString("en-US"));
|
|
110
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface PersianDateWheelProps {
|
|
3
|
+
visible: boolean;
|
|
4
|
+
value?: number;
|
|
5
|
+
onConfirm: (timestamp: number) => void;
|
|
6
|
+
onCancel: () => void;
|
|
7
|
+
showTime?: boolean;
|
|
8
|
+
variant?: "atlas" | "adeleh" | "shadi" | "esi";
|
|
9
|
+
minYear?: number;
|
|
10
|
+
maxYear?: number;
|
|
11
|
+
title?: string;
|
|
12
|
+
cancelText?: string;
|
|
13
|
+
confirmText?: string;
|
|
14
|
+
showNowButton?: boolean;
|
|
15
|
+
nowButtonText?: string;
|
|
16
|
+
fontFamily?: string;
|
|
17
|
+
usePersianNumbers?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export default function PersianDateWheel({ visible, value, onConfirm, onCancel, showTime, variant, minYear, maxYear, title, cancelText, confirmText, showNowButton, nowButtonText, fontFamily, usePersianNumbers, }: PersianDateWheelProps): React.JSX.Element;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.default = PersianDateWheel;
|
|
40
|
+
const react_1 = __importStar(require("react"));
|
|
41
|
+
const react_native_1 = require("react-native");
|
|
42
|
+
const moment_jalaali_1 = __importDefault(require("moment-jalaali"));
|
|
43
|
+
// Configure moment-jalaali
|
|
44
|
+
moment_jalaali_1.default.loadPersian();
|
|
45
|
+
// Convert English numbers to Persian (Farsi) numbers
|
|
46
|
+
const toPersianNumbers = (text) => {
|
|
47
|
+
const persianDigits = ["۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹"];
|
|
48
|
+
return String(text).replace(/\d/g, (d) => persianDigits[parseInt(d)]);
|
|
49
|
+
};
|
|
50
|
+
// Theme variants
|
|
51
|
+
const variants = {
|
|
52
|
+
adeleh: {
|
|
53
|
+
background: "#FFFFFF",
|
|
54
|
+
surface: "#FFFFFF",
|
|
55
|
+
primary: "#6366F1",
|
|
56
|
+
text: "#1F2937",
|
|
57
|
+
textSecondary: "#6B7280",
|
|
58
|
+
border: "#E5E7EB",
|
|
59
|
+
selectedBackground: "#E0E7FF",
|
|
60
|
+
isDark: false,
|
|
61
|
+
},
|
|
62
|
+
atlas: {
|
|
63
|
+
background: "#1E1E2E",
|
|
64
|
+
surface: "#2D2D3D",
|
|
65
|
+
primary: "#F59E0B",
|
|
66
|
+
text: "#F3F4F6",
|
|
67
|
+
textSecondary: "#9CA3AF",
|
|
68
|
+
border: "#4B5563",
|
|
69
|
+
selectedBackground: "#78350F",
|
|
70
|
+
isDark: true,
|
|
71
|
+
},
|
|
72
|
+
shadi: {
|
|
73
|
+
background: "#0F172A",
|
|
74
|
+
surface: "#1E293B",
|
|
75
|
+
primary: "#EC4899",
|
|
76
|
+
text: "#F8FAFC",
|
|
77
|
+
textSecondary: "#94A3B8",
|
|
78
|
+
border: "#334155",
|
|
79
|
+
selectedBackground: "#831843",
|
|
80
|
+
isDark: true,
|
|
81
|
+
},
|
|
82
|
+
esi: {
|
|
83
|
+
background: "#FDF4FF",
|
|
84
|
+
surface: "#FFFFFF",
|
|
85
|
+
primary: "#8B5CF6",
|
|
86
|
+
text: "#2D1B4E",
|
|
87
|
+
textSecondary: "#7C3AED",
|
|
88
|
+
border: "#E9D5FF",
|
|
89
|
+
selectedBackground: "#F3E8FF",
|
|
90
|
+
isDark: false,
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
function PersianDateWheel({ visible, value = Date.now(), onConfirm, onCancel, showTime = false, variant = "atlas", minYear = 1320, maxYear = 1440, title, cancelText, confirmText, showNowButton = false, nowButtonText, fontFamily = react_native_1.Platform.OS === "ios" ? "System" : "sans-serif", usePersianNumbers = true, // Default to true for Persian numbers
|
|
94
|
+
}) {
|
|
95
|
+
const theme = variants[variant];
|
|
96
|
+
const colors = theme;
|
|
97
|
+
const texts = {
|
|
98
|
+
cancel: cancelText || "انصراف",
|
|
99
|
+
confirm: confirmText || "تأیید",
|
|
100
|
+
title: title || "انتخاب تاریخ",
|
|
101
|
+
year: "سال",
|
|
102
|
+
month: "ماه",
|
|
103
|
+
day: "روز",
|
|
104
|
+
hour: "ساعت",
|
|
105
|
+
minute: "دقیقه",
|
|
106
|
+
};
|
|
107
|
+
const t = texts;
|
|
108
|
+
const nowText = nowButtonText || "اکنون";
|
|
109
|
+
// Create a helper function for two-digit numbers
|
|
110
|
+
const formatTwoDigitNumber = (num) => {
|
|
111
|
+
const twoDigit = num.toString().padStart(2, "0");
|
|
112
|
+
return usePersianNumbers ? toPersianNumbers(twoDigit) : twoDigit;
|
|
113
|
+
};
|
|
114
|
+
const m = (0, moment_jalaali_1.default)(value);
|
|
115
|
+
const [selectedYear, setSelectedYear] = (0, react_1.useState)(m.jYear());
|
|
116
|
+
const [selectedMonth, setSelectedMonth] = (0, react_1.useState)(m.jMonth() + 1);
|
|
117
|
+
const [selectedDay, setSelectedDay] = (0, react_1.useState)(m.jDate());
|
|
118
|
+
const [selectedHour, setSelectedHour] = (0, react_1.useState)(m.hour());
|
|
119
|
+
const [selectedMinute, setSelectedMinute] = (0, react_1.useState)(m.minute());
|
|
120
|
+
// Refs for scrolling
|
|
121
|
+
const yearScrollRef = (0, react_1.useRef)(null);
|
|
122
|
+
const monthScrollRef = (0, react_1.useRef)(null);
|
|
123
|
+
const dayScrollRef = (0, react_1.useRef)(null);
|
|
124
|
+
const hourScrollRef = (0, react_1.useRef)(null);
|
|
125
|
+
const minuteScrollRef = (0, react_1.useRef)(null);
|
|
126
|
+
const handleSetToNow = () => {
|
|
127
|
+
const now = (0, moment_jalaali_1.default)();
|
|
128
|
+
setSelectedYear(now.jYear());
|
|
129
|
+
setSelectedMonth(now.jMonth() + 1);
|
|
130
|
+
setSelectedDay(now.jDate());
|
|
131
|
+
setSelectedHour(now.hour());
|
|
132
|
+
setSelectedMinute(now.minute());
|
|
133
|
+
};
|
|
134
|
+
const years = Array.from({ length: maxYear - minYear + 1 }, (_, i) => minYear + i);
|
|
135
|
+
const months = [
|
|
136
|
+
"فروردین",
|
|
137
|
+
"اردیبهشت",
|
|
138
|
+
"خرداد",
|
|
139
|
+
"تیر",
|
|
140
|
+
"مرداد",
|
|
141
|
+
"شهریور",
|
|
142
|
+
"مهر",
|
|
143
|
+
"آبان",
|
|
144
|
+
"آذر",
|
|
145
|
+
"دی",
|
|
146
|
+
"بهمن",
|
|
147
|
+
"اسفند",
|
|
148
|
+
];
|
|
149
|
+
const getDaysInMonth = (year, month) => {
|
|
150
|
+
if (month <= 6)
|
|
151
|
+
return 31;
|
|
152
|
+
if (month <= 11)
|
|
153
|
+
return 30;
|
|
154
|
+
return (0, moment_jalaali_1.default)(`${year}/12/01`, "jYYYY/jMM/jDD").isLeapYear() ? 30 : 29;
|
|
155
|
+
};
|
|
156
|
+
const days = Array.from({ length: getDaysInMonth(selectedYear, selectedMonth) }, (_, i) => i + 1);
|
|
157
|
+
const hours = Array.from({ length: 24 }, (_, i) => i);
|
|
158
|
+
const minutes = Array.from({ length: 60 }, (_, i) => i);
|
|
159
|
+
// Format number with Persian digits if enabled
|
|
160
|
+
const formatNumber = (num) => {
|
|
161
|
+
const str = String(num);
|
|
162
|
+
return usePersianNumbers ? toPersianNumbers(str) : str;
|
|
163
|
+
};
|
|
164
|
+
// Auto-scroll effect
|
|
165
|
+
(0, react_1.useEffect)(() => {
|
|
166
|
+
if (visible) {
|
|
167
|
+
const timer = setTimeout(() => {
|
|
168
|
+
const yearIndex = years.findIndex((y) => y === selectedYear);
|
|
169
|
+
const monthIndex = selectedMonth - 1;
|
|
170
|
+
const dayIndex = selectedDay - 1;
|
|
171
|
+
const hourIndex = selectedHour;
|
|
172
|
+
const minuteIndex = selectedMinute;
|
|
173
|
+
if (yearScrollRef.current && yearIndex >= 0) {
|
|
174
|
+
yearScrollRef.current.scrollTo({ y: yearIndex * 44, animated: true });
|
|
175
|
+
}
|
|
176
|
+
if (monthScrollRef.current && monthIndex >= 0) {
|
|
177
|
+
monthScrollRef.current.scrollTo({
|
|
178
|
+
y: monthIndex * 44,
|
|
179
|
+
animated: true,
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
if (dayScrollRef.current && dayIndex >= 0) {
|
|
183
|
+
dayScrollRef.current.scrollTo({ y: dayIndex * 44, animated: true });
|
|
184
|
+
}
|
|
185
|
+
if (hourScrollRef.current && hourIndex >= 0) {
|
|
186
|
+
hourScrollRef.current.scrollTo({ y: hourIndex * 44, animated: true });
|
|
187
|
+
}
|
|
188
|
+
if (minuteScrollRef.current && minuteIndex >= 0) {
|
|
189
|
+
minuteScrollRef.current.scrollTo({
|
|
190
|
+
y: minuteIndex * 44,
|
|
191
|
+
animated: true,
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
}, 200);
|
|
195
|
+
return () => clearTimeout(timer);
|
|
196
|
+
}
|
|
197
|
+
}, [
|
|
198
|
+
visible,
|
|
199
|
+
selectedYear,
|
|
200
|
+
selectedMonth,
|
|
201
|
+
selectedDay,
|
|
202
|
+
selectedHour,
|
|
203
|
+
selectedMinute,
|
|
204
|
+
]);
|
|
205
|
+
(0, react_1.useEffect)(() => {
|
|
206
|
+
const maxDay = getDaysInMonth(selectedYear, selectedMonth);
|
|
207
|
+
if (selectedDay > maxDay) {
|
|
208
|
+
setSelectedDay(maxDay);
|
|
209
|
+
}
|
|
210
|
+
}, [selectedYear, selectedMonth]);
|
|
211
|
+
const handleConfirm = () => {
|
|
212
|
+
const date = (0, moment_jalaali_1.default)(`${selectedYear}/${selectedMonth}/${selectedDay}`, "jYYYY/jM/jD")
|
|
213
|
+
.hour(selectedHour)
|
|
214
|
+
.minute(selectedMinute)
|
|
215
|
+
.second(0);
|
|
216
|
+
onConfirm(date.valueOf());
|
|
217
|
+
};
|
|
218
|
+
const PickerItem = ({ label, isSelected, onPress }) => (<react_native_1.TouchableOpacity style={[
|
|
219
|
+
styles.pickerItem,
|
|
220
|
+
isSelected && { backgroundColor: `${colors.primary}20` },
|
|
221
|
+
]} onPress={onPress} activeOpacity={0.7}>
|
|
222
|
+
<react_native_1.Text style={[
|
|
223
|
+
styles.pickerItemText,
|
|
224
|
+
{
|
|
225
|
+
color: isSelected ? colors.primary : colors.text,
|
|
226
|
+
fontFamily: fontFamily,
|
|
227
|
+
fontWeight: isSelected ? "600" : "400",
|
|
228
|
+
},
|
|
229
|
+
]}>
|
|
230
|
+
{label}
|
|
231
|
+
</react_native_1.Text>
|
|
232
|
+
</react_native_1.TouchableOpacity>);
|
|
233
|
+
return (<react_native_1.Modal visible={visible} transparent={true} animationType="slide" onRequestClose={onCancel}>
|
|
234
|
+
<react_native_1.View style={styles.overlay}>
|
|
235
|
+
<react_native_1.View style={[styles.container, { backgroundColor: colors.surface }]}>
|
|
236
|
+
<react_native_1.View style={[styles.header, { borderBottomColor: colors.border }]}>
|
|
237
|
+
<react_native_1.TouchableOpacity onPress={onCancel} hitSlop={{ top: 10, bottom: 10, left: 10, right: 10 }}>
|
|
238
|
+
<react_native_1.Text style={[
|
|
239
|
+
styles.cancelText,
|
|
240
|
+
{ color: colors.textSecondary, fontFamily },
|
|
241
|
+
]}>
|
|
242
|
+
{t.cancel}
|
|
243
|
+
</react_native_1.Text>
|
|
244
|
+
</react_native_1.TouchableOpacity>
|
|
245
|
+
|
|
246
|
+
{showNowButton && (<react_native_1.TouchableOpacity onPress={handleSetToNow} hitSlop={{ top: 10, bottom: 10, left: 10, right: 10 }} style={styles.nowButton}>
|
|
247
|
+
<react_native_1.Text style={[
|
|
248
|
+
styles.nowButtonText,
|
|
249
|
+
{ color: colors.primary, fontFamily, fontWeight: "500" },
|
|
250
|
+
]}>
|
|
251
|
+
{nowText}
|
|
252
|
+
</react_native_1.Text>
|
|
253
|
+
</react_native_1.TouchableOpacity>)}
|
|
254
|
+
|
|
255
|
+
<react_native_1.Text style={[
|
|
256
|
+
styles.title,
|
|
257
|
+
{ color: colors.text, fontFamily, fontWeight: "600" },
|
|
258
|
+
]}>
|
|
259
|
+
{t.title}
|
|
260
|
+
</react_native_1.Text>
|
|
261
|
+
|
|
262
|
+
<react_native_1.TouchableOpacity onPress={handleConfirm} hitSlop={{ top: 10, bottom: 10, left: 10, right: 10 }}>
|
|
263
|
+
<react_native_1.Text style={[
|
|
264
|
+
styles.confirmText,
|
|
265
|
+
{ color: colors.primary, fontFamily, fontWeight: "600" },
|
|
266
|
+
]}>
|
|
267
|
+
{t.confirm}
|
|
268
|
+
</react_native_1.Text>
|
|
269
|
+
</react_native_1.TouchableOpacity>
|
|
270
|
+
</react_native_1.View>
|
|
271
|
+
|
|
272
|
+
<react_native_1.View style={[styles.pickersContainer, styles.pickersContainerRTL]}>
|
|
273
|
+
{/* Year Picker */}
|
|
274
|
+
<react_native_1.View style={styles.pickerColumn}>
|
|
275
|
+
<react_native_1.Text style={[
|
|
276
|
+
styles.pickerLabel,
|
|
277
|
+
{ color: colors.textSecondary, fontFamily },
|
|
278
|
+
]}>
|
|
279
|
+
{t.year}
|
|
280
|
+
</react_native_1.Text>
|
|
281
|
+
<react_native_1.ScrollView ref={yearScrollRef} showsVerticalScrollIndicator={false} style={styles.pickerScroll}>
|
|
282
|
+
{years.map((year) => (<PickerItem key={year} label={formatNumber(year)} isSelected={selectedYear === year} onPress={() => setSelectedYear(year)}/>))}
|
|
283
|
+
</react_native_1.ScrollView>
|
|
284
|
+
</react_native_1.View>
|
|
285
|
+
|
|
286
|
+
{/* Month Picker */}
|
|
287
|
+
<react_native_1.View style={styles.pickerColumn}>
|
|
288
|
+
<react_native_1.Text style={[
|
|
289
|
+
styles.pickerLabel,
|
|
290
|
+
{ color: colors.textSecondary, fontFamily },
|
|
291
|
+
]}>
|
|
292
|
+
{t.month}
|
|
293
|
+
</react_native_1.Text>
|
|
294
|
+
<react_native_1.ScrollView ref={monthScrollRef} showsVerticalScrollIndicator={false} style={styles.pickerScroll}>
|
|
295
|
+
{months.map((month, index) => (<PickerItem key={index} label={month} isSelected={selectedMonth === index + 1} onPress={() => setSelectedMonth(index + 1)}/>))}
|
|
296
|
+
</react_native_1.ScrollView>
|
|
297
|
+
</react_native_1.View>
|
|
298
|
+
|
|
299
|
+
{/* Day Picker */}
|
|
300
|
+
<react_native_1.View style={styles.pickerColumn}>
|
|
301
|
+
<react_native_1.Text style={[
|
|
302
|
+
styles.pickerLabel,
|
|
303
|
+
{ color: colors.textSecondary, fontFamily },
|
|
304
|
+
]}>
|
|
305
|
+
{t.day}
|
|
306
|
+
</react_native_1.Text>
|
|
307
|
+
<react_native_1.ScrollView ref={dayScrollRef} showsVerticalScrollIndicator={false} style={styles.pickerScroll}>
|
|
308
|
+
{days.map((day) => (<PickerItem key={day} label={formatNumber(day)} isSelected={selectedDay === day} onPress={() => setSelectedDay(day)}/>))}
|
|
309
|
+
</react_native_1.ScrollView>
|
|
310
|
+
</react_native_1.View>
|
|
311
|
+
|
|
312
|
+
{/* Hour Picker */}
|
|
313
|
+
{showTime && (<react_native_1.View style={styles.pickerColumn}>
|
|
314
|
+
<react_native_1.Text style={[
|
|
315
|
+
styles.pickerLabel,
|
|
316
|
+
{ color: colors.textSecondary, fontFamily },
|
|
317
|
+
]}>
|
|
318
|
+
{t.hour}
|
|
319
|
+
</react_native_1.Text>
|
|
320
|
+
<react_native_1.ScrollView ref={hourScrollRef} showsVerticalScrollIndicator={false} style={styles.pickerScroll}>
|
|
321
|
+
{hours.map((hour) => (<PickerItem key={hour} label={formatTwoDigitNumber(hour)} // Will show ۰۱, ۰۲, etc.
|
|
322
|
+
isSelected={selectedHour === hour} onPress={() => setSelectedHour(hour)}/>))}
|
|
323
|
+
</react_native_1.ScrollView>
|
|
324
|
+
</react_native_1.View>)}
|
|
325
|
+
|
|
326
|
+
{/* Minute Picker */}
|
|
327
|
+
{showTime && (<react_native_1.View style={styles.pickerColumn}>
|
|
328
|
+
<react_native_1.Text style={[
|
|
329
|
+
styles.pickerLabel,
|
|
330
|
+
{ color: colors.textSecondary, fontFamily },
|
|
331
|
+
]}>
|
|
332
|
+
{t.minute}
|
|
333
|
+
</react_native_1.Text>
|
|
334
|
+
<react_native_1.ScrollView ref={minuteScrollRef} showsVerticalScrollIndicator={false} style={styles.pickerScroll}>
|
|
335
|
+
{minutes.map((minute) => (<PickerItem key={minute} label={formatTwoDigitNumber(minute)} // Will show ۰۱, ۰۲, etc.
|
|
336
|
+
isSelected={selectedMinute === minute} onPress={() => setSelectedMinute(minute)}/>))}
|
|
337
|
+
</react_native_1.ScrollView>
|
|
338
|
+
</react_native_1.View>)}
|
|
339
|
+
</react_native_1.View>
|
|
340
|
+
</react_native_1.View>
|
|
341
|
+
</react_native_1.View>
|
|
342
|
+
</react_native_1.Modal>);
|
|
343
|
+
}
|
|
344
|
+
const styles = react_native_1.StyleSheet.create({
|
|
345
|
+
overlay: {
|
|
346
|
+
flex: 1,
|
|
347
|
+
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
|
348
|
+
justifyContent: "flex-end",
|
|
349
|
+
},
|
|
350
|
+
container: {
|
|
351
|
+
borderTopLeftRadius: 20,
|
|
352
|
+
borderTopRightRadius: 20,
|
|
353
|
+
maxHeight: "80%",
|
|
354
|
+
},
|
|
355
|
+
header: {
|
|
356
|
+
flexDirection: "row",
|
|
357
|
+
justifyContent: "space-between",
|
|
358
|
+
alignItems: "center",
|
|
359
|
+
paddingHorizontal: 20,
|
|
360
|
+
paddingVertical: 16,
|
|
361
|
+
borderBottomWidth: 1,
|
|
362
|
+
},
|
|
363
|
+
nowButton: {
|
|
364
|
+
paddingHorizontal: 8,
|
|
365
|
+
paddingVertical: 4,
|
|
366
|
+
},
|
|
367
|
+
nowButtonText: {
|
|
368
|
+
fontSize: 14,
|
|
369
|
+
},
|
|
370
|
+
cancelText: {
|
|
371
|
+
fontSize: 16,
|
|
372
|
+
},
|
|
373
|
+
title: {
|
|
374
|
+
fontSize: 18,
|
|
375
|
+
},
|
|
376
|
+
confirmText: {
|
|
377
|
+
fontSize: 16,
|
|
378
|
+
},
|
|
379
|
+
pickersContainer: {
|
|
380
|
+
flexDirection: "row",
|
|
381
|
+
padding: 16,
|
|
382
|
+
gap: 12,
|
|
383
|
+
},
|
|
384
|
+
pickersContainerRTL: {
|
|
385
|
+
flexDirection: "row-reverse",
|
|
386
|
+
},
|
|
387
|
+
pickerColumn: {
|
|
388
|
+
flex: 1,
|
|
389
|
+
height: 250,
|
|
390
|
+
},
|
|
391
|
+
pickerScroll: {
|
|
392
|
+
flex: 1,
|
|
393
|
+
},
|
|
394
|
+
pickerLabel: {
|
|
395
|
+
fontSize: 12,
|
|
396
|
+
textAlign: "center",
|
|
397
|
+
marginBottom: 8,
|
|
398
|
+
opacity: 0.8,
|
|
399
|
+
},
|
|
400
|
+
pickerItem: {
|
|
401
|
+
paddingVertical: 12,
|
|
402
|
+
alignItems: "center",
|
|
403
|
+
justifyContent: "center",
|
|
404
|
+
height: 44,
|
|
405
|
+
},
|
|
406
|
+
pickerItemText: {
|
|
407
|
+
fontSize: 14,
|
|
408
|
+
textAlign: "center",
|
|
409
|
+
},
|
|
410
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "expo-persian-date-wheel",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A beautiful, customizable Persian/Jalali date and time wheel picker for Expo and React Native",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"prepare": "npm run build"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"expo",
|
|
13
|
+
"react-native",
|
|
14
|
+
"persian",
|
|
15
|
+
"jalali",
|
|
16
|
+
"datepicker",
|
|
17
|
+
"datetimepicker",
|
|
18
|
+
"farsi",
|
|
19
|
+
"ir",
|
|
20
|
+
"calendar",
|
|
21
|
+
"persian-calendar",
|
|
22
|
+
"date-picker"
|
|
23
|
+
],
|
|
24
|
+
"author": "Ali Sabet",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "https://github.com/alisabet95/expo-persian-date-wheel"
|
|
29
|
+
},
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/alisabet95/expo-persian-date-wheel/issues"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://github.com/alisabet95/expo-persian-date-wheel#readme",
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"moment-jalaali": ">=0.9.0",
|
|
36
|
+
"react": ">=16.8.0",
|
|
37
|
+
"react-native": ">=0.60.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/moment-jalaali": "^0.7.9",
|
|
41
|
+
"@types/react": "^19.2.17",
|
|
42
|
+
"typescript": "^6.0.3"
|
|
43
|
+
}
|
|
44
|
+
}
|