react-native-bikram-sambat 0.1.3 → 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.
- package/CHANGELOG.md +19 -0
- package/README.md +44 -211
- package/lib/commonjs/accessibility/index.js +1 -1
- package/lib/commonjs/accessibility/labels.js +3 -4
- package/lib/commonjs/accessibility/labels.js.map +1 -1
- package/lib/commonjs/calendar/get-calendar-month-grid.js +5 -5
- package/lib/commonjs/calendar/index.js +1 -1
- package/lib/commonjs/components/NepaliCalendar/CalendarDay.js +10 -43
- package/lib/commonjs/components/NepaliCalendar/CalendarDay.js.map +1 -1
- package/lib/commonjs/components/NepaliCalendar/CalendarGrid.js +8 -25
- package/lib/commonjs/components/NepaliCalendar/CalendarGrid.js.map +1 -1
- package/lib/commonjs/components/NepaliCalendar/CalendarHeader.js +26 -14
- package/lib/commonjs/components/NepaliCalendar/CalendarHeader.js.map +1 -1
- package/lib/commonjs/components/NepaliCalendar/NepaliCalendar.js +119 -87
- package/lib/commonjs/components/NepaliCalendar/NepaliCalendar.js.map +1 -1
- package/lib/commonjs/components/NepaliCalendar/index.js +1 -1
- package/lib/commonjs/core/arithmetic.js +3 -3
- package/lib/commonjs/core/bsData.js +107 -8
- package/lib/commonjs/core/bsData.js.map +1 -1
- package/lib/commonjs/core/conversion.js +4 -4
- package/lib/commonjs/core/conversion.js.map +1 -1
- package/lib/commonjs/core/dateKey.js +1 -1
- package/lib/commonjs/core/format/format.js +9 -9
- package/lib/commonjs/core/format/format.js.map +1 -1
- package/lib/commonjs/core/format/index.js +2 -2
- package/lib/commonjs/core/format/parse.js +3 -3
- package/lib/commonjs/core/format/parse.js.map +1 -1
- package/lib/commonjs/core/index.js +19 -19
- package/lib/commonjs/core/index.js.map +1 -1
- package/lib/commonjs/core/locale/index.js +2 -2
- package/lib/commonjs/core/numerals/index.js +1 -1
- package/lib/commonjs/core/validation.js +4 -3
- package/lib/commonjs/core/validation.js.map +1 -1
- package/lib/commonjs/index.js +24 -46
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/theme/create-theme.js +1 -1
- package/lib/commonjs/theme/default-theme.js +2 -22
- package/lib/commonjs/theme/default-theme.js.map +1 -1
- package/lib/commonjs/theme/index.js +2 -2
- package/lib/commonjs/utils/date-helpers.js +4 -12
- package/lib/commonjs/utils/date-helpers.js.map +1 -1
- package/lib/commonjs/utils/index.js +1 -1
- package/lib/module/accessibility/index.js +1 -1
- package/lib/module/accessibility/index.js.map +1 -1
- package/lib/module/accessibility/labels.js +2 -3
- package/lib/module/accessibility/labels.js.map +1 -1
- package/lib/module/calendar/get-calendar-month-grid.js +6 -6
- package/lib/module/calendar/get-calendar-month-grid.js.map +1 -1
- package/lib/module/calendar/index.js +1 -1
- package/lib/module/calendar/index.js.map +1 -1
- package/lib/module/components/NepaliCalendar/CalendarDay.js +9 -42
- package/lib/module/components/NepaliCalendar/CalendarDay.js.map +1 -1
- package/lib/module/components/NepaliCalendar/CalendarGrid.js +8 -25
- package/lib/module/components/NepaliCalendar/CalendarGrid.js.map +1 -1
- package/lib/module/components/NepaliCalendar/CalendarHeader.js +22 -10
- package/lib/module/components/NepaliCalendar/CalendarHeader.js.map +1 -1
- package/lib/module/components/NepaliCalendar/NepaliCalendar.js +102 -70
- package/lib/module/components/NepaliCalendar/NepaliCalendar.js.map +1 -1
- package/lib/module/components/NepaliCalendar/index.js +1 -1
- package/lib/module/components/NepaliCalendar/index.js.map +1 -1
- package/lib/module/core/arithmetic.js +3 -3
- package/lib/module/core/arithmetic.js.map +1 -1
- package/lib/module/core/bsData.js +107 -8
- package/lib/module/core/bsData.js.map +1 -1
- package/lib/module/core/conversion.js +4 -4
- package/lib/module/core/conversion.js.map +1 -1
- package/lib/module/core/dateKey.js +1 -1
- package/lib/module/core/dateKey.js.map +1 -1
- package/lib/module/core/format/format.js +6 -6
- package/lib/module/core/format/format.js.map +1 -1
- package/lib/module/core/format/index.js +2 -2
- package/lib/module/core/format/index.js.map +1 -1
- package/lib/module/core/format/parse.js +2 -2
- package/lib/module/core/format/parse.js.map +1 -1
- package/lib/module/core/index.js +10 -10
- package/lib/module/core/index.js.map +1 -1
- package/lib/module/core/locale/index.js +2 -2
- package/lib/module/core/locale/index.js.map +1 -1
- package/lib/module/core/numerals/index.js +1 -1
- package/lib/module/core/numerals/index.js.map +1 -1
- package/lib/module/core/validation.js +4 -3
- package/lib/module/core/validation.js.map +1 -1
- package/lib/module/index.js +6 -8
- package/lib/module/index.js.map +1 -1
- package/lib/module/package.json +1 -0
- package/lib/module/theme/create-theme.js +1 -1
- package/lib/module/theme/create-theme.js.map +1 -1
- package/lib/module/theme/default-theme.js +2 -22
- package/lib/module/theme/default-theme.js.map +1 -1
- package/lib/module/theme/index.js +2 -2
- package/lib/module/theme/index.js.map +1 -1
- package/lib/module/utils/date-helpers.js +2 -10
- package/lib/module/utils/date-helpers.js.map +1 -1
- package/lib/module/utils/index.js +1 -1
- package/lib/module/utils/index.js.map +1 -1
- package/lib/typescript/src/accessibility/labels.d.ts +1 -1
- package/lib/typescript/src/accessibility/labels.d.ts.map +1 -1
- package/lib/typescript/src/components/NepaliCalendar/CalendarDay.d.ts +1 -5
- package/lib/typescript/src/components/NepaliCalendar/CalendarDay.d.ts.map +1 -1
- package/lib/typescript/src/components/NepaliCalendar/CalendarGrid.d.ts +1 -4
- package/lib/typescript/src/components/NepaliCalendar/CalendarGrid.d.ts.map +1 -1
- package/lib/typescript/src/components/NepaliCalendar/CalendarHeader.d.ts +1 -0
- package/lib/typescript/src/components/NepaliCalendar/CalendarHeader.d.ts.map +1 -1
- package/lib/typescript/src/components/NepaliCalendar/NepaliCalendar.d.ts +1 -1
- package/lib/typescript/src/components/NepaliCalendar/NepaliCalendar.d.ts.map +1 -1
- package/lib/typescript/src/components/NepaliCalendar/types.d.ts +6 -10
- package/lib/typescript/src/components/NepaliCalendar/types.d.ts.map +1 -1
- package/lib/typescript/src/core/bsData.d.ts.map +1 -1
- package/lib/typescript/src/core/validation.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +0 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/theme/default-theme.d.ts.map +1 -1
- package/lib/typescript/src/theme/types.d.ts +0 -10
- package/lib/typescript/src/theme/types.d.ts.map +1 -1
- package/lib/typescript/src/utils/date-helpers.d.ts +0 -4
- package/lib/typescript/src/utils/date-helpers.d.ts.map +1 -1
- package/package.json +4 -8
- package/src/accessibility/labels.ts +0 -2
- package/src/components/NepaliCalendar/CalendarDay.tsx +6 -65
- package/src/components/NepaliCalendar/CalendarGrid.tsx +12 -32
- package/src/components/NepaliCalendar/CalendarHeader.tsx +18 -2
- package/src/components/NepaliCalendar/NepaliCalendar.tsx +128 -56
- package/src/components/NepaliCalendar/types.ts +3 -12
- package/src/core/bsData.ts +105 -6
- package/src/core/conversion.ts +1 -1
- package/src/core/validation.ts +7 -1
- package/src/index.ts +0 -2
- package/src/theme/default-theme.ts +0 -20
- package/src/theme/types.ts +0 -10
- package/src/utils/date-helpers.ts +0 -12
- package/lib/commonjs/components/NepaliDatePicker/DatePickerModal.js +0 -185
- package/lib/commonjs/components/NepaliDatePicker/DatePickerModal.js.map +0 -1
- package/lib/commonjs/components/NepaliDatePicker/NepaliDatePicker.js +0 -148
- package/lib/commonjs/components/NepaliDatePicker/NepaliDatePicker.js.map +0 -1
- package/lib/commonjs/components/NepaliDatePicker/index.js +0 -20
- package/lib/commonjs/components/NepaliDatePicker/index.js.map +0 -1
- package/lib/commonjs/components/NepaliDatePicker/types.js +0 -6
- package/lib/commonjs/components/NepaliDatePicker/types.js.map +0 -1
- package/lib/commonjs/components/NepaliRangePicker/NepaliRangePicker.js +0 -187
- package/lib/commonjs/components/NepaliRangePicker/NepaliRangePicker.js.map +0 -1
- package/lib/commonjs/components/NepaliRangePicker/RangePickerModal.js +0 -275
- package/lib/commonjs/components/NepaliRangePicker/RangePickerModal.js.map +0 -1
- package/lib/commonjs/components/NepaliRangePicker/index.js +0 -57
- package/lib/commonjs/components/NepaliRangePicker/index.js.map +0 -1
- package/lib/commonjs/components/NepaliRangePicker/range-utils.js +0 -70
- package/lib/commonjs/components/NepaliRangePicker/range-utils.js.map +0 -1
- package/lib/commonjs/components/NepaliRangePicker/types.js +0 -6
- package/lib/commonjs/components/NepaliRangePicker/types.js.map +0 -1
- package/lib/module/components/NepaliDatePicker/DatePickerModal.js +0 -180
- package/lib/module/components/NepaliDatePicker/DatePickerModal.js.map +0 -1
- package/lib/module/components/NepaliDatePicker/NepaliDatePicker.js +0 -143
- package/lib/module/components/NepaliDatePicker/NepaliDatePicker.js.map +0 -1
- package/lib/module/components/NepaliDatePicker/index.js +0 -5
- package/lib/module/components/NepaliDatePicker/index.js.map +0 -1
- package/lib/module/components/NepaliDatePicker/types.js +0 -4
- package/lib/module/components/NepaliDatePicker/types.js.map +0 -1
- package/lib/module/components/NepaliRangePicker/NepaliRangePicker.js +0 -182
- package/lib/module/components/NepaliRangePicker/NepaliRangePicker.js.map +0 -1
- package/lib/module/components/NepaliRangePicker/RangePickerModal.js +0 -270
- package/lib/module/components/NepaliRangePicker/RangePickerModal.js.map +0 -1
- package/lib/module/components/NepaliRangePicker/index.js +0 -6
- package/lib/module/components/NepaliRangePicker/index.js.map +0 -1
- package/lib/module/components/NepaliRangePicker/range-utils.js +0 -61
- package/lib/module/components/NepaliRangePicker/range-utils.js.map +0 -1
- package/lib/module/components/NepaliRangePicker/types.js +0 -4
- package/lib/module/components/NepaliRangePicker/types.js.map +0 -1
- package/lib/typescript/src/components/NepaliDatePicker/DatePickerModal.d.ts +0 -4
- package/lib/typescript/src/components/NepaliDatePicker/DatePickerModal.d.ts.map +0 -1
- package/lib/typescript/src/components/NepaliDatePicker/NepaliDatePicker.d.ts +0 -4
- package/lib/typescript/src/components/NepaliDatePicker/NepaliDatePicker.d.ts.map +0 -1
- package/lib/typescript/src/components/NepaliDatePicker/index.d.ts +0 -4
- package/lib/typescript/src/components/NepaliDatePicker/index.d.ts.map +0 -1
- package/lib/typescript/src/components/NepaliDatePicker/types.d.ts +0 -50
- package/lib/typescript/src/components/NepaliDatePicker/types.d.ts.map +0 -1
- package/lib/typescript/src/components/NepaliRangePicker/NepaliRangePicker.d.ts +0 -4
- package/lib/typescript/src/components/NepaliRangePicker/NepaliRangePicker.d.ts.map +0 -1
- package/lib/typescript/src/components/NepaliRangePicker/RangePickerModal.d.ts +0 -4
- package/lib/typescript/src/components/NepaliRangePicker/RangePickerModal.d.ts.map +0 -1
- package/lib/typescript/src/components/NepaliRangePicker/index.d.ts +0 -5
- package/lib/typescript/src/components/NepaliRangePicker/index.d.ts.map +0 -1
- package/lib/typescript/src/components/NepaliRangePicker/range-utils.d.ts +0 -13
- package/lib/typescript/src/components/NepaliRangePicker/range-utils.d.ts.map +0 -1
- package/lib/typescript/src/components/NepaliRangePicker/types.d.ts +0 -61
- package/lib/typescript/src/components/NepaliRangePicker/types.d.ts.map +0 -1
- package/src/components/NepaliDatePicker/DatePickerModal.tsx +0 -220
- package/src/components/NepaliDatePicker/NepaliDatePicker.tsx +0 -171
- package/src/components/NepaliDatePicker/index.ts +0 -3
- package/src/components/NepaliDatePicker/types.ts +0 -70
- package/src/components/NepaliRangePicker/NepaliRangePicker.tsx +0 -206
- package/src/components/NepaliRangePicker/RangePickerModal.tsx +0 -336
- package/src/components/NepaliRangePicker/index.ts +0 -11
- package/src/components/NepaliRangePicker/range-utils.ts +0 -75
- package/src/components/NepaliRangePicker/types.ts +0 -84
|
@@ -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 {
|
|
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
|
-
}, [
|
|
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
|
|
120
|
+
}, [year, month, defaultYear, defaultMonth]);
|
|
142
121
|
|
|
143
|
-
const
|
|
144
|
-
const
|
|
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 (
|
|
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
|
-
|
|
137
|
+
setIsYearPickerOpen(false);
|
|
138
|
+
}, [controlledYear, controlledMonth, isControlled, onMonthChange]);
|
|
155
139
|
|
|
156
140
|
const handleNextMonth = useCallback(() => {
|
|
157
141
|
const next = getNextBSMonth(controlledYear, controlledMonth);
|
|
158
|
-
if (
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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/core/bsData.ts
CHANGED
|
@@ -28,14 +28,113 @@ export type BSYearOffset = {
|
|
|
28
28
|
readonly totalDays: number;
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
// This placeholder exists only to prove the conversion architecture.
|
|
31
|
+
// Imported from the upstream `@nakarmi23/bikram-sambat` year table and capped to
|
|
32
|
+
// the range we currently support in this package.
|
|
34
33
|
export const BS_CALENDAR_DATA: BSCalendarData = {
|
|
35
|
-
anchorBS: { calendar: 'BS', year:
|
|
36
|
-
anchorAD: { calendar: 'AD', year:
|
|
34
|
+
anchorBS: { calendar: 'BS', year: 2000, month: 1, day: 1 },
|
|
35
|
+
anchorAD: { calendar: 'AD', year: 1943, month: 4, day: 14 },
|
|
37
36
|
monthLengthsByYear: {
|
|
38
|
-
|
|
37
|
+
2000: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
|
|
38
|
+
2001: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
39
|
+
2002: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
|
40
|
+
2003: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
|
41
|
+
2004: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
|
|
42
|
+
2005: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
43
|
+
2006: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
|
44
|
+
2007: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
|
45
|
+
2008: [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31],
|
|
46
|
+
2009: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
47
|
+
2010: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
|
48
|
+
2011: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
|
49
|
+
2012: [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
|
|
50
|
+
2013: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
51
|
+
2014: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
|
52
|
+
2015: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
|
53
|
+
2016: [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
|
|
54
|
+
2017: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
55
|
+
2018: [31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
|
56
|
+
2019: [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
|
|
57
|
+
2020: [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
58
|
+
2021: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
59
|
+
2022: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
|
|
60
|
+
2023: [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
|
|
61
|
+
2024: [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
62
|
+
2025: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
63
|
+
2026: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
|
64
|
+
2027: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
|
|
65
|
+
2028: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
66
|
+
2029: [31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30],
|
|
67
|
+
2030: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
|
68
|
+
2031: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
|
|
69
|
+
2032: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
70
|
+
2033: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
|
71
|
+
2034: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
|
72
|
+
2035: [30, 32, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31],
|
|
73
|
+
2036: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
74
|
+
2037: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
|
75
|
+
2038: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
|
76
|
+
2039: [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
|
|
77
|
+
2040: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
78
|
+
2041: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
|
79
|
+
2042: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
|
80
|
+
2043: [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
|
|
81
|
+
2044: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
82
|
+
2045: [31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
|
83
|
+
2046: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
|
84
|
+
2047: [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
85
|
+
2048: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
86
|
+
2049: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
|
|
87
|
+
2050: [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
|
|
88
|
+
2051: [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
89
|
+
2052: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
90
|
+
2053: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
|
|
91
|
+
2054: [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
|
|
92
|
+
2055: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
93
|
+
2056: [31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30],
|
|
94
|
+
2057: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
|
95
|
+
2058: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
|
|
96
|
+
2059: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
97
|
+
2060: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
|
98
|
+
2061: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
|
99
|
+
2062: [30, 32, 31, 32, 31, 31, 29, 30, 29, 30, 29, 31],
|
|
100
|
+
2063: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
101
|
+
2064: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
|
102
|
+
2065: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
|
103
|
+
2066: [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31],
|
|
104
|
+
2067: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
105
|
+
2068: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
|
106
|
+
2069: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
|
107
|
+
2070: [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
|
|
108
|
+
2071: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
109
|
+
2072: [31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
|
110
|
+
2073: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
|
111
|
+
2074: [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
112
|
+
2075: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
113
|
+
2076: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
|
|
114
|
+
2077: [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
|
|
115
|
+
2078: [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
116
|
+
2079: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
117
|
+
2080: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
|
|
118
|
+
2081: [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
|
|
119
|
+
2082: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
120
|
+
2083: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
121
|
+
2084: [31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30],
|
|
122
|
+
2085: [31, 32, 31, 32, 30, 31, 30, 30, 29, 30, 30, 30],
|
|
123
|
+
2086: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30],
|
|
124
|
+
2087: [31, 31, 32, 31, 31, 31, 30, 30, 29, 30, 30, 30],
|
|
125
|
+
2088: [30, 31, 32, 32, 30, 31, 30, 30, 29, 30, 30, 30],
|
|
126
|
+
2089: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30],
|
|
127
|
+
2090: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30],
|
|
128
|
+
2091: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
|
129
|
+
2092: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
|
130
|
+
2093: [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31],
|
|
131
|
+
2094: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
132
|
+
2095: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
|
133
|
+
2096: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
|
134
|
+
2097: [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
|
|
135
|
+
2098: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
136
|
+
2099: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
|
137
|
+
2100: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
|
39
138
|
},
|
|
40
139
|
};
|
|
41
140
|
|
package/src/core/conversion.ts
CHANGED
|
@@ -68,6 +68,6 @@ function throwUnsupportedRange(): never {
|
|
|
68
68
|
const range = getSupportedBSYearRange();
|
|
69
69
|
|
|
70
70
|
throw new RangeError(
|
|
71
|
-
`Conversion is limited to BS years ${range.min}-${range.max}
|
|
71
|
+
`Conversion is limited to supported BS years ${range.min}-${range.max}.`
|
|
72
72
|
);
|
|
73
73
|
}
|
package/src/core/validation.ts
CHANGED
|
@@ -68,7 +68,13 @@ export function clampBSDateToSupportedRange(date: BSDateValue): BSDateValue {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
if (date.year > range.max) {
|
|
71
|
-
|
|
71
|
+
const maxYearMonths = BS_CALENDAR_DATA.monthLengthsByYear[range.max];
|
|
72
|
+
return {
|
|
73
|
+
calendar: 'BS',
|
|
74
|
+
year: range.max,
|
|
75
|
+
month: 12,
|
|
76
|
+
day: maxYearMonths ? maxYearMonths[11] : 30,
|
|
77
|
+
};
|
|
72
78
|
}
|
|
73
79
|
|
|
74
80
|
const monthLengths = BS_CALENDAR_DATA.monthLengthsByYear[date.year];
|
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,
|
package/src/theme/types.ts
CHANGED
|
@@ -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');
|