@gambhirpoudel/nepali-calendar-kit 1.0.0 → 1.0.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.

Potentially problematic release.


This version of @gambhirpoudel/nepali-calendar-kit might be problematic. Click here for more details.

package/package.json CHANGED
@@ -1,32 +1,52 @@
1
1
  {
2
2
  "name": "@gambhirpoudel/nepali-calendar-kit",
3
- "version": "1.0.0",
4
- "description": "",
5
- "main": "dist/index.cjs.js",
3
+ "version": "1.0.3",
4
+ "description": "A React-based Nepali calendar library providing conversion functions, calendar components, and hooks.",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "type": "module",
9
+ "files": [
10
+ "dist",
11
+ "README.md",
12
+ "LICENSE"
13
+ ],
6
14
  "scripts": {
7
- "build": "tsup src/index.ts --format esm,cjs --dts",
8
- "test": "vitest run",
9
- "dev": "tsup src/index.ts --format esm --watch"
15
+ "build": "tsc",
16
+ "test": "vitest run"
10
17
  },
11
- "module": "dist/index.esm.js",
12
- "types": "dist/index.d.ts",
13
- "keywords": [],
14
- "author": "",
15
- "license": "ISC",
16
- "type": "commonjs",
17
18
  "dependencies": {
18
19
  "react": "^19.2.3",
19
20
  "react-dom": "^19.2.3"
20
21
  },
21
22
  "devDependencies": {
22
- "@types/react": "^19.2.8",
23
- "@types/react-dom": "^19.2.3",
24
- "tsup": "^8.5.1",
25
- "typescript": "^5.9.3",
23
+ "@types/node": "^25.0.8",
24
+ "@types/react": "^19.0.0",
25
+ "@types/react-dom": "^19.0.0",
26
+ "typescript": "^5.3.0",
26
27
  "vitest": "^4.0.17"
27
28
  },
29
+ "peerDependencies": {
30
+ "react": "^19.2.3",
31
+ "react-dom": "^19.2.3"
32
+ },
28
33
  "repository": {
29
34
  "type": "git",
30
- "url": "https://github.com/ZaddyAI/nepali-calendar-kit.git"
35
+ "url": "git+https://github.com/ZaddyAI/nepali-calendar-kit.git"
36
+ },
37
+ "keywords": [
38
+ "nepali",
39
+ "calendar",
40
+ "react",
41
+ "ad-bs",
42
+ "bs-ad",
43
+ "hooks",
44
+ "components"
45
+ ],
46
+ "author": "Gambhir Poudel <gambhir.poudel07@gmail.com>",
47
+ "license": "ISC",
48
+ "homepage": "https://github.com/ZaddyAI/nepali-calendar-kit#readme",
49
+ "publishConfig": {
50
+ "access": "public"
31
51
  }
32
52
  }
