react-native-bikram-sambat 0.1.4 → 0.1.5

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.
Files changed (126) hide show
  1. package/README.md +44 -213
  2. package/lib/commonjs/accessibility/labels.js +1 -2
  3. package/lib/commonjs/accessibility/labels.js.map +1 -1
  4. package/lib/commonjs/components/NepaliCalendar/CalendarDay.js +8 -41
  5. package/lib/commonjs/components/NepaliCalendar/CalendarDay.js.map +1 -1
  6. package/lib/commonjs/components/NepaliCalendar/CalendarGrid.js +7 -24
  7. package/lib/commonjs/components/NepaliCalendar/CalendarGrid.js.map +1 -1
  8. package/lib/commonjs/components/NepaliCalendar/CalendarHeader.js +18 -6
  9. package/lib/commonjs/components/NepaliCalendar/CalendarHeader.js.map +1 -1
  10. package/lib/commonjs/components/NepaliCalendar/NepaliCalendar.js +93 -61
  11. package/lib/commonjs/components/NepaliCalendar/NepaliCalendar.js.map +1 -1
  12. package/lib/commonjs/index.js +0 -22
  13. package/lib/commonjs/index.js.map +1 -1
  14. package/lib/commonjs/theme/default-theme.js +2 -22
  15. package/lib/commonjs/theme/default-theme.js.map +1 -1
  16. package/lib/commonjs/utils/date-helpers.js +0 -8
  17. package/lib/commonjs/utils/date-helpers.js.map +1 -1
  18. package/lib/module/accessibility/labels.js +1 -2
  19. package/lib/module/accessibility/labels.js.map +1 -1
  20. package/lib/module/components/NepaliCalendar/CalendarDay.js +8 -41
  21. package/lib/module/components/NepaliCalendar/CalendarDay.js.map +1 -1
  22. package/lib/module/components/NepaliCalendar/CalendarGrid.js +7 -24
  23. package/lib/module/components/NepaliCalendar/CalendarGrid.js.map +1 -1
  24. package/lib/module/components/NepaliCalendar/CalendarHeader.js +18 -6
  25. package/lib/module/components/NepaliCalendar/CalendarHeader.js.map +1 -1
  26. package/lib/module/components/NepaliCalendar/NepaliCalendar.js +96 -64
  27. package/lib/module/components/NepaliCalendar/NepaliCalendar.js.map +1 -1
  28. package/lib/module/index.js +0 -2
  29. package/lib/module/index.js.map +1 -1
  30. package/lib/module/theme/default-theme.js +2 -22
  31. package/lib/module/theme/default-theme.js.map +1 -1
  32. package/lib/module/utils/date-helpers.js +0 -8
  33. package/lib/module/utils/date-helpers.js.map +1 -1
  34. package/lib/typescript/src/accessibility/labels.d.ts +1 -1
  35. package/lib/typescript/src/accessibility/labels.d.ts.map +1 -1
  36. package/lib/typescript/src/components/NepaliCalendar/CalendarDay.d.ts +1 -5
  37. package/lib/typescript/src/components/NepaliCalendar/CalendarDay.d.ts.map +1 -1
  38. package/lib/typescript/src/components/NepaliCalendar/CalendarGrid.d.ts +1 -4
  39. package/lib/typescript/src/components/NepaliCalendar/CalendarGrid.d.ts.map +1 -1
  40. package/lib/typescript/src/components/NepaliCalendar/CalendarHeader.d.ts +1 -0
  41. package/lib/typescript/src/components/NepaliCalendar/CalendarHeader.d.ts.map +1 -1
  42. package/lib/typescript/src/components/NepaliCalendar/NepaliCalendar.d.ts +1 -1
  43. package/lib/typescript/src/components/NepaliCalendar/NepaliCalendar.d.ts.map +1 -1
  44. package/lib/typescript/src/components/NepaliCalendar/types.d.ts +6 -10
  45. package/lib/typescript/src/components/NepaliCalendar/types.d.ts.map +1 -1
  46. package/lib/typescript/src/index.d.ts +0 -2
  47. package/lib/typescript/src/index.d.ts.map +1 -1
  48. package/lib/typescript/src/theme/default-theme.d.ts.map +1 -1
  49. package/lib/typescript/src/theme/types.d.ts +0 -10
  50. package/lib/typescript/src/theme/types.d.ts.map +1 -1
  51. package/lib/typescript/src/utils/date-helpers.d.ts +0 -4
  52. package/lib/typescript/src/utils/date-helpers.d.ts.map +1 -1
  53. package/package.json +2 -6
  54. package/src/accessibility/labels.ts +0 -2
  55. package/src/components/NepaliCalendar/CalendarDay.tsx +6 -65
  56. package/src/components/NepaliCalendar/CalendarGrid.tsx +12 -32
  57. package/src/components/NepaliCalendar/CalendarHeader.tsx +18 -2
  58. package/src/components/NepaliCalendar/NepaliCalendar.tsx +128 -56
  59. package/src/components/NepaliCalendar/types.ts +3 -12
  60. package/src/index.ts +0 -2
  61. package/src/theme/default-theme.ts +0 -20
  62. package/src/theme/types.ts +0 -10
  63. package/src/utils/date-helpers.ts +0 -12
  64. package/lib/commonjs/components/NepaliDatePicker/DatePickerModal.js +0 -185
  65. package/lib/commonjs/components/NepaliDatePicker/DatePickerModal.js.map +0 -1
  66. package/lib/commonjs/components/NepaliDatePicker/NepaliDatePicker.js +0 -148
  67. package/lib/commonjs/components/NepaliDatePicker/NepaliDatePicker.js.map +0 -1
  68. package/lib/commonjs/components/NepaliDatePicker/index.js +0 -20
  69. package/lib/commonjs/components/NepaliDatePicker/index.js.map +0 -1
  70. package/lib/commonjs/components/NepaliDatePicker/types.js +0 -6
  71. package/lib/commonjs/components/NepaliDatePicker/types.js.map +0 -1
  72. package/lib/commonjs/components/NepaliRangePicker/NepaliRangePicker.js +0 -187
  73. package/lib/commonjs/components/NepaliRangePicker/NepaliRangePicker.js.map +0 -1
  74. package/lib/commonjs/components/NepaliRangePicker/RangePickerModal.js +0 -275
  75. package/lib/commonjs/components/NepaliRangePicker/RangePickerModal.js.map +0 -1
  76. package/lib/commonjs/components/NepaliRangePicker/index.js +0 -57
  77. package/lib/commonjs/components/NepaliRangePicker/index.js.map +0 -1
  78. package/lib/commonjs/components/NepaliRangePicker/range-utils.js +0 -70
  79. package/lib/commonjs/components/NepaliRangePicker/range-utils.js.map +0 -1
  80. package/lib/commonjs/components/NepaliRangePicker/types.js +0 -6
  81. package/lib/commonjs/components/NepaliRangePicker/types.js.map +0 -1
  82. package/lib/module/components/NepaliDatePicker/DatePickerModal.js +0 -180
  83. package/lib/module/components/NepaliDatePicker/DatePickerModal.js.map +0 -1
  84. package/lib/module/components/NepaliDatePicker/NepaliDatePicker.js +0 -143
  85. package/lib/module/components/NepaliDatePicker/NepaliDatePicker.js.map +0 -1
  86. package/lib/module/components/NepaliDatePicker/index.js +0 -5
  87. package/lib/module/components/NepaliDatePicker/index.js.map +0 -1
  88. package/lib/module/components/NepaliDatePicker/types.js +0 -4
  89. package/lib/module/components/NepaliDatePicker/types.js.map +0 -1
  90. package/lib/module/components/NepaliRangePicker/NepaliRangePicker.js +0 -182
  91. package/lib/module/components/NepaliRangePicker/NepaliRangePicker.js.map +0 -1
  92. package/lib/module/components/NepaliRangePicker/RangePickerModal.js +0 -270
  93. package/lib/module/components/NepaliRangePicker/RangePickerModal.js.map +0 -1
  94. package/lib/module/components/NepaliRangePicker/index.js +0 -6
  95. package/lib/module/components/NepaliRangePicker/index.js.map +0 -1
  96. package/lib/module/components/NepaliRangePicker/range-utils.js +0 -61
  97. package/lib/module/components/NepaliRangePicker/range-utils.js.map +0 -1
  98. package/lib/module/components/NepaliRangePicker/types.js +0 -4
  99. package/lib/module/components/NepaliRangePicker/types.js.map +0 -1
  100. package/lib/typescript/src/components/NepaliDatePicker/DatePickerModal.d.ts +0 -4
  101. package/lib/typescript/src/components/NepaliDatePicker/DatePickerModal.d.ts.map +0 -1
  102. package/lib/typescript/src/components/NepaliDatePicker/NepaliDatePicker.d.ts +0 -4
  103. package/lib/typescript/src/components/NepaliDatePicker/NepaliDatePicker.d.ts.map +0 -1
  104. package/lib/typescript/src/components/NepaliDatePicker/index.d.ts +0 -4
  105. package/lib/typescript/src/components/NepaliDatePicker/index.d.ts.map +0 -1
  106. package/lib/typescript/src/components/NepaliDatePicker/types.d.ts +0 -50
  107. package/lib/typescript/src/components/NepaliDatePicker/types.d.ts.map +0 -1
  108. package/lib/typescript/src/components/NepaliRangePicker/NepaliRangePicker.d.ts +0 -4
  109. package/lib/typescript/src/components/NepaliRangePicker/NepaliRangePicker.d.ts.map +0 -1
  110. package/lib/typescript/src/components/NepaliRangePicker/RangePickerModal.d.ts +0 -4
  111. package/lib/typescript/src/components/NepaliRangePicker/RangePickerModal.d.ts.map +0 -1
  112. package/lib/typescript/src/components/NepaliRangePicker/index.d.ts +0 -5
  113. package/lib/typescript/src/components/NepaliRangePicker/index.d.ts.map +0 -1
  114. package/lib/typescript/src/components/NepaliRangePicker/range-utils.d.ts +0 -13
  115. package/lib/typescript/src/components/NepaliRangePicker/range-utils.d.ts.map +0 -1
  116. package/lib/typescript/src/components/NepaliRangePicker/types.d.ts +0 -61
  117. package/lib/typescript/src/components/NepaliRangePicker/types.d.ts.map +0 -1
  118. package/src/components/NepaliDatePicker/DatePickerModal.tsx +0 -220
  119. package/src/components/NepaliDatePicker/NepaliDatePicker.tsx +0 -171
  120. package/src/components/NepaliDatePicker/index.ts +0 -3
  121. package/src/components/NepaliDatePicker/types.ts +0 -70
  122. package/src/components/NepaliRangePicker/NepaliRangePicker.tsx +0 -206
  123. package/src/components/NepaliRangePicker/RangePickerModal.tsx +0 -336
  124. package/src/components/NepaliRangePicker/index.ts +0 -11
  125. package/src/components/NepaliRangePicker/range-utils.ts +0 -75
  126. package/src/components/NepaliRangePicker/types.ts +0 -84
