react-native-bikram-sambat 0.1.0
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/LICENSE +21 -0
- package/README.md +340 -0
- package/lib/commonjs/accessibility/index.js +25 -0
- package/lib/commonjs/accessibility/index.js.map +1 -0
- package/lib/commonjs/accessibility/labels.js +20 -0
- package/lib/commonjs/accessibility/labels.js.map +1 -0
- package/lib/commonjs/calendar/calendar-types.js +6 -0
- package/lib/commonjs/calendar/calendar-types.js.map +1 -0
- package/lib/commonjs/calendar/get-calendar-month-grid.js +114 -0
- package/lib/commonjs/calendar/get-calendar-month-grid.js.map +1 -0
- package/lib/commonjs/calendar/index.js +13 -0
- package/lib/commonjs/calendar/index.js.map +1 -0
- package/lib/commonjs/components/NepaliCalendar/CalendarDay.js +137 -0
- package/lib/commonjs/components/NepaliCalendar/CalendarDay.js.map +1 -0
- package/lib/commonjs/components/NepaliCalendar/CalendarGrid.js +116 -0
- package/lib/commonjs/components/NepaliCalendar/CalendarGrid.js.map +1 -0
- package/lib/commonjs/components/NepaliCalendar/CalendarHeader.js +114 -0
- package/lib/commonjs/components/NepaliCalendar/CalendarHeader.js.map +1 -0
- package/lib/commonjs/components/NepaliCalendar/CalendarWeekdays.js +44 -0
- package/lib/commonjs/components/NepaliCalendar/CalendarWeekdays.js.map +1 -0
- package/lib/commonjs/components/NepaliCalendar/NepaliCalendar.js +288 -0
- package/lib/commonjs/components/NepaliCalendar/NepaliCalendar.js.map +1 -0
- package/lib/commonjs/components/NepaliCalendar/index.js +13 -0
- package/lib/commonjs/components/NepaliCalendar/index.js.map +1 -0
- package/lib/commonjs/components/NepaliCalendar/types.js +6 -0
- package/lib/commonjs/components/NepaliCalendar/types.js.map +1 -0
- package/lib/commonjs/components/NepaliDatePicker/DatePickerModal.js +185 -0
- package/lib/commonjs/components/NepaliDatePicker/DatePickerModal.js.map +1 -0
- package/lib/commonjs/components/NepaliDatePicker/NepaliDatePicker.js +148 -0
- package/lib/commonjs/components/NepaliDatePicker/NepaliDatePicker.js.map +1 -0
- package/lib/commonjs/components/NepaliDatePicker/index.js +20 -0
- package/lib/commonjs/components/NepaliDatePicker/index.js.map +1 -0
- package/lib/commonjs/components/NepaliDatePicker/types.js +6 -0
- package/lib/commonjs/components/NepaliDatePicker/types.js.map +1 -0
- package/lib/commonjs/components/NepaliRangePicker/NepaliRangePicker.js +187 -0
- package/lib/commonjs/components/NepaliRangePicker/NepaliRangePicker.js.map +1 -0
- package/lib/commonjs/components/NepaliRangePicker/RangePickerModal.js +275 -0
- package/lib/commonjs/components/NepaliRangePicker/RangePickerModal.js.map +1 -0
- package/lib/commonjs/components/NepaliRangePicker/index.js +57 -0
- package/lib/commonjs/components/NepaliRangePicker/index.js.map +1 -0
- package/lib/commonjs/components/NepaliRangePicker/range-utils.js +70 -0
- package/lib/commonjs/components/NepaliRangePicker/range-utils.js.map +1 -0
- package/lib/commonjs/components/NepaliRangePicker/types.js +6 -0
- package/lib/commonjs/components/NepaliRangePicker/types.js.map +1 -0
- package/lib/commonjs/core/arithmetic.js +36 -0
- package/lib/commonjs/core/arithmetic.js.map +1 -0
- package/lib/commonjs/core/bsData.js +89 -0
- package/lib/commonjs/core/bsData.js.map +1 -0
- package/lib/commonjs/core/conversion.js +53 -0
- package/lib/commonjs/core/conversion.js.map +1 -0
- package/lib/commonjs/core/dateKey.js +31 -0
- package/lib/commonjs/core/dateKey.js.map +1 -0
- package/lib/commonjs/core/epochDay.js +47 -0
- package/lib/commonjs/core/epochDay.js.map +1 -0
- package/lib/commonjs/core/format/format.js +86 -0
- package/lib/commonjs/core/format/format.js.map +1 -0
- package/lib/commonjs/core/format/index.js +20 -0
- package/lib/commonjs/core/format/index.js.map +1 -0
- package/lib/commonjs/core/format/parse.js +41 -0
- package/lib/commonjs/core/format/parse.js.map +1 -0
- package/lib/commonjs/core/format/tokens.js +9 -0
- package/lib/commonjs/core/format/tokens.js.map +1 -0
- package/lib/commonjs/core/index.js +116 -0
- package/lib/commonjs/core/index.js.map +1 -0
- package/lib/commonjs/core/locale/en.js +15 -0
- package/lib/commonjs/core/locale/en.js.map +1 -0
- package/lib/commonjs/core/locale/index.js +20 -0
- package/lib/commonjs/core/locale/index.js.map +1 -0
- package/lib/commonjs/core/locale/ne.js +15 -0
- package/lib/commonjs/core/locale/ne.js.map +1 -0
- package/lib/commonjs/core/locale/types.js +2 -0
- package/lib/commonjs/core/locale/types.js.map +1 -0
- package/lib/commonjs/core/numerals/index.js +19 -0
- package/lib/commonjs/core/numerals/index.js.map +1 -0
- package/lib/commonjs/core/numerals/nepali-numerals.js +28 -0
- package/lib/commonjs/core/numerals/nepali-numerals.js.map +1 -0
- package/lib/commonjs/core/types.js +2 -0
- package/lib/commonjs/core/types.js.map +1 -0
- package/lib/commonjs/core/validation.js +125 -0
- package/lib/commonjs/core/validation.js.map +1 -0
- package/lib/commonjs/core/validation.test.js +248 -0
- package/lib/commonjs/core/validation.test.js.map +1 -0
- package/lib/commonjs/exports.test.js +133 -0
- package/lib/commonjs/exports.test.js.map +1 -0
- package/lib/commonjs/index.js +94 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/phase2.test.js +446 -0
- package/lib/commonjs/phase2.test.js.map +1 -0
- package/lib/commonjs/phase3.test.js +91 -0
- package/lib/commonjs/phase3.test.js.map +1 -0
- package/lib/commonjs/phase4.test.js +89 -0
- package/lib/commonjs/phase4.test.js.map +1 -0
- package/lib/commonjs/phase5.test.js +246 -0
- package/lib/commonjs/phase5.test.js.map +1 -0
- package/lib/commonjs/phase7.test.js +284 -0
- package/lib/commonjs/phase7.test.js.map +1 -0
- package/lib/commonjs/range-helpers.test.js +182 -0
- package/lib/commonjs/range-helpers.test.js.map +1 -0
- package/lib/commonjs/theme/create-theme.js +37 -0
- package/lib/commonjs/theme/create-theme.js.map +1 -0
- package/lib/commonjs/theme/default-theme.js +99 -0
- package/lib/commonjs/theme/default-theme.js.map +1 -0
- package/lib/commonjs/theme/index.js +26 -0
- package/lib/commonjs/theme/index.js.map +1 -0
- package/lib/commonjs/theme/types.js +6 -0
- package/lib/commonjs/theme/types.js.map +1 -0
- package/lib/commonjs/utils/date-helpers.js +106 -0
- package/lib/commonjs/utils/date-helpers.js.map +1 -0
- package/lib/commonjs/utils/index.js +49 -0
- package/lib/commonjs/utils/index.js.map +1 -0
- package/lib/module/accessibility/index.js +4 -0
- package/lib/module/accessibility/index.js.map +1 -0
- package/lib/module/accessibility/labels.js +15 -0
- package/lib/module/accessibility/labels.js.map +1 -0
- package/lib/module/calendar/calendar-types.js +4 -0
- package/lib/module/calendar/calendar-types.js.map +1 -0
- package/lib/module/calendar/get-calendar-month-grid.js +111 -0
- package/lib/module/calendar/get-calendar-month-grid.js.map +1 -0
- package/lib/module/calendar/index.js +4 -0
- package/lib/module/calendar/index.js.map +1 -0
- package/lib/module/components/NepaliCalendar/CalendarDay.js +132 -0
- package/lib/module/components/NepaliCalendar/CalendarDay.js.map +1 -0
- package/lib/module/components/NepaliCalendar/CalendarGrid.js +111 -0
- package/lib/module/components/NepaliCalendar/CalendarGrid.js.map +1 -0
- package/lib/module/components/NepaliCalendar/CalendarHeader.js +109 -0
- package/lib/module/components/NepaliCalendar/CalendarHeader.js.map +1 -0
- package/lib/module/components/NepaliCalendar/CalendarWeekdays.js +39 -0
- package/lib/module/components/NepaliCalendar/CalendarWeekdays.js.map +1 -0
- package/lib/module/components/NepaliCalendar/NepaliCalendar.js +283 -0
- package/lib/module/components/NepaliCalendar/NepaliCalendar.js.map +1 -0
- package/lib/module/components/NepaliCalendar/index.js +4 -0
- package/lib/module/components/NepaliCalendar/index.js.map +1 -0
- package/lib/module/components/NepaliCalendar/types.js +4 -0
- package/lib/module/components/NepaliCalendar/types.js.map +1 -0
- package/lib/module/components/NepaliDatePicker/DatePickerModal.js +180 -0
- package/lib/module/components/NepaliDatePicker/DatePickerModal.js.map +1 -0
- package/lib/module/components/NepaliDatePicker/NepaliDatePicker.js +143 -0
- package/lib/module/components/NepaliDatePicker/NepaliDatePicker.js.map +1 -0
- package/lib/module/components/NepaliDatePicker/index.js +5 -0
- package/lib/module/components/NepaliDatePicker/index.js.map +1 -0
- package/lib/module/components/NepaliDatePicker/types.js +4 -0
- package/lib/module/components/NepaliDatePicker/types.js.map +1 -0
- package/lib/module/components/NepaliRangePicker/NepaliRangePicker.js +182 -0
- package/lib/module/components/NepaliRangePicker/NepaliRangePicker.js.map +1 -0
- package/lib/module/components/NepaliRangePicker/RangePickerModal.js +270 -0
- package/lib/module/components/NepaliRangePicker/RangePickerModal.js.map +1 -0
- package/lib/module/components/NepaliRangePicker/index.js +6 -0
- package/lib/module/components/NepaliRangePicker/index.js.map +1 -0
- package/lib/module/components/NepaliRangePicker/range-utils.js +61 -0
- package/lib/module/components/NepaliRangePicker/range-utils.js.map +1 -0
- package/lib/module/components/NepaliRangePicker/types.js +4 -0
- package/lib/module/components/NepaliRangePicker/types.js.map +1 -0
- package/lib/module/core/arithmetic.js +29 -0
- package/lib/module/core/arithmetic.js.map +1 -0
- package/lib/module/core/bsData.js +82 -0
- package/lib/module/core/bsData.js.map +1 -0
- package/lib/module/core/conversion.js +48 -0
- package/lib/module/core/conversion.js.map +1 -0
- package/lib/module/core/dateKey.js +26 -0
- package/lib/module/core/dateKey.js.map +1 -0
- package/lib/module/core/epochDay.js +39 -0
- package/lib/module/core/epochDay.js.map +1 -0
- package/lib/module/core/format/format.js +82 -0
- package/lib/module/core/format/format.js.map +1 -0
- package/lib/module/core/format/index.js +5 -0
- package/lib/module/core/format/index.js.map +1 -0
- package/lib/module/core/format/parse.js +37 -0
- package/lib/module/core/format/parse.js.map +1 -0
- package/lib/module/core/format/tokens.js +5 -0
- package/lib/module/core/format/tokens.js.map +1 -0
- package/lib/module/core/index.js +13 -0
- package/lib/module/core/index.js.map +1 -0
- package/lib/module/core/locale/en.js +11 -0
- package/lib/module/core/locale/en.js.map +1 -0
- package/lib/module/core/locale/index.js +5 -0
- package/lib/module/core/locale/index.js.map +1 -0
- package/lib/module/core/locale/ne.js +11 -0
- package/lib/module/core/locale/ne.js.map +1 -0
- package/lib/module/core/locale/types.js +2 -0
- package/lib/module/core/locale/types.js.map +1 -0
- package/lib/module/core/numerals/index.js +4 -0
- package/lib/module/core/numerals/index.js.map +1 -0
- package/lib/module/core/numerals/nepali-numerals.js +23 -0
- package/lib/module/core/numerals/nepali-numerals.js.map +1 -0
- package/lib/module/core/types.js +2 -0
- package/lib/module/core/types.js.map +1 -0
- package/lib/module/core/validation.js +115 -0
- package/lib/module/core/validation.js.map +1 -0
- package/lib/module/core/validation.test.js +248 -0
- package/lib/module/core/validation.test.js.map +1 -0
- package/lib/module/exports.test.js +133 -0
- package/lib/module/exports.test.js.map +1 -0
- package/lib/module/index.js +11 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/phase2.test.js +446 -0
- package/lib/module/phase2.test.js.map +1 -0
- package/lib/module/phase3.test.js +91 -0
- package/lib/module/phase3.test.js.map +1 -0
- package/lib/module/phase4.test.js +89 -0
- package/lib/module/phase4.test.js.map +1 -0
- package/lib/module/phase5.test.js +246 -0
- package/lib/module/phase5.test.js.map +1 -0
- package/lib/module/phase7.test.js +284 -0
- package/lib/module/phase7.test.js.map +1 -0
- package/lib/module/range-helpers.test.js +182 -0
- package/lib/module/range-helpers.test.js.map +1 -0
- package/lib/module/theme/create-theme.js +33 -0
- package/lib/module/theme/create-theme.js.map +1 -0
- package/lib/module/theme/default-theme.js +95 -0
- package/lib/module/theme/default-theme.js.map +1 -0
- package/lib/module/theme/index.js +5 -0
- package/lib/module/theme/index.js.map +1 -0
- package/lib/module/theme/types.js +4 -0
- package/lib/module/theme/types.js.map +1 -0
- package/lib/module/utils/date-helpers.js +96 -0
- package/lib/module/utils/date-helpers.js.map +1 -0
- package/lib/module/utils/index.js +4 -0
- package/lib/module/utils/index.js.map +1 -0
- package/lib/typescript/src/accessibility/index.d.ts +2 -0
- package/lib/typescript/src/accessibility/index.d.ts.map +1 -0
- package/lib/typescript/src/accessibility/labels.d.ts +6 -0
- package/lib/typescript/src/accessibility/labels.d.ts.map +1 -0
- package/lib/typescript/src/calendar/calendar-types.d.ts +23 -0
- package/lib/typescript/src/calendar/calendar-types.d.ts.map +1 -0
- package/lib/typescript/src/calendar/get-calendar-month-grid.d.ts +3 -0
- package/lib/typescript/src/calendar/get-calendar-month-grid.d.ts.map +1 -0
- package/lib/typescript/src/calendar/index.d.ts +3 -0
- package/lib/typescript/src/calendar/index.d.ts.map +1 -0
- package/lib/typescript/src/components/NepaliCalendar/CalendarDay.d.ts +23 -0
- package/lib/typescript/src/components/NepaliCalendar/CalendarDay.d.ts.map +1 -0
- package/lib/typescript/src/components/NepaliCalendar/CalendarGrid.d.ts +25 -0
- package/lib/typescript/src/components/NepaliCalendar/CalendarGrid.d.ts.map +1 -0
- package/lib/typescript/src/components/NepaliCalendar/CalendarHeader.d.ts +17 -0
- package/lib/typescript/src/components/NepaliCalendar/CalendarHeader.d.ts.map +1 -0
- package/lib/typescript/src/components/NepaliCalendar/CalendarWeekdays.d.ts +11 -0
- package/lib/typescript/src/components/NepaliCalendar/CalendarWeekdays.d.ts.map +1 -0
- package/lib/typescript/src/components/NepaliCalendar/NepaliCalendar.d.ts +4 -0
- package/lib/typescript/src/components/NepaliCalendar/NepaliCalendar.d.ts.map +1 -0
- package/lib/typescript/src/components/NepaliCalendar/index.d.ts +3 -0
- package/lib/typescript/src/components/NepaliCalendar/index.d.ts.map +1 -0
- package/lib/typescript/src/components/NepaliCalendar/types.d.ts +52 -0
- package/lib/typescript/src/components/NepaliCalendar/types.d.ts.map +1 -0
- package/lib/typescript/src/components/NepaliDatePicker/DatePickerModal.d.ts +4 -0
- package/lib/typescript/src/components/NepaliDatePicker/DatePickerModal.d.ts.map +1 -0
- package/lib/typescript/src/components/NepaliDatePicker/NepaliDatePicker.d.ts +4 -0
- package/lib/typescript/src/components/NepaliDatePicker/NepaliDatePicker.d.ts.map +1 -0
- package/lib/typescript/src/components/NepaliDatePicker/index.d.ts +4 -0
- package/lib/typescript/src/components/NepaliDatePicker/index.d.ts.map +1 -0
- package/lib/typescript/src/components/NepaliDatePicker/types.d.ts +50 -0
- package/lib/typescript/src/components/NepaliDatePicker/types.d.ts.map +1 -0
- package/lib/typescript/src/components/NepaliRangePicker/NepaliRangePicker.d.ts +4 -0
- package/lib/typescript/src/components/NepaliRangePicker/NepaliRangePicker.d.ts.map +1 -0
- package/lib/typescript/src/components/NepaliRangePicker/RangePickerModal.d.ts +4 -0
- package/lib/typescript/src/components/NepaliRangePicker/RangePickerModal.d.ts.map +1 -0
- package/lib/typescript/src/components/NepaliRangePicker/index.d.ts +5 -0
- package/lib/typescript/src/components/NepaliRangePicker/index.d.ts.map +1 -0
- package/lib/typescript/src/components/NepaliRangePicker/range-utils.d.ts +13 -0
- package/lib/typescript/src/components/NepaliRangePicker/range-utils.d.ts.map +1 -0
- package/lib/typescript/src/components/NepaliRangePicker/types.d.ts +61 -0
- package/lib/typescript/src/components/NepaliRangePicker/types.d.ts.map +1 -0
- package/lib/typescript/src/core/arithmetic.d.ts +6 -0
- package/lib/typescript/src/core/arithmetic.d.ts.map +1 -0
- package/lib/typescript/src/core/bsData.d.ts +39 -0
- package/lib/typescript/src/core/bsData.d.ts.map +1 -0
- package/lib/typescript/src/core/conversion.d.ts +4 -0
- package/lib/typescript/src/core/conversion.d.ts.map +1 -0
- package/lib/typescript/src/core/dateKey.d.ts +4 -0
- package/lib/typescript/src/core/dateKey.d.ts.map +1 -0
- package/lib/typescript/src/core/epochDay.d.ts +7 -0
- package/lib/typescript/src/core/epochDay.d.ts.map +1 -0
- package/lib/typescript/src/core/format/format.d.ts +8 -0
- package/lib/typescript/src/core/format/format.d.ts.map +1 -0
- package/lib/typescript/src/core/format/index.d.ts +5 -0
- package/lib/typescript/src/core/format/index.d.ts.map +1 -0
- package/lib/typescript/src/core/format/parse.d.ts +7 -0
- package/lib/typescript/src/core/format/parse.d.ts.map +1 -0
- package/lib/typescript/src/core/format/tokens.d.ts +4 -0
- package/lib/typescript/src/core/format/tokens.d.ts.map +1 -0
- package/lib/typescript/src/core/index.d.ts +11 -0
- package/lib/typescript/src/core/index.d.ts.map +1 -0
- package/lib/typescript/src/core/locale/en.d.ts +3 -0
- package/lib/typescript/src/core/locale/en.d.ts.map +1 -0
- package/lib/typescript/src/core/locale/index.d.ts +4 -0
- package/lib/typescript/src/core/locale/index.d.ts.map +1 -0
- package/lib/typescript/src/core/locale/ne.d.ts +3 -0
- package/lib/typescript/src/core/locale/ne.d.ts.map +1 -0
- package/lib/typescript/src/core/locale/types.d.ts +11 -0
- package/lib/typescript/src/core/locale/types.d.ts.map +1 -0
- package/lib/typescript/src/core/numerals/index.d.ts +2 -0
- package/lib/typescript/src/core/numerals/index.d.ts.map +1 -0
- package/lib/typescript/src/core/numerals/nepali-numerals.d.ts +3 -0
- package/lib/typescript/src/core/numerals/nepali-numerals.d.ts.map +1 -0
- package/lib/typescript/src/core/types.d.ts +14 -0
- package/lib/typescript/src/core/types.d.ts.map +1 -0
- package/lib/typescript/src/core/validation.d.ts +17 -0
- package/lib/typescript/src/core/validation.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +9 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/theme/create-theme.d.ts +6 -0
- package/lib/typescript/src/theme/create-theme.d.ts.map +1 -0
- package/lib/typescript/src/theme/default-theme.d.ts +4 -0
- package/lib/typescript/src/theme/default-theme.d.ts.map +1 -0
- package/lib/typescript/src/theme/index.d.ts +4 -0
- package/lib/typescript/src/theme/index.d.ts.map +1 -0
- package/lib/typescript/src/theme/types.d.ts +43 -0
- package/lib/typescript/src/theme/types.d.ts.map +1 -0
- package/lib/typescript/src/utils/date-helpers.d.ts +27 -0
- package/lib/typescript/src/utils/date-helpers.d.ts.map +1 -0
- package/lib/typescript/src/utils/index.d.ts +2 -0
- package/lib/typescript/src/utils/index.d.ts.map +1 -0
- package/package.json +85 -0
- package/src/accessibility/index.ts +5 -0
- package/src/accessibility/labels.ts +22 -0
- package/src/calendar/calendar-types.ts +25 -0
- package/src/calendar/get-calendar-month-grid.ts +125 -0
- package/src/calendar/index.ts +2 -0
- package/src/components/NepaliCalendar/CalendarDay.tsx +198 -0
- package/src/components/NepaliCalendar/CalendarGrid.tsx +159 -0
- package/src/components/NepaliCalendar/CalendarHeader.tsx +126 -0
- package/src/components/NepaliCalendar/CalendarWeekdays.tsx +49 -0
- package/src/components/NepaliCalendar/NepaliCalendar.tsx +279 -0
- package/src/components/NepaliCalendar/index.ts +6 -0
- package/src/components/NepaliCalendar/types.ts +62 -0
- package/src/components/NepaliDatePicker/DatePickerModal.tsx +220 -0
- package/src/components/NepaliDatePicker/NepaliDatePicker.tsx +171 -0
- package/src/components/NepaliDatePicker/index.ts +3 -0
- package/src/components/NepaliDatePicker/types.ts +70 -0
- package/src/components/NepaliRangePicker/NepaliRangePicker.tsx +206 -0
- package/src/components/NepaliRangePicker/RangePickerModal.tsx +336 -0
- package/src/components/NepaliRangePicker/index.ts +11 -0
- package/src/components/NepaliRangePicker/range-utils.ts +75 -0
- package/src/components/NepaliRangePicker/types.ts +84 -0
- package/src/core/arithmetic.ts +34 -0
- package/src/core/bsData.ts +115 -0
- package/src/core/conversion.ts +73 -0
- package/src/core/dateKey.ts +31 -0
- package/src/core/epochDay.ts +49 -0
- package/src/core/format/format.ts +108 -0
- package/src/core/format/index.ts +4 -0
- package/src/core/format/parse.ts +68 -0
- package/src/core/format/tokens.ts +35 -0
- package/src/core/index.ts +10 -0
- package/src/core/locale/en.ts +23 -0
- package/src/core/locale/index.ts +3 -0
- package/src/core/locale/ne.ts +31 -0
- package/src/core/locale/types.ts +12 -0
- package/src/core/numerals/index.ts +1 -0
- package/src/core/numerals/nepali-numerals.ts +27 -0
- package/src/core/types.ts +15 -0
- package/src/core/validation.test.ts +207 -0
- package/src/core/validation.ts +141 -0
- package/src/exports.test.ts +135 -0
- package/src/index.ts +8 -0
- package/src/phase2.test.ts +424 -0
- package/src/phase3.test.ts +83 -0
- package/src/phase4.test.ts +86 -0
- package/src/phase5.test.ts +257 -0
- package/src/phase7.test.ts +307 -0
- package/src/range-helpers.test.ts +153 -0
- package/src/theme/create-theme.ts +29 -0
- package/src/theme/default-theme.ts +99 -0
- package/src/theme/index.ts +3 -0
- package/src/theme/types.ts +44 -0
- package/src/utils/date-helpers.ts +146 -0
- package/src/utils/index.ts +9 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import React, { memo, useCallback, useMemo } from 'react';
|
|
2
|
+
import { View, StyleSheet } from 'react-native';
|
|
3
|
+
import type { BSDateValue } from '../../core/types';
|
|
4
|
+
import { compareBS } from '../../core';
|
|
5
|
+
import type { CalendarMonthGrid } from '../../calendar';
|
|
6
|
+
import type { CalendarTheme } from '../../theme/types';
|
|
7
|
+
import type { CalendarLocale } from '../../core/locale';
|
|
8
|
+
import type { CalendarMarkedDate, CalendarDayRenderProps } from './types';
|
|
9
|
+
import type { DateRangeValue } from '../NepaliRangePicker/types';
|
|
10
|
+
import { isRangeStart, isRangeEnd, isDateInRange } from '../NepaliRangePicker/range-utils';
|
|
11
|
+
import { CalendarDay } from './CalendarDay';
|
|
12
|
+
|
|
13
|
+
type CalendarGridProps = {
|
|
14
|
+
grid: CalendarMonthGrid;
|
|
15
|
+
value: BSDateValue | null;
|
|
16
|
+
today: BSDateValue | null;
|
|
17
|
+
minDate: BSDateValue | undefined;
|
|
18
|
+
maxDate: BSDateValue | undefined;
|
|
19
|
+
numerals: 'latin' | 'devanagari';
|
|
20
|
+
theme: CalendarTheme;
|
|
21
|
+
markedDates: Record<string, CalendarMarkedDate> | undefined;
|
|
22
|
+
disabledDates: string[] | ((date: BSDateValue) => boolean) | undefined;
|
|
23
|
+
onChange: (date: BSDateValue) => void;
|
|
24
|
+
renderDay: ((props: CalendarDayRenderProps) => React.ReactNode) | undefined;
|
|
25
|
+
rangeValue?: DateRangeValue;
|
|
26
|
+
locale?: CalendarLocale;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const CalendarGrid = memo(function CalendarGrid({
|
|
30
|
+
grid,
|
|
31
|
+
value,
|
|
32
|
+
today,
|
|
33
|
+
numerals,
|
|
34
|
+
theme,
|
|
35
|
+
markedDates,
|
|
36
|
+
disabledDates,
|
|
37
|
+
onChange,
|
|
38
|
+
renderDay,
|
|
39
|
+
rangeValue,
|
|
40
|
+
locale,
|
|
41
|
+
}: CalendarGridProps) {
|
|
42
|
+
const isDateDisabledByList = useCallback(
|
|
43
|
+
(date: BSDateValue, dateKey: string): boolean => {
|
|
44
|
+
if (Array.isArray(disabledDates)) {
|
|
45
|
+
return disabledDates.includes(dateKey);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (typeof disabledDates === 'function') {
|
|
49
|
+
return disabledDates(date);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return false;
|
|
53
|
+
},
|
|
54
|
+
[disabledDates]
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
const rows = useMemo(() => {
|
|
58
|
+
const hasRange = rangeValue?.start != null;
|
|
59
|
+
|
|
60
|
+
return grid.weeks.map((week, weekIndex) => (
|
|
61
|
+
<View key={weekIndex} style={styles.weekRow}>
|
|
62
|
+
{week.map((cell) => {
|
|
63
|
+
const dateKey = cell.key;
|
|
64
|
+
const isSelected = value !== null && compareBS(cell.date, value) === 0;
|
|
65
|
+
const isTodayCell = today !== null && compareBS(cell.date, today) === 0;
|
|
66
|
+
const marked = markedDates?.[dateKey];
|
|
67
|
+
const explicitlyDisabled = marked?.disabled ?? false;
|
|
68
|
+
const disabled =
|
|
69
|
+
explicitlyDisabled ||
|
|
70
|
+
cell.isDisabled ||
|
|
71
|
+
isDateDisabledByList(cell.date, dateKey);
|
|
72
|
+
|
|
73
|
+
const rangeStart = hasRange && isRangeStart(cell.date, rangeValue!);
|
|
74
|
+
const rangeEnd = hasRange && isRangeEnd(cell.date, rangeValue!);
|
|
75
|
+
const inRange = hasRange && isDateInRange(cell.date, rangeValue!);
|
|
76
|
+
|
|
77
|
+
const handlePress = () => {
|
|
78
|
+
if (!disabled) {
|
|
79
|
+
onChange(cell.date);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const dayProps: CalendarDayRenderProps = {
|
|
84
|
+
date: cell.date,
|
|
85
|
+
dateKey,
|
|
86
|
+
day: cell.day,
|
|
87
|
+
selected: isSelected,
|
|
88
|
+
today: isTodayCell,
|
|
89
|
+
disabled,
|
|
90
|
+
inCurrentMonth: cell.inCurrentMonth,
|
|
91
|
+
marked,
|
|
92
|
+
onPress: handlePress,
|
|
93
|
+
rangeStart,
|
|
94
|
+
rangeEnd,
|
|
95
|
+
inRange,
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
if (renderDay) {
|
|
99
|
+
return (
|
|
100
|
+
<View key={dateKey} style={styles.dayCell}>
|
|
101
|
+
{renderDay(dayProps)}
|
|
102
|
+
</View>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return (
|
|
107
|
+
<View key={dateKey} style={styles.dayCell}>
|
|
108
|
+
<CalendarDay
|
|
109
|
+
date={cell.date}
|
|
110
|
+
day={cell.day}
|
|
111
|
+
selected={isSelected}
|
|
112
|
+
today={isTodayCell}
|
|
113
|
+
disabled={disabled}
|
|
114
|
+
inCurrentMonth={cell.inCurrentMonth}
|
|
115
|
+
marked={marked}
|
|
116
|
+
numerals={numerals}
|
|
117
|
+
theme={theme}
|
|
118
|
+
onPress={handlePress}
|
|
119
|
+
rangeStart={rangeStart}
|
|
120
|
+
rangeEnd={rangeEnd}
|
|
121
|
+
inRange={inRange}
|
|
122
|
+
locale={locale}
|
|
123
|
+
/>
|
|
124
|
+
</View>
|
|
125
|
+
);
|
|
126
|
+
})}
|
|
127
|
+
</View>
|
|
128
|
+
));
|
|
129
|
+
}, [
|
|
130
|
+
grid.weeks,
|
|
131
|
+
value,
|
|
132
|
+
today,
|
|
133
|
+
numerals,
|
|
134
|
+
theme,
|
|
135
|
+
markedDates,
|
|
136
|
+
isDateDisabledByList,
|
|
137
|
+
onChange,
|
|
138
|
+
renderDay,
|
|
139
|
+
rangeValue,
|
|
140
|
+
locale,
|
|
141
|
+
]);
|
|
142
|
+
|
|
143
|
+
return <View style={styles.grid}>{rows}</View>;
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
const styles = StyleSheet.create({
|
|
147
|
+
grid: {
|
|
148
|
+
paddingHorizontal: 8,
|
|
149
|
+
paddingBottom: 8,
|
|
150
|
+
},
|
|
151
|
+
weekRow: {
|
|
152
|
+
flexDirection: 'row',
|
|
153
|
+
justifyContent: 'space-around',
|
|
154
|
+
},
|
|
155
|
+
dayCell: {
|
|
156
|
+
flex: 1,
|
|
157
|
+
alignItems: 'center',
|
|
158
|
+
},
|
|
159
|
+
});
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import React, { memo, useCallback } from 'react';
|
|
2
|
+
import { View, Text, Pressable, StyleSheet } from 'react-native';
|
|
3
|
+
import type { NumeralSystem, CalendarLocale } from '../../core/locale';
|
|
4
|
+
import { formatBS } from '../../core/format';
|
|
5
|
+
import { toNepaliNumerals } from '../../core/numerals';
|
|
6
|
+
import { clampBSDateToSupportedRange } from '../../core/validation';
|
|
7
|
+
import type { CalendarTheme } from '../../theme/types';
|
|
8
|
+
import {
|
|
9
|
+
HEADER_PREV_MONTH_LABEL,
|
|
10
|
+
HEADER_NEXT_MONTH_LABEL,
|
|
11
|
+
} from '../../accessibility';
|
|
12
|
+
|
|
13
|
+
type CalendarHeaderProps = {
|
|
14
|
+
year: number;
|
|
15
|
+
month: number;
|
|
16
|
+
locale: CalendarLocale;
|
|
17
|
+
numerals: NumeralSystem;
|
|
18
|
+
theme: CalendarTheme;
|
|
19
|
+
onPrevMonth: () => void;
|
|
20
|
+
onNextMonth: () => void;
|
|
21
|
+
canGoPrev: boolean;
|
|
22
|
+
canGoNext: boolean;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
function safeFormatHeader(
|
|
26
|
+
year: number,
|
|
27
|
+
month: number,
|
|
28
|
+
locale: CalendarLocale,
|
|
29
|
+
numerals: NumeralSystem
|
|
30
|
+
): string {
|
|
31
|
+
const safeDate = clampBSDateToSupportedRange({
|
|
32
|
+
calendar: 'BS',
|
|
33
|
+
year,
|
|
34
|
+
month: Math.max(1, Math.min(12, month)),
|
|
35
|
+
day: 1,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
return formatBS(safeDate, 'MMMM yyyy', { locale, numerals });
|
|
40
|
+
} catch {
|
|
41
|
+
const monthName =
|
|
42
|
+
safeDate.month >= 1 && safeDate.month <= 12
|
|
43
|
+
? locale.months[safeDate.month - 1]
|
|
44
|
+
: `Month ${safeDate.month}`;
|
|
45
|
+
const yearStr = numerals === 'devanagari' ? toNepaliNumerals(safeDate.year) : String(safeDate.year);
|
|
46
|
+
return `${monthName} ${yearStr}`;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const CalendarHeader = memo(function CalendarHeader({
|
|
51
|
+
year,
|
|
52
|
+
month,
|
|
53
|
+
locale,
|
|
54
|
+
numerals,
|
|
55
|
+
theme,
|
|
56
|
+
onPrevMonth,
|
|
57
|
+
onNextMonth,
|
|
58
|
+
canGoPrev,
|
|
59
|
+
canGoNext,
|
|
60
|
+
}: CalendarHeaderProps) {
|
|
61
|
+
const title = safeFormatHeader(year, month, locale, numerals);
|
|
62
|
+
|
|
63
|
+
const handlePrev = useCallback(() => {
|
|
64
|
+
if (canGoPrev) onPrevMonth();
|
|
65
|
+
}, [canGoPrev, onPrevMonth]);
|
|
66
|
+
|
|
67
|
+
const handleNext = useCallback(() => {
|
|
68
|
+
if (canGoNext) onNextMonth();
|
|
69
|
+
}, [canGoNext, onNextMonth]);
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<View style={styles.header}>
|
|
73
|
+
<Pressable
|
|
74
|
+
style={[styles.navButton, !canGoPrev && styles.navButtonDisabled]}
|
|
75
|
+
onPress={handlePrev}
|
|
76
|
+
disabled={!canGoPrev}
|
|
77
|
+
accessibilityRole="button"
|
|
78
|
+
accessibilityLabel={HEADER_PREV_MONTH_LABEL}
|
|
79
|
+
>
|
|
80
|
+
<Text style={[styles.navText, { color: theme.colors.text }]}>‹</Text>
|
|
81
|
+
</Pressable>
|
|
82
|
+
|
|
83
|
+
<Text style={[styles.title, { color: theme.colors.text }]}>{title}</Text>
|
|
84
|
+
|
|
85
|
+
<Pressable
|
|
86
|
+
style={[styles.navButton, !canGoNext && styles.navButtonDisabled]}
|
|
87
|
+
onPress={handleNext}
|
|
88
|
+
disabled={!canGoNext}
|
|
89
|
+
accessibilityRole="button"
|
|
90
|
+
accessibilityLabel={HEADER_NEXT_MONTH_LABEL}
|
|
91
|
+
>
|
|
92
|
+
<Text style={[styles.navText, { color: theme.colors.text }]}>›</Text>
|
|
93
|
+
</Pressable>
|
|
94
|
+
</View>
|
|
95
|
+
);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
const styles = StyleSheet.create({
|
|
99
|
+
header: {
|
|
100
|
+
flexDirection: 'row',
|
|
101
|
+
alignItems: 'center',
|
|
102
|
+
justifyContent: 'space-between',
|
|
103
|
+
paddingHorizontal: 16,
|
|
104
|
+
paddingVertical: 12,
|
|
105
|
+
},
|
|
106
|
+
title: {
|
|
107
|
+
fontSize: 18,
|
|
108
|
+
fontWeight: '600',
|
|
109
|
+
flex: 1,
|
|
110
|
+
textAlign: 'center',
|
|
111
|
+
},
|
|
112
|
+
navButton: {
|
|
113
|
+
width: 40,
|
|
114
|
+
height: 40,
|
|
115
|
+
alignItems: 'center',
|
|
116
|
+
justifyContent: 'center',
|
|
117
|
+
borderRadius: 20,
|
|
118
|
+
},
|
|
119
|
+
navButtonDisabled: {
|
|
120
|
+
opacity: 0.3,
|
|
121
|
+
},
|
|
122
|
+
navText: {
|
|
123
|
+
fontSize: 24,
|
|
124
|
+
fontWeight: '400',
|
|
125
|
+
},
|
|
126
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React, { memo, useMemo } from 'react';
|
|
2
|
+
import { View, Text, StyleSheet } from 'react-native';
|
|
3
|
+
import type { CalendarLocale } from '../../core/locale';
|
|
4
|
+
import type { CalendarTheme } from '../../theme/types';
|
|
5
|
+
|
|
6
|
+
type CalendarWeekdaysProps = {
|
|
7
|
+
locale: CalendarLocale;
|
|
8
|
+
weekStartsOn: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
9
|
+
theme: CalendarTheme;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const CalendarWeekdays = memo(function CalendarWeekdays({
|
|
13
|
+
locale,
|
|
14
|
+
weekStartsOn,
|
|
15
|
+
theme,
|
|
16
|
+
}: CalendarWeekdaysProps) {
|
|
17
|
+
const weekdays = useMemo(() => {
|
|
18
|
+
const ordered = [...locale.weekdaysShort];
|
|
19
|
+
return ordered.slice(weekStartsOn).concat(ordered.slice(0, weekStartsOn));
|
|
20
|
+
}, [locale.weekdaysShort, weekStartsOn]);
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<View style={styles.weekdaysRow}>
|
|
24
|
+
{weekdays.map((day, index) => (
|
|
25
|
+
<Text
|
|
26
|
+
key={index}
|
|
27
|
+
style={[styles.weekdayText, { color: theme.colors.mutedText }]}
|
|
28
|
+
>
|
|
29
|
+
{day}
|
|
30
|
+
</Text>
|
|
31
|
+
))}
|
|
32
|
+
</View>
|
|
33
|
+
);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const styles = StyleSheet.create({
|
|
37
|
+
weekdaysRow: {
|
|
38
|
+
flexDirection: 'row',
|
|
39
|
+
justifyContent: 'space-around',
|
|
40
|
+
paddingHorizontal: 8,
|
|
41
|
+
paddingBottom: 8,
|
|
42
|
+
},
|
|
43
|
+
weekdayText: {
|
|
44
|
+
flex: 1,
|
|
45
|
+
textAlign: 'center',
|
|
46
|
+
fontSize: 12,
|
|
47
|
+
fontWeight: '500',
|
|
48
|
+
},
|
|
49
|
+
});
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import React, { useState, useMemo, useCallback, useRef, useEffect } from 'react';
|
|
2
|
+
import { View, StyleSheet } from 'react-native';
|
|
3
|
+
import type { BSDateValue } from '../../core/types';
|
|
4
|
+
import {
|
|
5
|
+
getBSMonthLength,
|
|
6
|
+
todayBS,
|
|
7
|
+
compareBS,
|
|
8
|
+
isBSDateInSupportedRange,
|
|
9
|
+
getSafeCalendarMonth,
|
|
10
|
+
getDefaultSupportedBSDate,
|
|
11
|
+
} from '../../core';
|
|
12
|
+
import { getCalendarMonthGrid } from '../../calendar';
|
|
13
|
+
import { EN_LOCALE, NE_LOCALE } from '../../core/locale';
|
|
14
|
+
import type { LocaleCode, CalendarLocale } from '../../core/locale';
|
|
15
|
+
import { useCalendarTheme } from '../../theme';
|
|
16
|
+
import { warnOutOfRangeInDev, warnMinMaxInDev, createDateAccessibilityLabel } from '../../utils';
|
|
17
|
+
import type { NepaliCalendarProps } from './types';
|
|
18
|
+
import { CalendarHeader } from './CalendarHeader';
|
|
19
|
+
import { CalendarWeekdays } from './CalendarWeekdays';
|
|
20
|
+
import { CalendarGrid } from './CalendarGrid';
|
|
21
|
+
|
|
22
|
+
function getPreviousBSMonth(
|
|
23
|
+
year: number,
|
|
24
|
+
month: number
|
|
25
|
+
): { year: number; month: number } {
|
|
26
|
+
if (month === 1) return { year: year - 1, month: 12 };
|
|
27
|
+
return { year, month: month - 1 };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function getNextBSMonth(
|
|
31
|
+
year: number,
|
|
32
|
+
month: number
|
|
33
|
+
): { year: number; month: number } {
|
|
34
|
+
if (month === 12) return { year: year + 1, month: 1 };
|
|
35
|
+
return { year, month: month + 1 };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function resolveLocale(
|
|
39
|
+
locale: LocaleCode | CalendarLocale | undefined
|
|
40
|
+
): CalendarLocale {
|
|
41
|
+
if (!locale) return EN_LOCALE;
|
|
42
|
+
if (typeof locale === 'string') {
|
|
43
|
+
return locale === 'ne' ? NE_LOCALE : EN_LOCALE;
|
|
44
|
+
}
|
|
45
|
+
return locale;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function NepaliCalendar({
|
|
49
|
+
value,
|
|
50
|
+
defaultValue,
|
|
51
|
+
onChange,
|
|
52
|
+
year,
|
|
53
|
+
month,
|
|
54
|
+
defaultYear,
|
|
55
|
+
defaultMonth,
|
|
56
|
+
minDate,
|
|
57
|
+
maxDate,
|
|
58
|
+
locale,
|
|
59
|
+
numerals = 'latin',
|
|
60
|
+
weekStartsOn = 0,
|
|
61
|
+
markedDates,
|
|
62
|
+
theme,
|
|
63
|
+
colorScheme = 'system',
|
|
64
|
+
disabledDates,
|
|
65
|
+
onMonthChange,
|
|
66
|
+
renderDay,
|
|
67
|
+
rangeValue,
|
|
68
|
+
testID,
|
|
69
|
+
}: NepaliCalendarProps) {
|
|
70
|
+
const resolvedLocale = useMemo(() => resolveLocale(locale), [locale]);
|
|
71
|
+
const calendarTheme = useCalendarTheme({ colorScheme, theme });
|
|
72
|
+
|
|
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
|
+
useEffect(() => {
|
|
83
|
+
warnMinMaxInDev(minDate, maxDate);
|
|
84
|
+
}, [minDate, maxDate]);
|
|
85
|
+
|
|
86
|
+
const safeDisplay = useMemo(() => {
|
|
87
|
+
const fallback = getDefaultSupportedBSDate();
|
|
88
|
+
|
|
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
|
+
if (year != null && month != null) {
|
|
98
|
+
const safe = getSafeCalendarMonth({ year, month });
|
|
99
|
+
return safe;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (defaultYear != null && defaultMonth != null) {
|
|
103
|
+
return getSafeCalendarMonth({ year: defaultYear, month: defaultMonth });
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
try {
|
|
107
|
+
const today = todayBS();
|
|
108
|
+
if (isBSDateInSupportedRange(today)) {
|
|
109
|
+
return { year: today.year, month: today.month };
|
|
110
|
+
}
|
|
111
|
+
} catch {
|
|
112
|
+
// fall through
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return { year: fallback.year, month: fallback.month };
|
|
116
|
+
}, [value, defaultValue, year, month, defaultYear, defaultMonth]);
|
|
117
|
+
|
|
118
|
+
const [internalYear, setInternalYear] = useState(safeDisplay.year);
|
|
119
|
+
const [internalMonth, setInternalMonth] = useState(safeDisplay.month);
|
|
120
|
+
|
|
121
|
+
const wasControlledRef = useRef(year !== undefined && month !== undefined);
|
|
122
|
+
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
const isControlled = year !== undefined && month !== undefined;
|
|
125
|
+
if (isControlled) {
|
|
126
|
+
wasControlledRef.current = true;
|
|
127
|
+
const safe = getSafeCalendarMonth({ year, month });
|
|
128
|
+
setInternalYear(safe.year);
|
|
129
|
+
setInternalMonth(safe.month);
|
|
130
|
+
} else if (wasControlledRef.current) {
|
|
131
|
+
wasControlledRef.current = false;
|
|
132
|
+
const safe = getSafeCalendarMonth({
|
|
133
|
+
year: defaultYear,
|
|
134
|
+
month: defaultMonth,
|
|
135
|
+
value,
|
|
136
|
+
defaultValue,
|
|
137
|
+
});
|
|
138
|
+
setInternalYear(safe.year);
|
|
139
|
+
setInternalMonth(safe.month);
|
|
140
|
+
}
|
|
141
|
+
}, [year, month, defaultYear, defaultMonth, value, defaultValue]);
|
|
142
|
+
|
|
143
|
+
const controlledYear = year !== undefined ? getSafeCalendarMonth({ year, month: month ?? 1 }).year : internalYear;
|
|
144
|
+
const controlledMonth = year !== undefined ? getSafeCalendarMonth({ year, month: month ?? 1 }).month : internalMonth;
|
|
145
|
+
|
|
146
|
+
const handlePrevMonth = useCallback(() => {
|
|
147
|
+
const prev = getPreviousBSMonth(controlledYear, controlledMonth);
|
|
148
|
+
if (year === undefined) {
|
|
149
|
+
const safe = getSafeCalendarMonth({ year: prev.year, month: prev.month });
|
|
150
|
+
setInternalYear(safe.year);
|
|
151
|
+
setInternalMonth(safe.month);
|
|
152
|
+
}
|
|
153
|
+
onMonthChange?.(prev);
|
|
154
|
+
}, [controlledYear, controlledMonth, year, onMonthChange]);
|
|
155
|
+
|
|
156
|
+
const handleNextMonth = useCallback(() => {
|
|
157
|
+
const next = getNextBSMonth(controlledYear, controlledMonth);
|
|
158
|
+
if (year === undefined) {
|
|
159
|
+
const safe = getSafeCalendarMonth({ year: next.year, month: next.month });
|
|
160
|
+
setInternalYear(safe.year);
|
|
161
|
+
setInternalMonth(safe.month);
|
|
162
|
+
}
|
|
163
|
+
onMonthChange?.(next);
|
|
164
|
+
}, [controlledYear, controlledMonth, year, onMonthChange]);
|
|
165
|
+
|
|
166
|
+
const today = useMemo(() => {
|
|
167
|
+
try {
|
|
168
|
+
const t = todayBS();
|
|
169
|
+
return isBSDateInSupportedRange(t) ? t : null;
|
|
170
|
+
} catch {
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
}, []);
|
|
174
|
+
|
|
175
|
+
const grid = useMemo(() => {
|
|
176
|
+
try {
|
|
177
|
+
return getCalendarMonthGrid({
|
|
178
|
+
year: controlledYear,
|
|
179
|
+
month: controlledMonth,
|
|
180
|
+
weekStartsOn,
|
|
181
|
+
minDate,
|
|
182
|
+
maxDate,
|
|
183
|
+
today: today ?? undefined,
|
|
184
|
+
});
|
|
185
|
+
} catch {
|
|
186
|
+
return {
|
|
187
|
+
year: controlledYear,
|
|
188
|
+
month: controlledMonth,
|
|
189
|
+
weeks: [],
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
}, [controlledYear, controlledMonth, weekStartsOn, minDate, maxDate, today]);
|
|
193
|
+
|
|
194
|
+
const canGoPrev = useMemo(() => {
|
|
195
|
+
const prev = getPreviousBSMonth(controlledYear, controlledMonth);
|
|
196
|
+
try {
|
|
197
|
+
getBSMonthLength(prev.year, prev.month);
|
|
198
|
+
return true;
|
|
199
|
+
} catch {
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
}, [controlledYear, controlledMonth]);
|
|
203
|
+
|
|
204
|
+
const canGoNext = useMemo(() => {
|
|
205
|
+
const next = getNextBSMonth(controlledYear, controlledMonth);
|
|
206
|
+
try {
|
|
207
|
+
getBSMonthLength(next.year, next.month);
|
|
208
|
+
return true;
|
|
209
|
+
} catch {
|
|
210
|
+
return false;
|
|
211
|
+
}
|
|
212
|
+
}, [controlledYear, controlledMonth]);
|
|
213
|
+
|
|
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
|
+
return (
|
|
232
|
+
<View
|
|
233
|
+
style={[styles.container, { backgroundColor: calendarTheme.colors.background }]}
|
|
234
|
+
testID={testID}
|
|
235
|
+
accessibilityLabel={accessibilityLabel}
|
|
236
|
+
>
|
|
237
|
+
<CalendarHeader
|
|
238
|
+
year={controlledYear}
|
|
239
|
+
month={controlledMonth}
|
|
240
|
+
locale={resolvedLocale}
|
|
241
|
+
numerals={numerals}
|
|
242
|
+
theme={calendarTheme}
|
|
243
|
+
onPrevMonth={handlePrevMonth}
|
|
244
|
+
onNextMonth={handleNextMonth}
|
|
245
|
+
canGoPrev={canGoPrev}
|
|
246
|
+
canGoNext={canGoNext}
|
|
247
|
+
/>
|
|
248
|
+
|
|
249
|
+
<CalendarWeekdays
|
|
250
|
+
locale={resolvedLocale}
|
|
251
|
+
weekStartsOn={weekStartsOn}
|
|
252
|
+
theme={calendarTheme}
|
|
253
|
+
/>
|
|
254
|
+
|
|
255
|
+
<CalendarGrid
|
|
256
|
+
grid={grid}
|
|
257
|
+
value={resolvedValue}
|
|
258
|
+
today={today}
|
|
259
|
+
minDate={minDate}
|
|
260
|
+
maxDate={maxDate}
|
|
261
|
+
numerals={numerals}
|
|
262
|
+
theme={calendarTheme}
|
|
263
|
+
markedDates={markedDates}
|
|
264
|
+
disabledDates={disabledDates}
|
|
265
|
+
onChange={handleDayPress}
|
|
266
|
+
renderDay={renderDay}
|
|
267
|
+
rangeValue={rangeValue}
|
|
268
|
+
locale={resolvedLocale}
|
|
269
|
+
/>
|
|
270
|
+
</View>
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
const styles = StyleSheet.create({
|
|
275
|
+
container: {
|
|
276
|
+
borderRadius: 12,
|
|
277
|
+
overflow: 'hidden',
|
|
278
|
+
},
|
|
279
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { BSDateValue } from '../../core/types';
|
|
3
|
+
import type { LocaleCode, CalendarLocale, NumeralSystem } from '../../core/locale';
|
|
4
|
+
import type { CalendarTheme } from '../../theme/types';
|
|
5
|
+
import type { DateRangeValue } from '../NepaliRangePicker/types';
|
|
6
|
+
|
|
7
|
+
export type CalendarMarkedDate = {
|
|
8
|
+
type?: 'dot' | 'holiday' | 'event' | 'disabled';
|
|
9
|
+
label?: string;
|
|
10
|
+
color?: string;
|
|
11
|
+
textColor?: string;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type CalendarDayRenderProps = {
|
|
16
|
+
date: BSDateValue;
|
|
17
|
+
dateKey: string;
|
|
18
|
+
day: number;
|
|
19
|
+
selected: boolean;
|
|
20
|
+
today: boolean;
|
|
21
|
+
disabled: boolean;
|
|
22
|
+
inCurrentMonth: boolean;
|
|
23
|
+
marked?: CalendarMarkedDate;
|
|
24
|
+
onPress: () => void;
|
|
25
|
+
rangeStart?: boolean;
|
|
26
|
+
rangeEnd?: boolean;
|
|
27
|
+
inRange?: boolean;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type NepaliCalendarProps = {
|
|
31
|
+
value?: BSDateValue | null;
|
|
32
|
+
defaultValue?: BSDateValue;
|
|
33
|
+
onChange?: (date: BSDateValue) => void;
|
|
34
|
+
|
|
35
|
+
year?: number;
|
|
36
|
+
month?: number;
|
|
37
|
+
defaultYear?: number;
|
|
38
|
+
defaultMonth?: number;
|
|
39
|
+
|
|
40
|
+
minDate?: BSDateValue;
|
|
41
|
+
maxDate?: BSDateValue;
|
|
42
|
+
|
|
43
|
+
locale?: LocaleCode | CalendarLocale;
|
|
44
|
+
numerals?: NumeralSystem;
|
|
45
|
+
|
|
46
|
+
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
47
|
+
|
|
48
|
+
markedDates?: Record<string, CalendarMarkedDate>;
|
|
49
|
+
|
|
50
|
+
theme?: Partial<CalendarTheme>;
|
|
51
|
+
colorScheme?: 'light' | 'dark' | 'system';
|
|
52
|
+
|
|
53
|
+
disabledDates?: string[] | ((date: BSDateValue) => boolean);
|
|
54
|
+
|
|
55
|
+
onMonthChange?: (value: { year: number; month: number }) => void;
|
|
56
|
+
|
|
57
|
+
renderDay?: (props: CalendarDayRenderProps) => ReactNode;
|
|
58
|
+
|
|
59
|
+
rangeValue?: DateRangeValue;
|
|
60
|
+
|
|
61
|
+
testID?: string;
|
|
62
|
+
};
|