package/dist/index.d.mts DELETED
@@ -1,42 +0,0 @@
1
- import React from 'react';
2
-
3
- declare function adToBs(ad: Date): {
4
- year: number;
5
- month: number;
6
- day: number;
7
- };
8
-
9
- declare function bsToAd(year: number, month: number, day: number): Date;
10
-
11
- declare function useNepaliDate(adDate?: Date): {
12
- bs: {
13
- year: number;
14
- month: number;
15
- day: number;
16
- };
17
- toAD: () => Date;
18
- };
19
-
20
- interface NepaliCalendarProps {
21
- date?: Date;
22
- renderDay?: (day: number, month: number, year: number) => React.ReactNode;
23
- }
24
- declare const NepaliCalendar: React.FC<NepaliCalendarProps>;
25
-
26
- interface DayCellProps {
27
- day: number;
28
- month: number;
29
- year: number;
30
- isSelected?: boolean;
31
- render?: (day: number, month: number, year: number, isSelected?: boolean) => React.ReactNode;
32
- }
33
- declare const DayCell: React.FC<DayCellProps>;
34
-
35
- interface MonthViewProps {
36
- year: number;
37
- month: number;
38
- renderDay?: (day: number, month: number, year: number) => React.ReactNode;
39
- }
40
- declare const MonthView: React.FC<MonthViewProps>;
41
-
42
- export { DayCell, MonthView, NepaliCalendar, adToBs, bsToAd, useNepaliDate };
package/dist/index.mjs DELETED
@@ -1,250 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
- var __hasOwnProp = Object.prototype.hasOwnProperty;
4
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __spreadValues = (a, b) => {
7
- for (var prop in b || (b = {}))
8
- if (__hasOwnProp.call(b, prop))
9
- __defNormalProp(a, prop, b[prop]);
10
- if (__getOwnPropSymbols)
11
- for (var prop of __getOwnPropSymbols(b)) {
12
- if (__propIsEnum.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- }
15
- return a;
16
- };
17
-
18
- // src/core/constants.ts
19
- var AD_ANCHOR = new Date(Date.UTC(1943, 3, 14));
20
- var BS_ANCHOR = { year: 2e3, month: 1, day: 1 };
21
-
22
- // src/data/bsMonthData.ts
23
- var BS_MONTH_DATA = {
24
- 1970: [31, 31, 32, 31, 31, 30, 30, 29, 30, 29, 30, 30],
25
- 1971: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
26
- 1972: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
27
- 1973: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
28
- 1974: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
29
- 1975: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
30
- 1976: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
31
- 1977: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
32
- 1978: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
33
- 1979: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
34
- 1980: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
35
- 1981: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
36
- 1982: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
37
- 1983: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
38
- 1984: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
39
- 1985: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
40
- 1986: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
41
- 1987: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
42
- 1988: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
43
- 1989: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
44
- 1990: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
45
- 1991: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
46
- 1992: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
47
- 1993: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
48
- 1994: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
49
- 1995: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
50
- 1996: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
51
- 1997: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
52
- 1998: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
53
- 1999: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
54
- 2e3: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
55
- 2001: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
56
- 2002: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
57
- 2003: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
58
- 2004: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
59
- 2005: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
60
- 2006: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
61
- 2007: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
62
- 2008: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
63
- 2009: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
64
- 2010: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
65
- 2011: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
66
- 2012: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
67
- 2013: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
68
- 2014: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
69
- 2015: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
70
- 2016: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
71
- 2017: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
72
- 2018: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
73
- 2019: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
74
- 2020: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
75
- 2021: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
76
- 2022: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
77
- 2023: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
78
- 2024: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
79
- 2025: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
80
- 2026: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
81
- 2027: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
82
- 2028: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
83
- 2029: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
84
- 2030: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
85
- 2031: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
86
- 2032: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
87
- 2033: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
88
- 2034: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
89
- 2035: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
90
- 2036: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
91
- 2037: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
92
- 2038: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
93
- 2039: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
94
- 2040: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
95
- 2041: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
96
- 2042: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
97
- 2043: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
98
- 2044: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
99
- 2045: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
100
- 2046: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
101
- 2047: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
102
- 2048: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
103
- 2049: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
104
- 2050: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
105
- 2051: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
106
- 2052: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
107
- 2053: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
108
- 2054: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
109
- 2055: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
110
- 2056: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
111
- 2057: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
112
- 2058: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
113
- 2059: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
114
- 2060: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
115
- 2061: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
116
- 2062: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
117
- 2063: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
118
- 2064: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
119
- 2065: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
120
- 2066: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
121
- 2067: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
122
- 2068: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
123
- 2069: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
124
- 2070: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
125
- 2071: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
126
- 2072: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
127
- 2073: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
128
- 2074: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
129
- 2075: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
130
- 2076: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
131
- 2077: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
132
- 2078: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
133
- 2079: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
134
- 2080: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
135
- 2081: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
136
- 2082: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
137
- 2083: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
138
- 2084: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
139
- 2085: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
140
- 2086: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
141
- 2087: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
142
- 2088: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
143
- 2089: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
144
- 2090: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
145
- 2091: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
146
- 2092: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
147
- 2093: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
148
- 2094: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
149
- 2095: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
150
- 2096: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
151
- 2097: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
152
- 2098: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
153
- 2099: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
154
- 2100: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
155
- 2101: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
156
- 2102: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
157
- 2103: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
158
- 2104: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
159
- 2105: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
160
- 2106: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
161
- 2107: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
162
- 2108: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
163
- 2109: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
164
- 2110: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
165
- 2111: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
166
- 2112: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
167
- 2113: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
168
- 2114: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
169
- 2115: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
170
- 2116: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
171
- 2117: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
172
- 2118: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
173
- 2119: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
174
- 2120: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
175
- 2121: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
176
- 2122: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
177
- 2123: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
178
- 2124: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31]
179
- };
180
-
181
- // src/core/adToBs.ts
182
- function adToBs(ad) {
183
- let days = Math.floor((ad.getTime() - AD_ANCHOR.getTime()) / 864e5);
184
- let { year, month, day } = __spreadValues({}, BS_ANCHOR);
185
- while (days > 0) {
186
- const daysInMonth = BS_MONTH_DATA[year][month - 1];
187
- day++;
188
- if (day > daysInMonth) {
189
- day = 1;
190
- month++;
191
- if (month > 12) {
192
- month = 1;
193
- year++;
194
- }
195
- }
196
- days--;
197
- }
198
- return { year, month, day };
199
- }
200
-
201
- // src/core/bsToAd.ts
202
- function bsToAd(year, month, day) {
203
- let totalDays = 0;
204
- for (let y = BS_ANCHOR.year; y < year; y++) {
205
- totalDays += BS_MONTH_DATA[y].reduce((a, b) => a + b, 0);
206
- }
207
- for (let m = 1; m < month; m++) {
208
- totalDays += BS_MONTH_DATA[year][m - 1];
209
- }
210
- totalDays += day - 1;
211
- return new Date(AD_ANCHOR.getTime() + totalDays * 864e5);
212
- }
213
-
214
- // src/hooks/useNepaliDate.ts
215
- function useNepaliDate(adDate = /* @__PURE__ */ new Date()) {
216
- const bs = adToBs(adDate);
217
- const toAD = () => bsToAd(bs.year, bs.month, bs.day);
218
- return { bs, toAD };
219
- }
220
-
221
- // src/components/NepaliCalendar.tsx
222
- import { useState } from "react";
223
-
224
- // src/components/DayCell.tsx
225
- import { jsx } from "react/jsx-runtime";
226
- var DayCell = ({ day, month, year, isSelected, render }) => {
227
- return /* @__PURE__ */ jsx("div", { className: `day-cell ${isSelected ? "selected" : ""}`, children: render ? render(day, month, year, isSelected) : day });
228
- };
229
-
230
- // src/components/MonthView.tsx
231
- import { jsx as jsx2 } from "react/jsx-runtime";
232
- var MonthView = ({ year, month, renderDay }) => {
233
- const daysInMonth = BS_MONTH_DATA[year][month - 1];
234
- return /* @__PURE__ */ jsx2("div", { className: "month-view-grid", children: Array.from({ length: daysInMonth }, (_, i) => /* @__PURE__ */ jsx2(DayCell, { day: i + 1, month, year, render: renderDay }, i)) });
235
- };
236
-
237
- // src/components/NepaliCalendar.tsx
238
- import { jsx as jsx3 } from "react/jsx-runtime";
239
- var NepaliCalendar = ({ date = /* @__PURE__ */ new Date(), renderDay }) => {
240
- const [current, setCurrent] = useState(adToBs(date));
241
- return /* @__PURE__ */ jsx3("div", { className: "nepali-calendar", children: /* @__PURE__ */ jsx3(MonthView, { year: current.year, month: current.month, renderDay }) });
242
- };
243
- export {
244
- DayCell,
245
- MonthView,
246
- NepaliCalendar,
247
- adToBs,
248
- bsToAd,
249
- useNepaliDate
250
- };
@@ -1,17 +0,0 @@
1
- import React from "react";
2
-
3
- interface DayCellProps {
4
- day: number;
5
- month: number;
6
- year: number;
7
- isSelected?: boolean;
8
- render?: (day: number, month: number, year: number, isSelected?: boolean) => React.ReactNode;
9
- }
10
-
11
- export const DayCell: React.FC<DayCellProps> = ({ day, month, year, isSelected, render }) => {
12
- return (
13
- <div className={`day-cell ${isSelected ? "selected" : ""}`}>
14
- {render ? render(day, month, year, isSelected) : day}
15
- </div>
16
- );
17
- };
@@ -1,21 +0,0 @@
1
- import React from "react";
2
- import { DayCell } from "./DayCell";
3
- import { BS_MONTH_DATA } from "../data/bsMonthData";
4
-
5
- interface MonthViewProps {
6
- year: number;
7
- month: number;
8
- renderDay?: (day: number, month: number, year: number) => React.ReactNode;
9
- }
10
-
11
- export const MonthView: React.FC<MonthViewProps> = ({ year, month, renderDay }) => {
12
- const daysInMonth = BS_MONTH_DATA[year][month - 1];
13
-
14
- return (
15
- <div className="month-view-grid">
16
- {Array.from({ length: daysInMonth }, (_, i) => (
17
- <DayCell key={i} day={i + 1} month={month} year={year} render={renderDay} />
18
- ))}
19
- </div>
20
- );
21
- };
@@ -1,19 +0,0 @@
1
- import React, { useState } from "react";
2
- import { adToBs } from "../core/adToBs";
3
- import { MonthView } from "./MonthView";
4
-
5
- interface NepaliCalendarProps {
6
- date?: Date;
7
- renderDay?: (day: number, month: number, year: number) => React.ReactNode;
8
- }
9
-
10
- export const NepaliCalendar: React.FC<NepaliCalendarProps> = ({ date = new Date(), renderDay }) => {
11
- const [current, setCurrent] = useState(adToBs(date));
12
-
13
- return (
14
- <div className="nepali-calendar">
15
- <MonthView year={current.year} month={current.month} renderDay={renderDay} />
16
- {/* You can extend with Month/Year navigation */}
17
- </div>
18
- );
19
- };
@@ -1,23 +0,0 @@
1
- import { AD_ANCHOR, BS_ANCHOR } from "./constants";
2
- import { BS_MONTH_DATA } from "../data/bsMonthData";
3
-
4
- export function adToBs(ad: Date) {
5
- let days = Math.floor((ad.getTime() - AD_ANCHOR.getTime()) / 86400000);
6
- let { year, month, day } = { ...BS_ANCHOR };
7
-
8
- while (days > 0) {
9
- const daysInMonth = BS_MONTH_DATA[year][month - 1];
10
- day++;
11
- if (day > daysInMonth) {
12
- day = 1;
13
- month++;
14
- if (month > 12) {
15
- month = 1;
16
- year++;
17
- }
18
- }
19
- days--;
20
- }
21
-
22
- return { year, month, day };
23
- }
@@ -1,18 +0,0 @@
1
- import { AD_ANCHOR, BS_ANCHOR } from "./constants";
2
- import { BS_MONTH_DATA } from "../data/bsMonthData";
3
-
4
- export function bsToAd(year: number, month: number, day: number): Date {
5
- let totalDays = 0;
6
-
7
- for (let y = BS_ANCHOR.year; y < year; y++) {
8
- totalDays += BS_MONTH_DATA[y].reduce((a, b) => a + b, 0);
9
- }
10
-
11
- for (let m = 1; m < month; m++) {
12
- totalDays += BS_MONTH_DATA[year][m - 1];
13
- }
14
-
15
- totalDays += day - 1;
16
-
17
- return new Date(AD_ANCHOR.getTime() + totalDays * 86400000);
18
- }
@@ -1,157 +0,0 @@
1
- export const BS_MONTH_DATA: Record<number, number[]> = {
2
- 1970: [31, 31, 32, 31, 31, 30, 30, 29, 30, 29, 30, 30],
3
- 1971: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
4
- 1972: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
5
- 1973: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
6
- 1974: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
7
- 1975: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
8
- 1976: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
9
- 1977: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
10
- 1978: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
11
- 1979: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
12
- 1980: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
13
- 1981: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
14
- 1982: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
15
- 1983: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
16
- 1984: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
17
- 1985: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
18
- 1986: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
19
- 1987: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
20
- 1988: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
21
- 1989: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
22
- 1990: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
23
- 1991: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
24
- 1992: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
25
- 1993: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
26
- 1994: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
27
- 1995: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
28
- 1996: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
29
- 1997: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
30
- 1998: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
31
- 1999: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
32
- 2000: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
33
- 2001: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
34
- 2002: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
35
- 2003: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
36
- 2004: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
37
- 2005: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
38
- 2006: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
39
- 2007: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
40
- 2008: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
41
- 2009: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
42
- 2010: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
43
- 2011: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
44
- 2012: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
45
- 2013: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
46
- 2014: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
47
- 2015: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
48
- 2016: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
49
- 2017: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
50
- 2018: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
51
- 2019: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
52
- 2020: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
53
- 2021: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
54
- 2022: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
55
- 2023: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
56
- 2024: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
57
- 2025: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
58
- 2026: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
59
- 2027: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
60
- 2028: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
61
- 2029: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
62
- 2030: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
63
- 2031: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
64
- 2032: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
65
- 2033: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
66
- 2034: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
67
- 2035: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
68
- 2036: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
69
- 2037: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
70
- 2038: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
71
- 2039: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
72
- 2040: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
73
- 2041: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
74
- 2042: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
75
- 2043: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
76
- 2044: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
77
- 2045: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
78
- 2046: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
79
- 2047: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
80
- 2048: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
81
- 2049: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
82
- 2050: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
83
- 2051: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
84
- 2052: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
85
- 2053: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
86
- 2054: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
87
- 2055: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
88
- 2056: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
89
- 2057: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
90
- 2058: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
91
- 2059: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
92
- 2060: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
93
- 2061: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
94
- 2062: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
95
- 2063: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
96
- 2064: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
97
- 2065: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
98
- 2066: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
99
- 2067: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
100
- 2068: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
101
- 2069: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
102
- 2070: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
103
- 2071: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
104
- 2072: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
105
- 2073: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
106
- 2074: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
107
- 2075: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
108
- 2076: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
109
- 2077: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
110
- 2078: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
111
- 2079: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
112
- 2080: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
113
- 2081: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
114
- 2082: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
115
- 2083: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
116
- 2084: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
117
- 2085: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
118
- 2086: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
119
- 2087: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
120
- 2088: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
121
- 2089: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
122
- 2090: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
123
- 2091: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
124
- 2092: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
125
- 2093: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
126
- 2094: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
127
- 2095: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
128
- 2096: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
129
- 2097: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
130
- 2098: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
131
- 2099: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
132
- 2100: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
133
- 2101: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
134
- 2102: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
135
- 2103: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
136
- 2104: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
137
- 2105: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
138
- 2106: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
139
- 2107: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
140
- 2108: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
141
- 2109: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
142
- 2110: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
143
- 2111: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
144
- 2112: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
145
- 2113: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
146
- 2114: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
147
- 2115: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
148
- 2116: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
149
- 2117: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
150
- 2118: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
151
- 2119: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
152
- 2120: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
153
- 2121: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
154
- 2122: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
155
- 2123: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
156
- 2124: [31, 31, 32, 31, 32, 30, 29, 30, 29, 30, 29, 31],
157
- };
@@ -1,10 +0,0 @@
1
- import { adToBs } from "../core/adToBs";
2
- import { bsToAd } from "../core/bsToAd";
3
-
4
- export function useNepaliDate(adDate: Date = new Date()) {
5
- const bs = adToBs(adDate);
6
-
7
- const toAD = () => bsToAd(bs.year, bs.month, bs.day);
8
-
9
- return { bs, toAD };
10
- }
package/src/index.ts DELETED
@@ -1,6 +0,0 @@
1
- export { adToBs } from "./core/adToBs";
2
- export { bsToAd } from "./core/bsToAd";
3
- export { useNepaliDate } from "./hooks/useNepaliDate";
4
- export { NepaliCalendar } from "./components/NepaliCalendar";
5
- export { DayCell } from "./components/DayCell";
6
- export { MonthView } from "./components/MonthView";
@@ -1,13 +0,0 @@
1
- import { describe, it, expect } from "vitest";
2
- import { adToBs } from "../src/core/adToBs";
3
- import { bsToAd } from "../src/core/bsToAd";
4
-
5
- describe("AD ↔ BS Conversion Reversibility", () => {
6
- it("AD → BS → AD returns the same AD date", () => {
7
- const ad = new Date("2025-01-13");
8
- const bs = adToBs(ad);
9
- const back = bsToAd(bs.year, bs.month, bs.day);
10
-
11
- expect(back.toISOString()).toBe(ad.toISOString());
12
- });
13
- });
@@ -1,14 +0,0 @@
1
- import { describe, it, expect } from "vitest";
2
- import { adToBs } from "../src/core/adToBs";
3
- import { bsToAd } from "../src/core/bsToAd";
4
-
5
- describe("AD ↔ BS Conversion Reversibility", () => {
6
- it("AD → BS → AD should return the same AD date", () => {
7
- const ad = new Date("2025-01-13");
8
- const bs = adToBs(ad);
9
- const back = bsToAd(bs.year, bs.month, bs.day);
10
-
11
- expect(back.toISOString()).toBe(ad.toISOString());
12
- });
13
- });
14
-