@@ -18,6 +18,7 @@ type CalendarHeaderProps = {
18
18
  theme: CalendarTheme;
19
19
  onPrevMonth: () => void;
20
20
  onNextMonth: () => void;
21
+ onYearPress: () => void;
21
22
  canGoPrev: boolean;
22
23
  canGoNext: boolean;
23
24
  };
@@ -55,6 +56,7 @@ export const CalendarHeader = memo(function CalendarHeader({
55
56
  theme,
56
57
  onPrevMonth,
57
58
  onNextMonth,
59
+ onYearPress,
58
60
  canGoPrev,
59
61
  canGoNext,
60
62
  }: CalendarHeaderProps) {
@@ -80,7 +82,16 @@ export const CalendarHeader = memo(function CalendarHeader({
80
82
  <Text style={[styles.navText, { color: theme.colors.text }]}>‹</Text>
81
83
  </Pressable>
82
84
 
83
- <Text style={[styles.title, { color: theme.colors.text }]}>{title}</Text>
85
+ <Pressable
86
+ style={styles.titleButton}
87
+ onPress={onYearPress}
88
+ accessibilityRole="button"
89
+ accessibilityLabel={`Select year, ${title}`}
90
+ >
91
+ <Text style={[styles.title, { color: theme.colors.text }]}>
92
+ {title}
93
+ </Text>
94
+ </Pressable>
84
95
 
85
96
  <Pressable
86
97
  style={[styles.navButton, !canGoNext && styles.navButtonDisabled]}
@@ -106,9 +117,14 @@ const styles = StyleSheet.create({
106
117
  title: {
107
118
  fontSize: 18,
108
119
  fontWeight: '600',
109
- flex: 1,
110
120
  textAlign: 'center',
111
121
  },
122
+ titleButton: {
123
+ flex: 1,
124
+ minHeight: 40,
125
+ alignItems: 'center',
126
+ justifyContent: 'center',
127
+ },
112
128
  navButton: {
113
129
  width: 40,
114
130
  height: 40,
@@ -1,19 +1,18 @@
1
1
  import React, { useState, useMemo, useCallback, useRef, useEffect } from 'react';
2
- import { View, StyleSheet } from 'react-native';
3
- import type { BSDateValue } from '../../core/types';
2
+ import { View, Text, Pressable, ScrollView, StyleSheet } from 'react-native';
4
3
  import {
5
4
  getBSMonthLength,
6
5
  todayBS,
7
- compareBS,
8
6
  isBSDateInSupportedRange,
9
7
  getSafeCalendarMonth,
10
8
  getDefaultSupportedBSDate,
9
+ getSupportedBSRange,
11
10
  } from '../../core';
12
11
  import { getCalendarMonthGrid } from '../../calendar';
13
12
  import { EN_LOCALE, NE_LOCALE } from '../../core/locale';
14
13
  import type { LocaleCode, CalendarLocale } from '../../core/locale';
15
14
  import { useCalendarTheme } from '../../theme';
16
- import { warnOutOfRangeInDev, warnMinMaxInDev, createDateAccessibilityLabel } from '../../utils';
15
+ import { warnMinMaxInDev } from '../../utils';
17
16
  import type { NepaliCalendarProps } from './types';
18
17
  import { CalendarHeader } from './CalendarHeader';
19
18
  import { CalendarWeekdays } from './CalendarWeekdays';
@@ -46,9 +45,6 @@ function resolveLocale(
46
45
  }
47
46
 
48
47
  export function NepaliCalendar({
49
- value,
50
- defaultValue,
51
- onChange,
52
48
  year,
53
49
  month,
54
50
  defaultYear,
@@ -62,23 +58,15 @@ export function NepaliCalendar({
62
58
  theme,
63
59
  colorScheme = 'system',
64
60
  disabledDates,
61
+ onDayPress,
65
62
  onMonthChange,
63
+ onYearChange,
66
64
  renderDay,
67
- rangeValue,
68
65
  testID,
69
66
  }: NepaliCalendarProps) {
70
67
  const resolvedLocale = useMemo(() => resolveLocale(locale), [locale]);
71
68
  const calendarTheme = useCalendarTheme({ colorScheme, theme });
72
69
 
73
- useEffect(() => {
74
- if (value && !isBSDateInSupportedRange(value)) {
75
- warnOutOfRangeInDev(value, { min: 2000, max: 2090 });
76
- }
77
- if (defaultValue && !isBSDateInSupportedRange(defaultValue)) {
78
- warnOutOfRangeInDev(defaultValue, { min: 2000, max: 2090 });
79
- }
80
- }, [value, defaultValue]);
81
-
82
70
  useEffect(() => {
83
71
  warnMinMaxInDev(minDate, maxDate);
84
72
  }, [minDate, maxDate]);
@@ -86,14 +74,6 @@ export function NepaliCalendar({
86
74
  const safeDisplay = useMemo(() => {
87
75
  const fallback = getDefaultSupportedBSDate();
88
76
 
89
- if (value && isBSDateInSupportedRange(value)) {
90
- return { year: value.year, month: value.month };
91
- }
92
-
93
- if (defaultValue && isBSDateInSupportedRange(defaultValue)) {
94
- return { year: defaultValue.year, month: defaultValue.month };
95
- }
96
-
97
77
  if (year != null && month != null) {
98
78
  const safe = getSafeCalendarMonth({ year, month });
99
79
  return safe;
@@ -113,10 +93,11 @@ export function NepaliCalendar({
113
93
  }
114
94
 
115
95
  return { year: fallback.year, month: fallback.month };
116
- }, [value, defaultValue, year, month, defaultYear, defaultMonth]);
96
+ }, [year, month, defaultYear, defaultMonth]);
117
97
 
118
98
  const [internalYear, setInternalYear] = useState(safeDisplay.year);
119
99
  const [internalMonth, setInternalMonth] = useState(safeDisplay.month);
100
+ const [isYearPickerOpen, setIsYearPickerOpen] = useState(false);
120
101
 
121
102
  const wasControlledRef = useRef(year !== undefined && month !== undefined);
122
103
 
@@ -132,36 +113,72 @@ export function NepaliCalendar({
132
113
  const safe = getSafeCalendarMonth({
133
114
  year: defaultYear,
134
115
  month: defaultMonth,
135
- value,
136
- defaultValue,
137
116
  });
138
117
  setInternalYear(safe.year);
139
118
  setInternalMonth(safe.month);
140
119
  }
141
- }, [year, month, defaultYear, defaultMonth, value, defaultValue]);
120
+ }, [year, month, defaultYear, defaultMonth]);
142
121
 
143
- const controlledYear = year !== undefined ? getSafeCalendarMonth({ year, month: month ?? 1 }).year : internalYear;
144
- const controlledMonth = year !== undefined ? getSafeCalendarMonth({ year, month: month ?? 1 }).month : internalMonth;
122
+ const isControlled = year !== undefined && month !== undefined;
123
+ const controlledDisplay = isControlled
124
+ ? getSafeCalendarMonth({ year, month })
125
+ : { year: internalYear, month: internalMonth };
126
+ const controlledYear = controlledDisplay.year;
127
+ const controlledMonth = controlledDisplay.month;
145
128
 
146
129
  const handlePrevMonth = useCallback(() => {
147
130
  const prev = getPreviousBSMonth(controlledYear, controlledMonth);
148
- if (year === undefined) {
131
+ if (!isControlled) {
149
132
  const safe = getSafeCalendarMonth({ year: prev.year, month: prev.month });
150
133
  setInternalYear(safe.year);
151
134
  setInternalMonth(safe.month);
152
135
  }
153
136
  onMonthChange?.(prev);
154
- }, [controlledYear, controlledMonth, year, onMonthChange]);
137
+ setIsYearPickerOpen(false);
138
+ }, [controlledYear, controlledMonth, isControlled, onMonthChange]);
155
139
 
156
140
  const handleNextMonth = useCallback(() => {
157
141
  const next = getNextBSMonth(controlledYear, controlledMonth);
158
- if (year === undefined) {
142
+ if (!isControlled) {
159
143
  const safe = getSafeCalendarMonth({ year: next.year, month: next.month });
160
144
  setInternalYear(safe.year);
161
145
  setInternalMonth(safe.month);
162
146
  }
163
147
  onMonthChange?.(next);
164
- }, [controlledYear, controlledMonth, year, onMonthChange]);
148
+ setIsYearPickerOpen(false);
149
+ }, [controlledYear, controlledMonth, isControlled, onMonthChange]);
150
+
151
+ const handleYearPress = useCallback(() => {
152
+ setIsYearPickerOpen((current) => !current);
153
+ }, []);
154
+
155
+ const supportedYears = useMemo(() => {
156
+ const range = getSupportedBSRange();
157
+ const years: number[] = [];
158
+ for (let supportedYear = range.start; supportedYear <= range.end; supportedYear += 1) {
159
+ years.push(supportedYear);
160
+ }
161
+ return years;
162
+ }, []);
163
+
164
+ const handleYearSelect = useCallback(
165
+ (selectedYear: number) => {
166
+ const safe = getSafeCalendarMonth({
167
+ year: selectedYear,
168
+ month: controlledMonth,
169
+ });
170
+
171
+ if (!isControlled) {
172
+ setInternalYear(safe.year);
173
+ setInternalMonth(safe.month);
174
+ }
175
+
176
+ setIsYearPickerOpen(false);
177
+ onYearChange?.(safe);
178
+ onMonthChange?.(safe);
179
+ },
180
+ [controlledMonth, isControlled, onYearChange, onMonthChange]
181
+ );
165
182
 
166
183
  const today = useMemo(() => {
167
184
  try {
@@ -211,28 +228,10 @@ export function NepaliCalendar({
211
228
  }
212
229
  }, [controlledYear, controlledMonth]);
213
230
 
214
- const resolvedValue = value && isBSDateInSupportedRange(value) ? value : null;
215
-
216
- const handleDayPress = useCallback(
217
- (date: BSDateValue) => {
218
- onChange?.(date);
219
- },
220
- [onChange]
221
- );
222
-
223
- const accessibilityLabel = useMemo(() => {
224
- if (!resolvedValue) return undefined;
225
- return createDateAccessibilityLabel(resolvedValue, resolvedLocale, {
226
- selected: true,
227
- today: today !== null && compareBS(resolvedValue, today) === 0,
228
- });
229
- }, [resolvedValue, resolvedLocale, today]);
230
-
231
231
  return (
232
232
  <View
233
233
  style={[styles.container, { backgroundColor: calendarTheme.colors.background }]}
234
234
  testID={testID}
235
- accessibilityLabel={accessibilityLabel}
236
235
  >
237
236
  <CalendarHeader
238
237
  year={controlledYear}
@@ -242,10 +241,62 @@ export function NepaliCalendar({
242
241
  theme={calendarTheme}
243
242
  onPrevMonth={handlePrevMonth}
244
243
  onNextMonth={handleNextMonth}
244
+ onYearPress={handleYearPress}
245
245
  canGoPrev={canGoPrev}
246
246
  canGoNext={canGoNext}
247
247
  />
248
248
 
249
+ {isYearPickerOpen && (
250
+ <ScrollView
251
+ style={styles.yearPicker}
252
+ contentContainerStyle={styles.yearPickerContent}
253
+ nestedScrollEnabled
254
+ >
255
+ {supportedYears.map((supportedYear) => {
256
+ const active = supportedYear === controlledYear;
257
+ const yearLabel =
258
+ numerals === 'devanagari'
259
+ ? String(supportedYear).replace(/[0-9]/g, (digit) =>
260
+ '०१२३४५६७८९'[Number(digit)]
261
+ )
262
+ : String(supportedYear);
263
+
264
+ return (
265
+ <Pressable
266
+ key={supportedYear}
267
+ style={[
268
+ styles.yearButton,
269
+ {
270
+ borderColor: active
271
+ ? calendarTheme.colors.primary
272
+ : calendarTheme.colors.border,
273
+ backgroundColor: active
274
+ ? calendarTheme.colors.primary
275
+ : calendarTheme.colors.surface,
276
+ },
277
+ ]}
278
+ onPress={() => handleYearSelect(supportedYear)}
279
+ accessibilityRole="button"
280
+ accessibilityLabel={`Select ${supportedYear}`}
281
+ >
282
+ <Text
283
+ style={[
284
+ styles.yearButtonText,
285
+ {
286
+ color: active
287
+ ? calendarTheme.colors.primaryText
288
+ : calendarTheme.colors.text,
289
+ },
290
+ ]}
291
+ >
292
+ {yearLabel}
293
+ </Text>
294
+ </Pressable>
295
+ );
296
+ })}
297
+ </ScrollView>
298
+ )}
299
+
249
300
  <CalendarWeekdays
250
301
  locale={resolvedLocale}
251
302
  weekStartsOn={weekStartsOn}
@@ -254,7 +305,6 @@ export function NepaliCalendar({
254
305
 
255
306
  <CalendarGrid
256
307
  grid={grid}
257
- value={resolvedValue}
258
308
  today={today}
259
309
  minDate={minDate}
260
310
  maxDate={maxDate}
@@ -262,9 +312,8 @@ export function NepaliCalendar({
262
312
  theme={calendarTheme}
263
313
  markedDates={markedDates}
264
314
  disabledDates={disabledDates}
265
- onChange={handleDayPress}
315
+ onDayPress={onDayPress}
266
316
  renderDay={renderDay}
267
- rangeValue={rangeValue}
268
317
  locale={resolvedLocale}
269
318
  />
270
319
  </View>
@@ -276,4 +325,27 @@ const styles = StyleSheet.create({
276
325
  borderRadius: 12,
277
326
  overflow: 'hidden',
278
327
  },
328
+ yearPicker: {
329
+ maxHeight: 220,
330
+ },
331
+ yearPickerContent: {
332
+ flexDirection: 'row',
333
+ flexWrap: 'wrap',
334
+ paddingHorizontal: 12,
335
+ paddingBottom: 12,
336
+ gap: 8,
337
+ },
338
+ yearButton: {
339
+ minWidth: 68,
340
+ minHeight: 36,
341
+ borderWidth: 1,
342
+ borderRadius: 8,
343
+ alignItems: 'center',
344
+ justifyContent: 'center',
345
+ paddingHorizontal: 10,
346
+ },
347
+ yearButtonText: {
348
+ fontSize: 14,
349
+ fontWeight: '600',
350
+ },
279
351
  });
@@ -2,7 +2,6 @@ import type { ReactNode } from 'react';
2
2
  import type { BSDateValue } from '../../core/types';
3
3
  import type { LocaleCode, CalendarLocale, NumeralSystem } from '../../core/locale';
4
4
  import type { CalendarTheme } from '../../theme/types';
5
- import type { DateRangeValue } from '../NepaliRangePicker/types';
6
5
 
7
6
  export type CalendarMarkedDate = {
8
7
  type?: 'dot' | 'holiday' | 'event' | 'disabled';
@@ -16,22 +15,14 @@ export type CalendarDayRenderProps = {
16
15
  date: BSDateValue;
17
16
  dateKey: string;
18
17
  day: number;
19
- selected: boolean;
20
18
  today: boolean;
21
19
  disabled: boolean;
22
20
  inCurrentMonth: boolean;
23
21
  marked?: CalendarMarkedDate;
24
- onPress: () => void;
25
- rangeStart?: boolean;
26
- rangeEnd?: boolean;
27
- inRange?: boolean;
22
+ onPress?: () => void;
28
23
  };
29
24
 
30
25
  export type NepaliCalendarProps = {
31
- value?: BSDateValue | null;
32
- defaultValue?: BSDateValue;
33
- onChange?: (date: BSDateValue) => void;
34
-
35
26
  year?: number;
36
27
  month?: number;
37
28
  defaultYear?: number;
@@ -52,11 +43,11 @@ export type NepaliCalendarProps = {
52
43
 
53
44
  disabledDates?: string[] | ((date: BSDateValue) => boolean);
54
45
 
46
+ onDayPress?: (date: BSDateValue) => void;
55
47
  onMonthChange?: (value: { year: number; month: number }) => void;
48
+ onYearChange?: (value: { year: number; month: number }) => void;
56
49
 
57
50
  renderDay?: (props: CalendarDayRenderProps) => ReactNode;
58
51
 
59
- rangeValue?: DateRangeValue;
60
-
61
52
  testID?: string;
62
53
  };
package/src/index.ts CHANGED
@@ -1,8 +1,6 @@
1
1
  export * from './core';
2
2
  export * from './calendar';
3
3
  export * from './components/NepaliCalendar';
4
- export * from './components/NepaliDatePicker';
5
- export * from './components/NepaliRangePicker';
6
4
  export * from './theme';
7
5
  export * from './accessibility';
8
6
  export * from './utils';
@@ -29,16 +29,6 @@ export const LIGHT_THEME: CalendarTheme = {
29
29
  outsideMonthText: '#d1d5db',
30
30
  border: '#e5e7eb',
31
31
  marker: '#2563eb',
32
- overlay: 'rgba(0, 0, 0, 0.5)',
33
- modalBackground: '#ffffff',
34
- fieldBackground: '#ffffff',
35
- fieldBorder: '#e5e7eb',
36
- placeholderText: '#9ca3af',
37
- rangeBackground: '#dbeafe',
38
- rangeText: '#1e40af',
39
- rangeStartBackground: '#2563eb',
40
- rangeEndBackground: '#2563eb',
41
- danger: '#ef4444',
42
32
  },
43
33
  radius: {
44
34
  day: 20,
@@ -70,16 +60,6 @@ export const DARK_THEME: CalendarTheme = {
70
60
  outsideMonthText: '#4b5563',
71
61
  border: '#374151',
72
62
  marker: '#3b82f6',
73
- overlay: 'rgba(0, 0, 0, 0.6)',
74
- modalBackground: '#1f2937',
75
- fieldBackground: '#1f2937',
76
- fieldBorder: '#374151',
77
- placeholderText: '#6b7280',
78
- rangeBackground: '#1e3a5f',
79
- rangeText: '#93c5fd',
80
- rangeStartBackground: '#3b82f6',
81
- rangeEndBackground: '#3b82f6',
82
- danger: '#f87171',
83
63
  },
84
64
  radius: {
85
65
  day: 20,
@@ -13,16 +13,6 @@ export type CalendarTheme = {
13
13
  outsideMonthText: string;
14
14
  border: string;
15
15
  marker: string;
16
- overlay: string;
17
- modalBackground: string;
18
- fieldBackground: string;
19
- fieldBorder: string;
20
- placeholderText: string;
21
- rangeBackground: string;
22
- rangeText: string;
23
- rangeStartBackground: string;
24
- rangeEndBackground: string;
25
- danger: string;
26
16
  };
27
17
  radius: {
28
18
  day: number;
@@ -70,24 +70,16 @@ export function createDateAccessibilityLabel(
70
70
  date: BSDateValue,
71
71
  locale: CalendarLocale,
72
72
  options: {
73
- selected?: boolean;
74
73
  today?: boolean;
75
74
  disabled?: boolean;
76
75
  outsideMonth?: boolean;
77
- rangeStart?: boolean;
78
- rangeEnd?: boolean;
79
- inRange?: boolean;
80
76
  markedLabel?: string;
81
77
  }
82
78
  ): string {
83
79
  const {
84
- selected,
85
80
  today,
86
81
  disabled,
87
82
  outsideMonth,
88
- rangeStart,
89
- rangeEnd,
90
- inRange,
91
83
  markedLabel,
92
84
  } = options;
93
85
 
@@ -99,10 +91,6 @@ export function createDateAccessibilityLabel(
99
91
  parts.push(`${date.year}/${date.month}/${date.day}`);
100
92
  }
101
93
 
102
- if (rangeStart) parts.push('range start');
103
- if (rangeEnd) parts.push('range end');
104
- if (inRange && !rangeStart && !rangeEnd) parts.push('in selected range');
105
- if (selected && !inRange) parts.push('selected');
106
94
  if (today) parts.push('today');
107
95
  if (disabled) parts.push('disabled');
108
96
  if (outsideMonth) parts.push('outside month');
@@ -1,185 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.DatePickerModal = DatePickerModal;
7
- var _react = _interopRequireWildcard(require("react"));
8
- var _reactNative = require("react-native");
9
- var _theme = require("../../theme");
10
- var _utils = require("../../utils");
11
- var _NepaliCalendar = require("../NepaliCalendar");
12
- var _jsxRuntime = require("react/jsx-runtime");
13
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
14
- function DatePickerModal({
15
- visible,
16
- value,
17
- defaultValue,
18
- onChange,
19
- onConfirm,
20
- onCancel,
21
- onClose,
22
- locale,
23
- numerals,
24
- minDate,
25
- maxDate,
26
- markedDates,
27
- disabledDates,
28
- weekStartsOn,
29
- theme,
30
- colorScheme,
31
- title = 'Select Date',
32
- confirmText = 'Confirm',
33
- cancelText = 'Cancel',
34
- testID
35
- }) {
36
- const calendarTheme = (0, _theme.useCalendarTheme)({
37
- colorScheme,
38
- theme
39
- });
40
- const [tempDate, setTempDate] = (0, _react.useState)(() => (0, _utils.getSafeInitialBSDate)(value, defaultValue));
41
- (0, _react.useEffect)(() => {
42
- if (visible) {
43
- setTempDate((0, _utils.getSafeInitialBSDate)(value, defaultValue));
44
- }
45
- }, [visible, value, defaultValue]);
46
- const handleConfirm = (0, _react.useCallback)(() => {
47
- onConfirm?.(tempDate);
48
- onChange?.(tempDate);
49
- onClose?.();
50
- }, [tempDate, onConfirm, onChange, onClose]);
51
- const handleCancel = (0, _react.useCallback)(() => {
52
- onCancel?.();
53
- onClose?.();
54
- }, [onCancel, onClose]);
55
- const handleBackdropPress = (0, _react.useCallback)(() => {
56
- onCancel?.();
57
- onClose?.();
58
- }, [onCancel, onClose]);
59
- const modalContent = (0, _react.useMemo)(() => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
60
- style: [styles.modalContent, {
61
- backgroundColor: calendarTheme.colors.modalBackground
62
- }],
63
- testID: testID,
64
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
65
- style: [styles.title, {
66
- color: calendarTheme.colors.text,
67
- borderBottomColor: calendarTheme.colors.border
68
- }],
69
- children: title
70
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
71
- style: styles.calendarWrapper,
72
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_NepaliCalendar.NepaliCalendar, {
73
- value: tempDate,
74
- onChange: setTempDate,
75
- locale: locale,
76
- numerals: numerals,
77
- minDate: minDate,
78
- maxDate: maxDate,
79
- markedDates: markedDates,
80
- disabledDates: disabledDates,
81
- weekStartsOn: weekStartsOn,
82
- theme: theme,
83
- colorScheme: colorScheme
84
- })
85
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
86
- style: [styles.buttonRow, {
87
- borderTopColor: calendarTheme.colors.border
88
- }],
89
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
90
- style: [styles.button, styles.cancelButton],
91
- onPress: handleCancel,
92
- accessibilityRole: "button",
93
- accessibilityLabel: cancelText,
94
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
95
- style: [styles.cancelText, {
96
- color: calendarTheme.colors.mutedText
97
- }],
98
- children: cancelText
99
- })
100
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
101
- style: [styles.button, {
102
- backgroundColor: calendarTheme.colors.primary
103
- }],
104
- onPress: handleConfirm,
105
- accessibilityRole: "button",
106
- accessibilityLabel: "Confirm selected date",
107
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
108
- style: [styles.confirmText, {
109
- color: calendarTheme.colors.primaryText
110
- }],
111
- children: confirmText
112
- })
113
- })]
114
- })]
115
- }), [tempDate, title, locale, numerals, minDate, maxDate, markedDates, disabledDates, weekStartsOn, theme, colorScheme, testID, cancelText, confirmText, calendarTheme, handleCancel, handleConfirm]);
116
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Modal, {
117
- visible: visible,
118
- transparent: true,
119
- animationType: "fade",
120
- onRequestClose: handleCancel,
121
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableWithoutFeedback, {
122
- onPress: handleBackdropPress,
123
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
124
- style: [styles.backdrop, {
125
- backgroundColor: calendarTheme.colors.overlay
126
- }],
127
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableWithoutFeedback, {
128
- children: modalContent
129
- })
130
- })
131
- })
132
- });
133
- }
134
- const styles = _reactNative.StyleSheet.create({
135
- backdrop: {
136
- flex: 1,
137
- justifyContent: 'center',
138
- alignItems: 'center',
139
- paddingHorizontal: 20
140
- },
141
- modalContent: {
142
- borderRadius: 16,
143
- overflow: 'hidden',
144
- width: '100%',
145
- maxWidth: 400
146
- },
147
- title: {
148
- fontSize: 18,
149
- fontWeight: '600',
150
- textAlign: 'center',
151
- paddingVertical: 16,
152
- paddingHorizontal: 16,
153
- borderBottomWidth: _reactNative.StyleSheet.hairlineWidth
154
- },
155
- calendarWrapper: {
156
- padding: 8
157
- },
158
- buttonRow: {
159
- flexDirection: 'row',
160
- justifyContent: 'flex-end',
161
- paddingHorizontal: 16,
162
- paddingVertical: 12,
163
- gap: 12,
164
- borderTopWidth: _reactNative.StyleSheet.hairlineWidth
165
- },
166
- button: {
167
- paddingVertical: 10,
168
- paddingHorizontal: 20,
169
- borderRadius: 8,
170
- minWidth: 80,
171
- alignItems: 'center'
172
- },
173
- cancelButton: {
174
- backgroundColor: 'transparent'
175
- },
176
- cancelText: {
177
- fontSize: 16,
178
- fontWeight: '600'
179
- },
180
- confirmText: {
181
- fontSize: 16,
182
- fontWeight: '600'
183
- }
184
- });
185
- //# sourceMappingURL=DatePickerModal.js.map