react-native-bikram-sambat 0.1.1 → 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 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.
@@ -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
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2026
3
+ Copyright (c) 2026 jeevandhl
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,8 +1,25 @@
1
- # react-native-bikram-sambat
1
+ # React Native Bikram Sambat Calendar, Nepali Date Picker, and AD to BS Converter
2
2
 
3
- A production-grade Bikram Sambat (BS) calendar engine and React Native date picker for React Native.
3
+ ![npm](https://img.shields.io/npm/v/react-native-bikram-sambat)
4
+ ![downloads](https://img.shields.io/npm/dm/react-native-bikram-sambat)
5
+ ![license](https://img.shields.io/npm/l/react-native-bikram-sambat)
6
+ ![types](https://img.shields.io/npm/types/react-native-bikram-sambat)
4
7
 
5
- TypeScript-first helpers for BS/AD conversion, formatting, parsing, and calendar grid generation, plus ready-to-use React Native UI components with theming, dark mode, and accessibility.
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.
9
+
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.
11
+
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
6
23
 
7
24
  ## Installation
8
25
 
@@ -18,16 +35,12 @@ yarn add react-native-bikram-sambat
18
35
 
19
36
  ## Quick Start
20
37
 
21
- ### Date Picker
22
-
23
- The simplest way to let users pick a BS date:
24
-
25
38
  ```tsx
26
39
  import React, { useState } from 'react';
27
40
  import { SafeAreaView } from 'react-native';
28
41
  import {
29
42
  NepaliDatePicker,
30
- type BSDateValue
43
+ type BSDateValue,
31
44
  } from 'react-native-bikram-sambat';
32
45
 
33
46
  export default function App() {
@@ -47,83 +60,90 @@ export default function App() {
47
60
  }
48
61
  ```
49
62
 
50
- ### Calendar Component
63
+ ## AD to BS Example
51
64
 
52
- For inline calendar display:
65
+ Use the built-in AD to BS converter when you need to convert a Gregorian date to a Bikram Sambat date.
53
66
 
54
- ```tsx
55
- import React, { useState } from 'react';
56
- import { SafeAreaView } from 'react-native';
57
- import { NepaliCalendar, type BSDateValue } from 'react-native-bikram-sambat';
67
+ ```ts
68
+ import { toBS } from 'react-native-bikram-sambat';
58
69
 
59
- export default function App() {
60
- const [date, setDate] = useState<BSDateValue | null>(null);
70
+ const bsDate = toBS({
71
+ calendar: 'AD',
72
+ year: 2024,
73
+ month: 4,
74
+ day: 13,
75
+ });
61
76
 
62
- return (
63
- <SafeAreaView style={{ flex: 1 }}>
64
- <NepaliCalendar value={date} onChange={setDate} />
65
- </SafeAreaView>
66
- );
67
- }
77
+ // Example result shape:
78
+ // { calendar: 'BS', year: 2081, month: 1, day: 1 }
68
79
  ```
69
80
 
70
- ### Date Picker Modal
81
+ ## BS to AD Example
82
+
83
+ Use the BS to AD converter when your app stores Bikram Sambat values and needs Gregorian output.
71
84
 
72
- For custom modal control:
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
73
100
 
74
101
  ```tsx
75
102
  import React, { useState } from 'react';
76
- import { Button, SafeAreaView } from 'react-native';
103
+ import { SafeAreaView } from 'react-native';
77
104
  import {
78
- DatePickerModal,
79
- type BSDateValue
105
+ NepaliDatePicker,
106
+ type BSDateValue,
80
107
  } from 'react-native-bikram-sambat';
81
108
 
82
109
  export default function App() {
83
- const [visible, setVisible] = useState(false);
84
- const [date, setDate] = useState<BSDateValue | null>(null);
110
+ const [selectedDate, setSelectedDate] = useState<BSDateValue | null>(null);
85
111
 
86
112
  return (
87
113
  <SafeAreaView style={{ flex: 1, padding: 16 }}>
88
- <Button title="Open date picker" onPress={() => setVisible(true)} />
89
-
90
- <DatePickerModal
91
- visible={visible}
92
- value={date}
93
- onChange={setDate}
94
- onClose={() => setVisible(false)}
95
- locale="ne"
96
- numerals="devanagari"
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"
97
121
  />
98
122
  </SafeAreaView>
99
123
  );
100
124
  }
101
125
  ```
102
126
 
103
- ### Range Picker
127
+ ## More Usage Examples
104
128
 
105
- For selecting a date range:
129
+ ### Inline Bikram Sambat calendar
106
130
 
107
131
  ```tsx
108
132
  import React, { useState } from 'react';
109
133
  import { SafeAreaView } from 'react-native';
110
134
  import {
111
- NepaliRangePicker,
112
- type DateRangeValue
135
+ NepaliCalendar,
136
+ type BSDateValue,
113
137
  } from 'react-native-bikram-sambat';
114
138
 
115
139
  export default function App() {
116
- const [range, setRange] = useState<DateRangeValue>({
117
- start: null,
118
- end: null,
119
- });
140
+ const [date, setDate] = useState<BSDateValue | null>(null);
120
141
 
121
142
  return (
122
143
  <SafeAreaView style={{ flex: 1, padding: 16 }}>
123
- <NepaliRangePicker
124
- value={range}
125
- onChange={setRange}
126
- placeholder="Select date range"
144
+ <NepaliCalendar
145
+ value={date}
146
+ onChange={setDate}
127
147
  locale="ne"
128
148
  numerals="devanagari"
129
149
  />
@@ -132,20 +152,17 @@ export default function App() {
132
152
  }
133
153
  ```
134
154
 
135
- ### Range Picker Modal
136
-
137
- For custom range picker modal control:
155
+ ### Nepali date range picker
138
156
 
139
157
  ```tsx
140
158
  import React, { useState } from 'react';
141
- import { Button, SafeAreaView } from 'react-native';
159
+ import { SafeAreaView } from 'react-native';
142
160
  import {
143
- RangePickerModal,
144
- type DateRangeValue
161
+ NepaliRangePicker,
162
+ type DateRangeValue,
145
163
  } from 'react-native-bikram-sambat';
146
164
 
147
165
  export default function App() {
148
- const [visible, setVisible] = useState(false);
149
166
  const [range, setRange] = useState<DateRangeValue>({
150
167
  start: null,
151
168
  end: null,
@@ -153,206 +170,104 @@ export default function App() {
153
170
 
154
171
  return (
155
172
  <SafeAreaView style={{ flex: 1, padding: 16 }}>
156
- <Button title="Open range picker" onPress={() => setVisible(true)} />
157
-
158
- <RangePickerModal
159
- visible={visible}
173
+ <NepaliRangePicker
160
174
  value={range}
161
175
  onChange={setRange}
162
- onClose={() => setVisible(false)}
163
- locale="ne"
164
- numerals="devanagari"
176
+ placeholder="Select date range"
165
177
  />
166
178
  </SafeAreaView>
167
179
  );
168
180
  }
169
181
  ```
170
182
 
171
- ## Core Utilities
172
-
173
- ### BS ⇄ AD Conversion
174
-
175
- ```ts
176
- import { toBS, toAD, isValidBSDate, isValidADDate } from 'react-native-bikram-sambat';
177
-
178
- const bs = toBS({ calendar: 'AD', year: 2024, month: 4, day: 13 });
179
- const ad = toAD({ calendar: 'BS', year: 2081, month: 1, day: 1 });
180
-
181
- const valid = isValidBSDate({ calendar: 'BS', year: 2081, month: 1, day: 1 });
182
- const validAD = isValidADDate({ calendar: 'AD', year: 2024, month: 4, day: 13 });
183
- ```
184
-
185
- ### Formatting and Parsing
186
-
187
- ```ts
188
- import { formatBS, parseBS, toNepaliNumerals, toLatinNumerals } from 'react-native-bikram-sambat';
189
-
190
- const date = { calendar: 'BS', year: 2081, month: 1, day: 5 };
191
-
192
- formatBS(date, 'yyyy-MM-dd'); // '2081-01-05'
193
- formatBS(date, 'dd MMMM yyyy'); // '05 Baisakh 2081'
194
- formatBS(date, 'dd MMMM yyyy', { locale: 'ne', numerals: 'devanagari' }); // '०५ बैशाख २०८१'
195
-
196
- parseBS('2081-01-05', 'yyyy-MM-dd'); // { calendar: 'BS', year: 2081, month: 1, day: 5 }
197
-
198
- toNepaliNumerals('2081'); // '२०८१'
199
- toLatinNumerals('२०८१'); // '2081'
200
- ```
201
-
202
- ### Date Arithmetic
203
-
204
- ```ts
205
- import { compareBS, addBSDays, subBSDays, todayBS } from 'react-native-bikram-sambat';
206
-
207
- const today = todayBS();
208
- const future = addBSDays(today, 30);
209
- const past = subBSDays(today, 30);
210
- const cmp = compareBS(future, past); // > 0
211
- ```
212
-
213
- ### Date Keys
214
-
215
- ```ts
216
- import { createBSDateKey, parseBSDateKey } from 'react-native-bikram-sambat';
217
-
218
- const key = createBSDateKey({ calendar: 'BS', year: 2081, month: 1, day: 1 });
219
- // '2081-01-01'
220
-
221
- const parsed = parseBSDateKey('2081-01-01');
222
- // { calendar: 'BS', year: 2081, month: 1, day: 1 }
223
- ```
224
-
225
- ### Supported Range
226
-
227
- ```ts
228
- import { getSupportedBSRange, isBSDateInSupportedRange } from 'react-native-bikram-sambat';
229
-
230
- const range = getSupportedBSRange(); // { start: 2081, end: 2081 }
231
- const inRange = isBSDateInSupportedRange({ calendar: 'BS', year: 2081, month: 1, day: 1 });
232
- ```
233
-
234
- ### Calendar Grid
235
-
236
- ```ts
237
- import { getCalendarMonthGrid } from 'react-native-bikram-sambat';
238
-
239
- const grid = getCalendarMonthGrid({
240
- year: 2081,
241
- month: 1,
242
- weekStartsOn: 0, // 0 = Sunday
243
- minDate: { calendar: 'BS', year: 2081, month: 1, day: 1 },
244
- maxDate: { calendar: 'BS', year: 2081, month: 12, day: 30 },
245
- });
246
-
247
- // grid.weeks is a 2D array of cells
248
- ```
249
-
250
- ## TypeScript Usage
251
-
252
- All public APIs are fully typed:
183
+ ### Formatting and parsing Nepali dates
253
184
 
254
185
  ```ts
255
186
  import {
256
- type BSDateValue,
257
- type ADDateValue,
258
- type DateRangeValue,
259
- type CalendarTheme,
260
- type CalendarMarkedDate,
261
- type NepaliCalendarProps,
262
- type NepaliDatePickerProps,
263
- type DatePickerModalProps,
264
- type NepaliRangePickerProps,
265
- type RangePickerModalProps,
266
- type CalendarLocale,
267
- type LocaleCode,
268
- type NumeralSystem,
187
+ formatBS,
188
+ parseBS,
189
+ toNepaliNumerals,
190
+ toLatinNumerals,
269
191
  } from 'react-native-bikram-sambat';
270
- ```
271
-
272
- ## Theme Customization
273
192
 
274
- ### Light and Dark Mode
193
+ const date = { calendar: 'BS', year: 2081, month: 1, day: 5 } as const;
275
194
 
276
- ```tsx
277
- import { NepaliCalendar } from 'react-native-bikram-sambat';
278
-
279
- // System default (auto-detects device theme)
280
- <NepaliCalendar colorScheme="system" />
281
-
282
- // Force dark mode
283
- <NepaliCalendar colorScheme="dark" />
195
+ const isoLike = formatBS(date, 'yyyy-MM-dd');
196
+ const nepaliFormatted = formatBS(date, 'dd MMMM yyyy', {
197
+ locale: 'ne',
198
+ numerals: 'devanagari',
199
+ });
284
200
 
285
- // Force light mode
286
- <NepaliCalendar colorScheme="light" />
201
+ const parsed = parseBS('2081-01-05', 'yyyy-MM-dd');
202
+ const devanagari = toNepaliNumerals('2081');
203
+ const latin = toLatinNumerals('२०८१');
287
204
  ```
288
205
 
289
- ### Custom Theme Override
206
+ ## API Reference
290
207
 
291
- ```tsx
292
- import { NepaliDatePicker, type CalendarTheme } from 'react-native-bikram-sambat';
293
-
294
- const customTheme: Partial<CalendarTheme> = {
295
- colors: {
296
- primary: '#7c3aed',
297
- primaryText: '#ffffff',
298
- },
299
- radius: {
300
- day: 16,
301
- calendar: 16,
302
- },
303
- };
304
-
305
- <NepaliDatePicker theme={customTheme} />
306
- ```
208
+ ### Components
307
209
 
308
- ## Local Package Testing
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
309
215
 
310
- When developing locally, test the package before publishing:
216
+ ### Conversion and formatting
311
217
 
312
- ```sh
313
- npm run typecheck
314
- npm test
315
- npm run build
316
- npm pack --dry-run
317
- npm pack
318
- ```
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
319
224
 
320
- This produces a `.tgz` file. Test it in another React Native CLI app:
225
+ ### Validation and helpers
321
226
 
322
- ```sh
323
- cd /path/to/your/app
324
- npm install ../Calender/react-native-bikram-sambat-0.1.0.tgz
325
- ```
227
+ - `isValidBSDate`
228
+ - `isValidADDate`
229
+ - `isBSDateInSupportedRange`
230
+ - `getSupportedBSRange`
231
+ - `createBSDateKey`
232
+ - `parseBSDateKey`
233
+ - `compareBS`
234
+ - `addBSDays`
235
+ - `subBSDays`
236
+ - `todayBS`
237
+ - `getCalendarMonthGrid`
326
238
 
327
- ## Supported BS Range
239
+ ## Use Cases
328
240
 
329
- The package currently supports the verified BS date range included in its data table. Dates outside the supported range will throw or return `false` depending on the API.
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
330
247
 
331
- Core conversion functions throw `RangeError` for out-of-range dates.
332
- UI components handle invalid dates gracefully without crashing.
248
+ ## Why Use This Package?
333
249
 
334
- ## Publishing
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.
335
254
 
336
- Publishing is handled by GitHub Actions when code is pushed to `main`.
255
+ ## TypeScript Support
337
256
 
338
- Before publishing, add an npm automation token in GitHub:
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.
339
258
 
340
- - Repository settings Secrets and variables → Actions
341
- - Add secret named `NPM_TOKEN`
259
+ ## Expo and React Native CLI Compatibility
342
260
 
343
- To publish a new version:
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.
344
262
 
345
- ```sh
346
- npm version patch
347
- git push origin main --follow-tags
348
- ```
263
+ ## Preview
349
264
 
350
- The workflow publishes only if the current package version is not already on npm.
265
+ ![Calendar view](./docs/screenshots/iphone-15-pro-max-calendar.png)
351
266
 
352
- ## Screenshot
267
+ ## Contributing
353
268
 
354
- ![Calendar view](./docs/screenshots/iphone-15-pro-max-calendar.png)
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.
355
270
 
356
271
  ## License
357
272
 
358
- MIT
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.1",
4
- "description": "A production-grade Bikram Sambat calendar engine and React Native date picker for React Native.",
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
- "ad-to-bs"
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",