bs-ad-calendar-react 1.0.2 → 1.1.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 +1 -1
- package/README.md +77 -130
- package/dist/bs-ad-calendar.js +120 -112
- package/dist/bs-ad-calendar.umd.cjs +1 -1
- package/package.json +4 -1
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,61 +1,80 @@
|
|
|
1
1
|
# BS-AD Calendar
|
|
2
2
|
|
|
3
|
-
A modern
|
|
3
|
+
A modern React calendar component for seamless conversion between **Bikram Sambat (BS)** and **Gregorian (AD)** calendars.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/bs-ad-calendar-react)
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
|
7
7
|
|
|
8
|
-
##
|
|
8
|
+
## Live Demo
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
[View Demo](https://bibekamatya.github.io/bs-ad-calendar/)
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
🎨 **Customizable Themes** - Light/dark themes with custom color support
|
|
14
|
-
📅 **Date & Range Selection** - Single date or date range selection modes
|
|
15
|
-
🌏 **Localization** - Nepali months, days, and number support
|
|
16
|
-
⌨️ **Keyboard Navigation** - Full keyboard accessibility
|
|
17
|
-
📱 **Responsive Design** - Works on all screen sizes
|
|
18
|
-
🎯 **DatePicker Component** - Input field with popup calendar
|
|
19
|
-
🔧 **TypeScript** - Full type definitions included
|
|
20
|
-
♿ **Accessible** - ARIA labels and keyboard navigation
|
|
12
|
+
## Key Feature
|
|
21
13
|
|
|
22
|
-
|
|
14
|
+
**Select any date → Get both BS and AD dates automatically**
|
|
23
15
|
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
When you click a date on either calendar, you instantly receive both the BS and AD equivalents with formatted output.
|
|
17
|
+
|
|
18
|
+
**Example Output:**
|
|
26
19
|
```
|
|
20
|
+
Input: Click on Poush 15, 2081 (BS Calendar)
|
|
27
21
|
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
Output:
|
|
23
|
+
{
|
|
24
|
+
bs: "2081-09-15",
|
|
25
|
+
ad: "2024-12-31",
|
|
26
|
+
formatted: {
|
|
27
|
+
bs: "Poush 15, 2081",
|
|
28
|
+
ad: "December 31, 2024"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
30
31
|
```
|
|
31
32
|
|
|
33
|
+
## Features
|
|
34
|
+
|
|
35
|
+
- Automatic dual calendar conversion
|
|
36
|
+
- Single date and range selection modes
|
|
37
|
+
- Customizable themes (light/dark)
|
|
38
|
+
- Nepali localization support
|
|
39
|
+
- Full keyboard navigation
|
|
40
|
+
- Responsive design
|
|
41
|
+
- Complete TypeScript support
|
|
42
|
+
- Accessible (ARIA labels)
|
|
43
|
+
|
|
44
|
+
## Installation
|
|
45
|
+
|
|
32
46
|
```bash
|
|
33
|
-
|
|
47
|
+
npm install bs-ad-calendar-react
|
|
34
48
|
```
|
|
35
49
|
|
|
36
50
|
## Quick Start
|
|
37
51
|
|
|
38
|
-
### Basic
|
|
52
|
+
### Basic Usage
|
|
39
53
|
|
|
40
54
|
```tsx
|
|
41
55
|
import { Calendar } from 'bs-ad-calendar-react'
|
|
42
56
|
|
|
43
|
-
function App() {
|
|
57
|
+
export default function App() {
|
|
44
58
|
return (
|
|
45
59
|
<Calendar
|
|
46
60
|
calendarType="BS"
|
|
47
|
-
onDateSelect={(date) =>
|
|
61
|
+
onDateSelect={(date) => {
|
|
62
|
+
console.log(date.bs) // "2081-09-15"
|
|
63
|
+
console.log(date.ad) // "2024-12-31"
|
|
64
|
+
console.log(date.formatted.bs) // "Poush 15, 2081"
|
|
65
|
+
console.log(date.formatted.ad) // "December 31, 2024"
|
|
66
|
+
}}
|
|
48
67
|
/>
|
|
49
68
|
)
|
|
50
69
|
}
|
|
51
70
|
```
|
|
52
71
|
|
|
53
|
-
### DatePicker
|
|
72
|
+
### DatePicker Input
|
|
54
73
|
|
|
55
74
|
```tsx
|
|
56
75
|
import { DatePicker } from 'bs-ad-calendar-react'
|
|
57
76
|
|
|
58
|
-
function App() {
|
|
77
|
+
export default function App() {
|
|
59
78
|
return (
|
|
60
79
|
<DatePicker
|
|
61
80
|
calendarType="AD"
|
|
@@ -71,7 +90,7 @@ function App() {
|
|
|
71
90
|
```tsx
|
|
72
91
|
import { Calendar } from 'bs-ad-calendar-react'
|
|
73
92
|
|
|
74
|
-
function App() {
|
|
93
|
+
export default function App() {
|
|
75
94
|
return (
|
|
76
95
|
<Calendar
|
|
77
96
|
calendarType="BS"
|
|
@@ -91,71 +110,45 @@ function App() {
|
|
|
91
110
|
|------|------|---------|-------------|
|
|
92
111
|
| `calendarType` | `'BS' \| 'AD'` | `'AD'` | Calendar type |
|
|
93
112
|
| `mode` | `'single' \| 'range'` | `'single'` | Selection mode |
|
|
94
|
-
| `onDateSelect` | `(date: DateOutput) => void` | - |
|
|
113
|
+
| `onDateSelect` | `(date: DateOutput) => void` | - | Date selection callback |
|
|
95
114
|
| `onRangeSelect` | `(range: DateRange) => void` | - | Range selection callback |
|
|
96
|
-
| `showToday` | `boolean` | `true` | Highlight today
|
|
97
|
-
| `disabled` | `boolean` | `false` | Disable
|
|
98
|
-
| `minDate` | `string` | - |
|
|
99
|
-
| `maxDate` | `string` | - |
|
|
100
|
-
| `theme` | `'light' \| 'dark'
|
|
101
|
-
| `colors` | `ColorConfig` | - | Custom
|
|
102
|
-
| `showNepaliMonths` | `boolean` | `false` |
|
|
103
|
-
| `showNepaliDays` | `boolean` | `false` |
|
|
104
|
-
| `showNepaliNumbers` | `boolean` | `false` |
|
|
105
|
-
| `showRangePresets` | `boolean` | `false` | Show
|
|
106
|
-
| `rangePresetsPosition` | `'top' \| 'left'` | `'top'` | Position of range presets |
|
|
107
|
-
| `className` | `string` | - | Additional CSS class |
|
|
115
|
+
| `showToday` | `boolean` | `true` | Highlight today |
|
|
116
|
+
| `disabled` | `boolean` | `false` | Disable interaction |
|
|
117
|
+
| `minDate` | `string` | - | Min selectable date |
|
|
118
|
+
| `maxDate` | `string` | - | Max selectable date |
|
|
119
|
+
| `theme` | `'light' \| 'dark'` | `'light'` | Theme variant |
|
|
120
|
+
| `colors` | `ColorConfig` | - | Custom colors |
|
|
121
|
+
| `showNepaliMonths` | `boolean` | `false` | Nepali month names |
|
|
122
|
+
| `showNepaliDays` | `boolean` | `false` | Nepali day names |
|
|
123
|
+
| `showNepaliNumbers` | `boolean` | `false` | Nepali numerals |
|
|
124
|
+
| `showRangePresets` | `boolean` | `false` | Show preset buttons |
|
|
108
125
|
|
|
109
126
|
### DatePicker Props
|
|
110
127
|
|
|
111
|
-
Extends
|
|
128
|
+
Extends Calendar props plus:
|
|
112
129
|
|
|
113
130
|
| Prop | Type | Default | Description |
|
|
114
131
|
|------|------|---------|-------------|
|
|
115
|
-
| `placeholder` | `string` | `'Select date'` | Input placeholder
|
|
116
|
-
| `inputClassName` | `string` | - | Input
|
|
117
|
-
| `popupClassName` | `string` | - | Popup
|
|
118
|
-
|
|
119
|
-
### Color Configuration
|
|
120
|
-
|
|
121
|
-
```tsx
|
|
122
|
-
colors={{
|
|
123
|
-
primary: '#3b82f6', // Primary accent color
|
|
124
|
-
selected: '#3b82f6', // Selected date background
|
|
125
|
-
today: '#dbeafe', // Today's date background
|
|
126
|
-
hover: '#eff6ff', // Hover state background
|
|
127
|
-
background: '#ffffff', // Calendar background
|
|
128
|
-
text: '#1f2937', // Text color
|
|
129
|
-
border: '#e5e7eb', // Border color
|
|
130
|
-
disabled: '#d1d5db' // Disabled date color
|
|
131
|
-
}}
|
|
132
|
-
```
|
|
132
|
+
| `placeholder` | `string` | `'Select date'` | Input placeholder |
|
|
133
|
+
| `inputClassName` | `string` | - | Input CSS class |
|
|
134
|
+
| `popupClassName` | `string` | - | Popup CSS class |
|
|
133
135
|
|
|
134
|
-
###
|
|
136
|
+
### Output Format
|
|
135
137
|
|
|
136
138
|
```tsx
|
|
137
139
|
{
|
|
138
|
-
bs: "2081-09-15",
|
|
139
|
-
ad: "2024-12-31",
|
|
140
|
+
bs: "2081-09-15",
|
|
141
|
+
ad: "2024-12-31",
|
|
140
142
|
formatted: {
|
|
141
|
-
bs: "Poush 15, 2081",
|
|
142
|
-
ad: "December 31, 2024"
|
|
143
|
+
bs: "Poush 15, 2081",
|
|
144
|
+
ad: "December 31, 2024"
|
|
143
145
|
}
|
|
144
146
|
}
|
|
145
147
|
```
|
|
146
148
|
|
|
147
|
-
### Range Output Format
|
|
148
|
-
|
|
149
|
-
```tsx
|
|
150
|
-
{
|
|
151
|
-
start: { year: 2081, month: 8, day: 1 },
|
|
152
|
-
end: { year: 2081, month: 8, day: 30 }
|
|
153
|
-
}
|
|
154
|
-
```
|
|
155
|
-
|
|
156
149
|
## Examples
|
|
157
150
|
|
|
158
|
-
### Custom
|
|
151
|
+
### Custom Theme
|
|
159
152
|
|
|
160
153
|
```tsx
|
|
161
154
|
<Calendar
|
|
@@ -163,8 +156,7 @@ colors={{
|
|
|
163
156
|
colors={{
|
|
164
157
|
primary: '#10b981',
|
|
165
158
|
selected: '#059669',
|
|
166
|
-
today: '#d1fae5'
|
|
167
|
-
hover: '#ecfdf5'
|
|
159
|
+
today: '#d1fae5'
|
|
168
160
|
}}
|
|
169
161
|
onDateSelect={(date) => console.log(date)}
|
|
170
162
|
/>
|
|
@@ -182,86 +174,41 @@ colors={{
|
|
|
182
174
|
/>
|
|
183
175
|
```
|
|
184
176
|
|
|
185
|
-
### Date
|
|
186
|
-
|
|
187
|
-
```tsx
|
|
188
|
-
<Calendar
|
|
189
|
-
calendarType="AD"
|
|
190
|
-
minDate="2024-01-01"
|
|
191
|
-
maxDate="2024-12-31"
|
|
192
|
-
onDateSelect={(date) => console.log(date)}
|
|
193
|
-
/>
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
### Dark Theme
|
|
197
|
-
|
|
198
|
-
```tsx
|
|
199
|
-
<Calendar
|
|
200
|
-
calendarType="BS"
|
|
201
|
-
theme="dark"
|
|
202
|
-
onDateSelect={(date) => console.log(date)}
|
|
203
|
-
/>
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
### Custom Range Presets
|
|
177
|
+
### Date Range
|
|
207
178
|
|
|
208
179
|
```tsx
|
|
209
180
|
<Calendar
|
|
210
181
|
calendarType="BS"
|
|
211
182
|
mode="range"
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
{
|
|
215
|
-
label: 'This Month',
|
|
216
|
-
key: 'this-month',
|
|
217
|
-
getValue: (type) => ({
|
|
218
|
-
start: { year: 2081, month: 8, day: 1 },
|
|
219
|
-
end: { year: 2081, month: 8, day: 30 }
|
|
220
|
-
})
|
|
221
|
-
}
|
|
222
|
-
]}
|
|
183
|
+
minDate="2024-01-01"
|
|
184
|
+
maxDate="2024-12-31"
|
|
223
185
|
onRangeSelect={(range) => console.log(range)}
|
|
224
186
|
/>
|
|
225
187
|
```
|
|
226
188
|
|
|
227
189
|
## Keyboard Navigation
|
|
228
190
|
|
|
229
|
-
-
|
|
230
|
-
-
|
|
231
|
-
-
|
|
232
|
-
-
|
|
233
|
-
- **Tab**: Navigate between interactive elements
|
|
191
|
+
- Arrow Left/Right - Navigate months
|
|
192
|
+
- Arrow Up/Down - Navigate years
|
|
193
|
+
- PageUp/PageDown - Navigate months
|
|
194
|
+
- Shift + PageUp/PageDown - Navigate years
|
|
234
195
|
|
|
235
196
|
## Browser Support
|
|
236
197
|
|
|
237
|
-
|
|
238
|
-
- Firefox (latest)
|
|
239
|
-
- Safari (latest)
|
|
240
|
-
- Edge (latest)
|
|
198
|
+
Chrome, Firefox, Safari, Edge (latest versions)
|
|
241
199
|
|
|
242
200
|
## TypeScript
|
|
243
201
|
|
|
244
|
-
Full TypeScript support with exported types:
|
|
245
|
-
|
|
246
202
|
```tsx
|
|
247
|
-
import type {
|
|
248
|
-
DateInfo,
|
|
249
|
-
DateRange,
|
|
250
|
-
DateOutput,
|
|
251
|
-
CalendarProps
|
|
252
|
-
} from 'bs-ad-calendar-react'
|
|
203
|
+
import type { DateOutput, DateRange, CalendarProps } from 'bs-ad-calendar-react'
|
|
253
204
|
```
|
|
254
205
|
|
|
255
|
-
## Contributing
|
|
256
|
-
|
|
257
|
-
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
258
|
-
|
|
259
206
|
## License
|
|
260
207
|
|
|
261
208
|
MIT © [Bibek Amatya](https://github.com/bibekamatya)
|
|
262
209
|
|
|
263
210
|
## Links
|
|
264
211
|
|
|
265
|
-
- [GitHub
|
|
266
|
-
- [NPM
|
|
267
|
-
- [
|
|
212
|
+
- [GitHub](https://github.com/bibekamatya/bs-ad-calendar)
|
|
213
|
+
- [NPM](https://www.npmjs.com/package/bs-ad-calendar-react)
|
|
214
|
+
- [Demo](https://bibekamatya.github.io/bs-ad-calendar/)
|