react-native-bikram-sambat 0.1.2 → 0.1.3
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/CHANGELOG.md +13 -0
- package/CONTRIBUTING.md +39 -0
- package/LICENSE +1 -1
- package/README.md +181 -19
- package/package.json +22 -7
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on Keep a Changelog and this project follows Semantic Versioning.
|
|
6
|
+
|
|
7
|
+
## [0.1.2] - 2026-05-16
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
- Improved npm metadata for discoverability and package SEO.
|
|
12
|
+
- Rewrote the README with production-ready documentation, badges, and accurate usage examples.
|
|
13
|
+
- Added contribution guidance, changelog tracking, and GitHub issue templates.
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thank you for contributing to `react-native-bikram-sambat`.
|
|
4
|
+
|
|
5
|
+
## Development Setup
|
|
6
|
+
|
|
7
|
+
1. Clone the repository.
|
|
8
|
+
2. Install dependencies:
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
npm install
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
3. Run the main validation steps:
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
npm run typecheck
|
|
18
|
+
npm test
|
|
19
|
+
npm run build
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Contribution Guidelines
|
|
23
|
+
|
|
24
|
+
- Keep public APIs backward compatible unless a breaking change is clearly discussed.
|
|
25
|
+
- Add or update tests when changing exported behavior.
|
|
26
|
+
- Keep README examples aligned with the actual exported API.
|
|
27
|
+
- Avoid adding dependencies unless they are necessary for the package.
|
|
28
|
+
- Keep commits focused and easy to review.
|
|
29
|
+
|
|
30
|
+
## Pull Requests
|
|
31
|
+
|
|
32
|
+
- Describe the problem and the proposed fix clearly.
|
|
33
|
+
- Include screenshots or usage examples when changing UI behavior.
|
|
34
|
+
- Mention any changes to exports, documentation, or package metadata.
|
|
35
|
+
|
|
36
|
+
## Issues
|
|
37
|
+
|
|
38
|
+
- Use the bug report template for incorrect behavior, crashes, or packaging problems.
|
|
39
|
+
- Use the feature request template for new APIs, components, or enhancements.
|
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,12 +1,39 @@
|
|
|
1
|
-
#
|
|
1
|
+
# React Native Bikram Sambat Calendar, Nepali Date Picker, and AD to BS Converter
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
4
7
|
|
|
5
|
-
`react-native-bikram-sambat`
|
|
8
|
+
`react-native-bikram-sambat` is a TypeScript React Native calendar package for building Nepali calendar experiences in mobile apps. It combines a React Native Bikram Sambat calendar UI, a Nepali date picker, and reliable Nepali date conversion helpers for AD to BS conversion and BS to AD conversion.
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
If you need a Nepali calendar for React Native, a Bikram Sambat calendar component, or an AD to BS converter for app logic, this package gives you both the UI layer and the core date engine in one place. It is designed for teams that want production-ready Bikram Sambat and Nepali date conversion support without maintaining custom date tables and picker components themselves.
|
|
8
11
|
|
|
9
|
-
|
|
12
|
+
## Features
|
|
13
|
+
|
|
14
|
+
- React Native Bikram Sambat calendar component
|
|
15
|
+
- Nepali date picker and range picker components
|
|
16
|
+
- AD to BS converter and BS to AD converter helpers
|
|
17
|
+
- Bikram Sambat calendar month grid generation
|
|
18
|
+
- Nepali date conversion utilities for formatting, parsing, validation, and arithmetic
|
|
19
|
+
- English and Nepali locale support
|
|
20
|
+
- Latin and Devanagari numeral support
|
|
21
|
+
- TypeScript-first exports and generated declaration files
|
|
22
|
+
- Theme overrides, dark mode support, and accessibility-friendly interactions
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
npm install react-native-bikram-sambat
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
or
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
yarn add react-native-bikram-sambat
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Quick Start
|
|
10
37
|
|
|
11
38
|
```tsx
|
|
12
39
|
import React, { useState } from 'react';
|
|
@@ -33,7 +60,73 @@ export default function App() {
|
|
|
33
60
|
}
|
|
34
61
|
```
|
|
35
62
|
|
|
36
|
-
|
|
63
|
+
## AD to BS Example
|
|
64
|
+
|
|
65
|
+
Use the built-in AD to BS converter when you need to convert a Gregorian date to a Bikram Sambat date.
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
import { toBS } from 'react-native-bikram-sambat';
|
|
69
|
+
|
|
70
|
+
const bsDate = toBS({
|
|
71
|
+
calendar: 'AD',
|
|
72
|
+
year: 2024,
|
|
73
|
+
month: 4,
|
|
74
|
+
day: 13,
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
// Example result shape:
|
|
78
|
+
// { calendar: 'BS', year: 2081, month: 1, day: 1 }
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## BS to AD Example
|
|
82
|
+
|
|
83
|
+
Use the BS to AD converter when your app stores Bikram Sambat values and needs Gregorian output.
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
import { toAD } from 'react-native-bikram-sambat';
|
|
87
|
+
|
|
88
|
+
const adDate = toAD({
|
|
89
|
+
calendar: 'BS',
|
|
90
|
+
year: 2081,
|
|
91
|
+
month: 1,
|
|
92
|
+
day: 1,
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// Example result shape:
|
|
96
|
+
// { calendar: 'AD', year: 2024, month: 4, day: 13 }
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## React Native Date Picker Example
|
|
100
|
+
|
|
101
|
+
```tsx
|
|
102
|
+
import React, { useState } from 'react';
|
|
103
|
+
import { SafeAreaView } from 'react-native';
|
|
104
|
+
import {
|
|
105
|
+
NepaliDatePicker,
|
|
106
|
+
type BSDateValue,
|
|
107
|
+
} from 'react-native-bikram-sambat';
|
|
108
|
+
|
|
109
|
+
export default function App() {
|
|
110
|
+
const [selectedDate, setSelectedDate] = useState<BSDateValue | null>(null);
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<SafeAreaView style={{ flex: 1, padding: 16 }}>
|
|
114
|
+
<NepaliDatePicker
|
|
115
|
+
value={selectedDate}
|
|
116
|
+
onChange={setSelectedDate}
|
|
117
|
+
placeholder="Choose a BS date"
|
|
118
|
+
displayFormat="yyyy-MM-dd"
|
|
119
|
+
locale="en"
|
|
120
|
+
numerals="latin"
|
|
121
|
+
/>
|
|
122
|
+
</SafeAreaView>
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## More Usage Examples
|
|
128
|
+
|
|
129
|
+
### Inline Bikram Sambat calendar
|
|
37
130
|
|
|
38
131
|
```tsx
|
|
39
132
|
import React, { useState } from 'react';
|
|
@@ -47,14 +140,19 @@ export default function App() {
|
|
|
47
140
|
const [date, setDate] = useState<BSDateValue | null>(null);
|
|
48
141
|
|
|
49
142
|
return (
|
|
50
|
-
<SafeAreaView style={{ flex: 1 }}>
|
|
51
|
-
<NepaliCalendar
|
|
143
|
+
<SafeAreaView style={{ flex: 1, padding: 16 }}>
|
|
144
|
+
<NepaliCalendar
|
|
145
|
+
value={date}
|
|
146
|
+
onChange={setDate}
|
|
147
|
+
locale="ne"
|
|
148
|
+
numerals="devanagari"
|
|
149
|
+
/>
|
|
52
150
|
</SafeAreaView>
|
|
53
151
|
);
|
|
54
152
|
}
|
|
55
153
|
```
|
|
56
154
|
|
|
57
|
-
###
|
|
155
|
+
### Nepali date range picker
|
|
58
156
|
|
|
59
157
|
```tsx
|
|
60
158
|
import React, { useState } from 'react';
|
|
@@ -76,36 +174,100 @@ export default function App() {
|
|
|
76
174
|
value={range}
|
|
77
175
|
onChange={setRange}
|
|
78
176
|
placeholder="Select date range"
|
|
79
|
-
locale="ne"
|
|
80
|
-
numerals="devanagari"
|
|
81
177
|
/>
|
|
82
178
|
</SafeAreaView>
|
|
83
179
|
);
|
|
84
180
|
}
|
|
85
181
|
```
|
|
86
182
|
|
|
87
|
-
###
|
|
183
|
+
### Formatting and parsing Nepali dates
|
|
88
184
|
|
|
89
185
|
```ts
|
|
90
186
|
import {
|
|
91
|
-
toBS,
|
|
92
|
-
toAD,
|
|
93
187
|
formatBS,
|
|
94
188
|
parseBS,
|
|
95
189
|
toNepaliNumerals,
|
|
96
190
|
toLatinNumerals,
|
|
97
191
|
} from 'react-native-bikram-sambat';
|
|
98
192
|
|
|
99
|
-
const
|
|
100
|
-
const ad = toAD({ calendar: 'BS', year: 2081, month: 1, day: 1 });
|
|
193
|
+
const date = { calendar: 'BS', year: 2081, month: 1, day: 5 } as const;
|
|
101
194
|
|
|
102
|
-
const
|
|
103
|
-
const
|
|
195
|
+
const isoLike = formatBS(date, 'yyyy-MM-dd');
|
|
196
|
+
const nepaliFormatted = formatBS(date, 'dd MMMM yyyy', {
|
|
197
|
+
locale: 'ne',
|
|
198
|
+
numerals: 'devanagari',
|
|
199
|
+
});
|
|
104
200
|
|
|
201
|
+
const parsed = parseBS('2081-01-05', 'yyyy-MM-dd');
|
|
105
202
|
const devanagari = toNepaliNumerals('2081');
|
|
106
203
|
const latin = toLatinNumerals('२०८१');
|
|
107
204
|
```
|
|
108
205
|
|
|
109
|
-
##
|
|
206
|
+
## API Reference
|
|
207
|
+
|
|
208
|
+
### Components
|
|
209
|
+
|
|
210
|
+
- `NepaliCalendar`: Inline Bikram Sambat calendar component for React Native
|
|
211
|
+
- `NepaliDatePicker`: Pressable Nepali date picker input with modal calendar
|
|
212
|
+
- `DatePickerModal`: Controlled date picker modal component
|
|
213
|
+
- `NepaliRangePicker`: Range picker input for selecting start and end BS dates
|
|
214
|
+
- `RangePickerModal`: Controlled range picker modal component
|
|
215
|
+
|
|
216
|
+
### Conversion and formatting
|
|
217
|
+
|
|
218
|
+
- `toBS`: Convert an AD date to a BS date
|
|
219
|
+
- `toAD`: Convert a BS date to an AD date
|
|
220
|
+
- `formatBS`: Format a BS date using supported tokens
|
|
221
|
+
- `parseBS`: Parse a BS date string using the supported `yyyy-MM-dd` pattern
|
|
222
|
+
- `toNepaliNumerals`: Convert Latin digits to Devanagari digits
|
|
223
|
+
- `toLatinNumerals`: Convert Devanagari digits to Latin digits
|
|
224
|
+
|
|
225
|
+
### Validation and helpers
|
|
226
|
+
|
|
227
|
+
- `isValidBSDate`
|
|
228
|
+
- `isValidADDate`
|
|
229
|
+
- `isBSDateInSupportedRange`
|
|
230
|
+
- `getSupportedBSRange`
|
|
231
|
+
- `createBSDateKey`
|
|
232
|
+
- `parseBSDateKey`
|
|
233
|
+
- `compareBS`
|
|
234
|
+
- `addBSDays`
|
|
235
|
+
- `subBSDays`
|
|
236
|
+
- `todayBS`
|
|
237
|
+
- `getCalendarMonthGrid`
|
|
238
|
+
|
|
239
|
+
## Use Cases
|
|
240
|
+
|
|
241
|
+
- Building a Nepali date picker in a React Native checkout, booking, or profile flow
|
|
242
|
+
- Showing a Bikram Sambat calendar in education, finance, HR, government, or scheduling apps
|
|
243
|
+
- Converting user-entered Gregorian dates with an AD to BS converter
|
|
244
|
+
- Converting stored BS values to Gregorian dates with a BS to AD converter
|
|
245
|
+
- Supporting Nepali date conversion and display in apps for users in Nepal
|
|
246
|
+
- Adding a TypeScript React Native calendar package to an Expo or React Native CLI codebase
|
|
247
|
+
|
|
248
|
+
## Why Use This Package?
|
|
249
|
+
|
|
250
|
+
- It gives you a single package for both Nepali date conversion and React Native UI components.
|
|
251
|
+
- It reduces maintenance compared with rolling your own Bikram Sambat calendar logic.
|
|
252
|
+
- It keeps TypeScript types close to the public API for better editor support and safer integration.
|
|
253
|
+
- It supports theming, locales, numerals, and accessibility so teams can ship a more polished Nepali calendar for React Native.
|
|
254
|
+
|
|
255
|
+
## TypeScript Support
|
|
256
|
+
|
|
257
|
+
This package is built with TypeScript and publishes declaration files via the `types` field. Public types include `BSDateValue`, `ADDateValue`, `DateRangeValue`, `NepaliCalendarProps`, `NepaliDatePickerProps`, `RangePickerModalProps`, and theme-related types.
|
|
258
|
+
|
|
259
|
+
## Expo and React Native CLI Compatibility
|
|
260
|
+
|
|
261
|
+
This package currently appears suitable for both Expo-managed and React Native CLI projects because the published source is JavaScript and TypeScript only and does not define custom native modules. You should still test your target screens in your own app, especially if you rely on specific React Native versions, theming constraints, or accessibility requirements.
|
|
262
|
+
|
|
263
|
+
## Preview
|
|
110
264
|
|
|
111
265
|

|
|
266
|
+
|
|
267
|
+
## Contributing
|
|
268
|
+
|
|
269
|
+
Contributions are welcome. Please open an issue for bugs, feature requests, or API discussions before large changes, and see [CONTRIBUTING.md](./CONTRIBUTING.md) for local setup and contribution guidance.
|
|
270
|
+
|
|
271
|
+
## License
|
|
272
|
+
|
|
273
|
+
MIT. See [LICENSE](./LICENSE).
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-bikram-sambat",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"description": "React Native Bikram Sambat calendar and Nepali date picker with AD to BS converter, BS to AD converter, and TypeScript support.",
|
|
5
5
|
"main": "./lib/commonjs/index.js",
|
|
6
6
|
"module": "./lib/module/index.js",
|
|
7
7
|
"types": "./lib/typescript/src/index.d.ts",
|
|
@@ -38,20 +38,35 @@
|
|
|
38
38
|
"!lib/**/*.test.d.ts.map",
|
|
39
39
|
"docs/screenshots",
|
|
40
40
|
"README.md",
|
|
41
|
+
"CHANGELOG.md",
|
|
42
|
+
"CONTRIBUTING.md",
|
|
41
43
|
"LICENSE"
|
|
42
44
|
],
|
|
43
45
|
"keywords": [
|
|
44
46
|
"react-native",
|
|
47
|
+
"react native",
|
|
45
48
|
"bikram-sambat",
|
|
49
|
+
"bikram sambat",
|
|
50
|
+
"bikram-sambat-calendar",
|
|
46
51
|
"nepali-calendar",
|
|
47
|
-
"bs-date",
|
|
48
|
-
"date-picker",
|
|
49
|
-
"calendar",
|
|
50
52
|
"nepali-date",
|
|
53
|
+
"nepali-date-picker",
|
|
54
|
+
"nepali date picker",
|
|
55
|
+
"bs-date",
|
|
56
|
+
"ad-bs",
|
|
57
|
+
"ad-to-bs",
|
|
51
58
|
"bs-to-ad",
|
|
52
|
-
"
|
|
59
|
+
"date-converter",
|
|
60
|
+
"calendar",
|
|
61
|
+
"datepicker",
|
|
62
|
+
"date-picker",
|
|
63
|
+
"nepal",
|
|
64
|
+
"nepali",
|
|
65
|
+
"typescript",
|
|
66
|
+
"react-native-calendar",
|
|
67
|
+
"date-conversion"
|
|
53
68
|
],
|
|
54
|
-
"author": "",
|
|
69
|
+
"author": "jeevandhl <udsjeevan@gmail.com>",
|
|
55
70
|
"license": "MIT",
|
|
56
71
|
"repository": {
|
|
57
72
|
"type": "git",
|