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,220 @@
|
|
|
1
|
+
import React, { useState, useEffect, useMemo, useCallback } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
Text,
|
|
5
|
+
Pressable,
|
|
6
|
+
Modal,
|
|
7
|
+
StyleSheet,
|
|
8
|
+
TouchableWithoutFeedback,
|
|
9
|
+
} from 'react-native';
|
|
10
|
+
import type { BSDateValue } from '../../core/types';
|
|
11
|
+
import { useCalendarTheme } from '../../theme';
|
|
12
|
+
import { getSafeInitialBSDate } from '../../utils';
|
|
13
|
+
import { NepaliCalendar } from '../NepaliCalendar';
|
|
14
|
+
import type { DatePickerModalProps } from './types';
|
|
15
|
+
|
|
16
|
+
export function DatePickerModal({
|
|
17
|
+
visible,
|
|
18
|
+
value,
|
|
19
|
+
defaultValue,
|
|
20
|
+
onChange,
|
|
21
|
+
onConfirm,
|
|
22
|
+
onCancel,
|
|
23
|
+
onClose,
|
|
24
|
+
locale,
|
|
25
|
+
numerals,
|
|
26
|
+
minDate,
|
|
27
|
+
maxDate,
|
|
28
|
+
markedDates,
|
|
29
|
+
disabledDates,
|
|
30
|
+
weekStartsOn,
|
|
31
|
+
theme,
|
|
32
|
+
colorScheme,
|
|
33
|
+
title = 'Select Date',
|
|
34
|
+
confirmText = 'Confirm',
|
|
35
|
+
cancelText = 'Cancel',
|
|
36
|
+
testID,
|
|
37
|
+
}: DatePickerModalProps) {
|
|
38
|
+
const calendarTheme = useCalendarTheme({ colorScheme, theme });
|
|
39
|
+
|
|
40
|
+
const [tempDate, setTempDate] = useState<BSDateValue>(() =>
|
|
41
|
+
getSafeInitialBSDate(value, defaultValue)
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (visible) {
|
|
46
|
+
setTempDate(getSafeInitialBSDate(value, defaultValue));
|
|
47
|
+
}
|
|
48
|
+
}, [visible, value, defaultValue]);
|
|
49
|
+
|
|
50
|
+
const handleConfirm = useCallback(() => {
|
|
51
|
+
onConfirm?.(tempDate);
|
|
52
|
+
onChange?.(tempDate);
|
|
53
|
+
onClose?.();
|
|
54
|
+
}, [tempDate, onConfirm, onChange, onClose]);
|
|
55
|
+
|
|
56
|
+
const handleCancel = useCallback(() => {
|
|
57
|
+
onCancel?.();
|
|
58
|
+
onClose?.();
|
|
59
|
+
}, [onCancel, onClose]);
|
|
60
|
+
|
|
61
|
+
const handleBackdropPress = useCallback(() => {
|
|
62
|
+
onCancel?.();
|
|
63
|
+
onClose?.();
|
|
64
|
+
}, [onCancel, onClose]);
|
|
65
|
+
|
|
66
|
+
const modalContent = useMemo(
|
|
67
|
+
() => (
|
|
68
|
+
<View
|
|
69
|
+
style={[
|
|
70
|
+
styles.modalContent,
|
|
71
|
+
{ backgroundColor: calendarTheme.colors.modalBackground },
|
|
72
|
+
]}
|
|
73
|
+
testID={testID}
|
|
74
|
+
>
|
|
75
|
+
<Text
|
|
76
|
+
style={[
|
|
77
|
+
styles.title,
|
|
78
|
+
{
|
|
79
|
+
color: calendarTheme.colors.text,
|
|
80
|
+
borderBottomColor: calendarTheme.colors.border,
|
|
81
|
+
},
|
|
82
|
+
]}
|
|
83
|
+
>
|
|
84
|
+
{title}
|
|
85
|
+
</Text>
|
|
86
|
+
|
|
87
|
+
<View style={styles.calendarWrapper}>
|
|
88
|
+
<NepaliCalendar
|
|
89
|
+
value={tempDate}
|
|
90
|
+
onChange={setTempDate}
|
|
91
|
+
locale={locale}
|
|
92
|
+
numerals={numerals}
|
|
93
|
+
minDate={minDate}
|
|
94
|
+
maxDate={maxDate}
|
|
95
|
+
markedDates={markedDates}
|
|
96
|
+
disabledDates={disabledDates}
|
|
97
|
+
weekStartsOn={weekStartsOn}
|
|
98
|
+
theme={theme}
|
|
99
|
+
colorScheme={colorScheme}
|
|
100
|
+
/>
|
|
101
|
+
</View>
|
|
102
|
+
|
|
103
|
+
<View
|
|
104
|
+
style={[
|
|
105
|
+
styles.buttonRow,
|
|
106
|
+
{ borderTopColor: calendarTheme.colors.border },
|
|
107
|
+
]}
|
|
108
|
+
>
|
|
109
|
+
<Pressable
|
|
110
|
+
style={[styles.button, styles.cancelButton]}
|
|
111
|
+
onPress={handleCancel}
|
|
112
|
+
accessibilityRole="button"
|
|
113
|
+
accessibilityLabel={cancelText}
|
|
114
|
+
>
|
|
115
|
+
<Text style={[styles.cancelText, { color: calendarTheme.colors.mutedText }]}>
|
|
116
|
+
{cancelText}
|
|
117
|
+
</Text>
|
|
118
|
+
</Pressable>
|
|
119
|
+
|
|
120
|
+
<Pressable
|
|
121
|
+
style={[styles.button, { backgroundColor: calendarTheme.colors.primary }]}
|
|
122
|
+
onPress={handleConfirm}
|
|
123
|
+
accessibilityRole="button"
|
|
124
|
+
accessibilityLabel="Confirm selected date"
|
|
125
|
+
>
|
|
126
|
+
<Text style={[styles.confirmText, { color: calendarTheme.colors.primaryText }]}>
|
|
127
|
+
{confirmText}
|
|
128
|
+
</Text>
|
|
129
|
+
</Pressable>
|
|
130
|
+
</View>
|
|
131
|
+
</View>
|
|
132
|
+
),
|
|
133
|
+
[
|
|
134
|
+
tempDate,
|
|
135
|
+
title,
|
|
136
|
+
locale,
|
|
137
|
+
numerals,
|
|
138
|
+
minDate,
|
|
139
|
+
maxDate,
|
|
140
|
+
markedDates,
|
|
141
|
+
disabledDates,
|
|
142
|
+
weekStartsOn,
|
|
143
|
+
theme,
|
|
144
|
+
colorScheme,
|
|
145
|
+
testID,
|
|
146
|
+
cancelText,
|
|
147
|
+
confirmText,
|
|
148
|
+
calendarTheme,
|
|
149
|
+
handleCancel,
|
|
150
|
+
handleConfirm,
|
|
151
|
+
]
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
return (
|
|
155
|
+
<Modal
|
|
156
|
+
visible={visible}
|
|
157
|
+
transparent
|
|
158
|
+
animationType="fade"
|
|
159
|
+
onRequestClose={handleCancel}
|
|
160
|
+
>
|
|
161
|
+
<TouchableWithoutFeedback onPress={handleBackdropPress}>
|
|
162
|
+
<View style={[styles.backdrop, { backgroundColor: calendarTheme.colors.overlay }]}>
|
|
163
|
+
<TouchableWithoutFeedback>{modalContent}</TouchableWithoutFeedback>
|
|
164
|
+
</View>
|
|
165
|
+
</TouchableWithoutFeedback>
|
|
166
|
+
</Modal>
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const styles = StyleSheet.create({
|
|
171
|
+
backdrop: {
|
|
172
|
+
flex: 1,
|
|
173
|
+
justifyContent: 'center',
|
|
174
|
+
alignItems: 'center',
|
|
175
|
+
paddingHorizontal: 20,
|
|
176
|
+
},
|
|
177
|
+
modalContent: {
|
|
178
|
+
borderRadius: 16,
|
|
179
|
+
overflow: 'hidden',
|
|
180
|
+
width: '100%',
|
|
181
|
+
maxWidth: 400,
|
|
182
|
+
},
|
|
183
|
+
title: {
|
|
184
|
+
fontSize: 18,
|
|
185
|
+
fontWeight: '600',
|
|
186
|
+
textAlign: 'center',
|
|
187
|
+
paddingVertical: 16,
|
|
188
|
+
paddingHorizontal: 16,
|
|
189
|
+
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
190
|
+
},
|
|
191
|
+
calendarWrapper: {
|
|
192
|
+
padding: 8,
|
|
193
|
+
},
|
|
194
|
+
buttonRow: {
|
|
195
|
+
flexDirection: 'row',
|
|
196
|
+
justifyContent: 'flex-end',
|
|
197
|
+
paddingHorizontal: 16,
|
|
198
|
+
paddingVertical: 12,
|
|
199
|
+
gap: 12,
|
|
200
|
+
borderTopWidth: StyleSheet.hairlineWidth,
|
|
201
|
+
},
|
|
202
|
+
button: {
|
|
203
|
+
paddingVertical: 10,
|
|
204
|
+
paddingHorizontal: 20,
|
|
205
|
+
borderRadius: 8,
|
|
206
|
+
minWidth: 80,
|
|
207
|
+
alignItems: 'center',
|
|
208
|
+
},
|
|
209
|
+
cancelButton: {
|
|
210
|
+
backgroundColor: 'transparent',
|
|
211
|
+
},
|
|
212
|
+
cancelText: {
|
|
213
|
+
fontSize: 16,
|
|
214
|
+
fontWeight: '600',
|
|
215
|
+
},
|
|
216
|
+
confirmText: {
|
|
217
|
+
fontSize: 16,
|
|
218
|
+
fontWeight: '600',
|
|
219
|
+
},
|
|
220
|
+
});
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import React, { useState, useMemo, useCallback, useEffect } from 'react';
|
|
2
|
+
import { Pressable, Text, StyleSheet } from 'react-native';
|
|
3
|
+
import type { BSDateValue } from '../../core/types';
|
|
4
|
+
import { isValidBSDate, isBSDateInSupportedRange } from '../../core/validation';
|
|
5
|
+
import { useCalendarTheme } from '../../theme';
|
|
6
|
+
import { safeFormatBSDate, warnOutOfRangeInDev, warnMinMaxInDev } from '../../utils';
|
|
7
|
+
import { DatePickerModal } from './DatePickerModal';
|
|
8
|
+
import type { NepaliDatePickerProps } from './types';
|
|
9
|
+
|
|
10
|
+
export function NepaliDatePicker({
|
|
11
|
+
value,
|
|
12
|
+
defaultValue,
|
|
13
|
+
onChange,
|
|
14
|
+
placeholder = 'Select date',
|
|
15
|
+
disabled = false,
|
|
16
|
+
locale,
|
|
17
|
+
numerals,
|
|
18
|
+
displayFormat = 'yyyy-MM-dd',
|
|
19
|
+
minDate,
|
|
20
|
+
maxDate,
|
|
21
|
+
markedDates,
|
|
22
|
+
disabledDates,
|
|
23
|
+
weekStartsOn,
|
|
24
|
+
theme,
|
|
25
|
+
colorScheme,
|
|
26
|
+
modalTitle,
|
|
27
|
+
confirmText,
|
|
28
|
+
cancelText,
|
|
29
|
+
onOpen,
|
|
30
|
+
onClose,
|
|
31
|
+
testID,
|
|
32
|
+
}: NepaliDatePickerProps) {
|
|
33
|
+
const [modalVisible, setModalVisible] = useState(false);
|
|
34
|
+
const calendarTheme = useCalendarTheme({ colorScheme, theme });
|
|
35
|
+
|
|
36
|
+
const isControlled = value !== undefined;
|
|
37
|
+
const [internalValue, setInternalValue] = useState<BSDateValue | null>(
|
|
38
|
+
defaultValue ?? null
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (value) {
|
|
43
|
+
if (!isValidBSDate(value)) {
|
|
44
|
+
if (__DEV__) {
|
|
45
|
+
console.warn(
|
|
46
|
+
'react-native-bikram-sambat: Invalid date value provided to NepaliDatePicker.',
|
|
47
|
+
value
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
} else if (!isBSDateInSupportedRange(value)) {
|
|
51
|
+
warnOutOfRangeInDev(value, { min: 2000, max: 2090 });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}, [value]);
|
|
55
|
+
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
warnMinMaxInDev(minDate, maxDate);
|
|
58
|
+
}, [minDate, maxDate]);
|
|
59
|
+
|
|
60
|
+
const currentValue = isControlled
|
|
61
|
+
? (value && isValidBSDate(value) && isBSDateInSupportedRange(value) ? value : null)
|
|
62
|
+
: internalValue;
|
|
63
|
+
|
|
64
|
+
const displayText = useMemo(() => {
|
|
65
|
+
if (!currentValue) return placeholder;
|
|
66
|
+
|
|
67
|
+
const formatted = safeFormatBSDate(currentValue, displayFormat, locale, numerals);
|
|
68
|
+
return formatted ?? placeholder;
|
|
69
|
+
}, [currentValue, placeholder, displayFormat, locale, numerals]);
|
|
70
|
+
|
|
71
|
+
const handleOpen = useCallback(() => {
|
|
72
|
+
if (disabled) return;
|
|
73
|
+
setModalVisible(true);
|
|
74
|
+
onOpen?.();
|
|
75
|
+
}, [disabled, onOpen]);
|
|
76
|
+
|
|
77
|
+
const handleClose = useCallback(() => {
|
|
78
|
+
setModalVisible(false);
|
|
79
|
+
onClose?.();
|
|
80
|
+
}, [onClose]);
|
|
81
|
+
|
|
82
|
+
const handleChange = useCallback(
|
|
83
|
+
(date: BSDateValue) => {
|
|
84
|
+
if (!isControlled) {
|
|
85
|
+
setInternalValue(date);
|
|
86
|
+
}
|
|
87
|
+
onChange?.(date);
|
|
88
|
+
},
|
|
89
|
+
[isControlled, onChange]
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
const accessibilityLabel = useMemo(() => {
|
|
93
|
+
if (disabled) return `${placeholder}, disabled`;
|
|
94
|
+
if (currentValue) {
|
|
95
|
+
const formatted = safeFormatBSDate(currentValue, displayFormat, locale, numerals);
|
|
96
|
+
return formatted ?? placeholder;
|
|
97
|
+
}
|
|
98
|
+
return placeholder;
|
|
99
|
+
}, [currentValue, placeholder, displayFormat, locale, numerals, disabled]);
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<>
|
|
103
|
+
<Pressable
|
|
104
|
+
style={[
|
|
105
|
+
styles.field,
|
|
106
|
+
{
|
|
107
|
+
borderColor: calendarTheme.colors.fieldBorder,
|
|
108
|
+
backgroundColor: calendarTheme.colors.fieldBackground,
|
|
109
|
+
},
|
|
110
|
+
disabled && styles.fieldDisabled,
|
|
111
|
+
]}
|
|
112
|
+
onPress={handleOpen}
|
|
113
|
+
disabled={disabled}
|
|
114
|
+
accessibilityRole="button"
|
|
115
|
+
accessibilityLabel={accessibilityLabel}
|
|
116
|
+
accessibilityState={{ disabled }}
|
|
117
|
+
testID={testID}
|
|
118
|
+
>
|
|
119
|
+
<Text
|
|
120
|
+
style={[
|
|
121
|
+
styles.fieldText,
|
|
122
|
+
{
|
|
123
|
+
color: currentValue
|
|
124
|
+
? calendarTheme.colors.text
|
|
125
|
+
: calendarTheme.colors.placeholderText,
|
|
126
|
+
},
|
|
127
|
+
]}
|
|
128
|
+
>
|
|
129
|
+
{displayText}
|
|
130
|
+
</Text>
|
|
131
|
+
</Pressable>
|
|
132
|
+
|
|
133
|
+
<DatePickerModal
|
|
134
|
+
visible={modalVisible}
|
|
135
|
+
value={currentValue}
|
|
136
|
+
defaultValue={defaultValue}
|
|
137
|
+
onChange={handleChange}
|
|
138
|
+
onClose={handleClose}
|
|
139
|
+
locale={locale}
|
|
140
|
+
numerals={numerals}
|
|
141
|
+
minDate={minDate}
|
|
142
|
+
maxDate={maxDate}
|
|
143
|
+
markedDates={markedDates}
|
|
144
|
+
disabledDates={disabledDates}
|
|
145
|
+
weekStartsOn={weekStartsOn}
|
|
146
|
+
theme={theme}
|
|
147
|
+
colorScheme={colorScheme}
|
|
148
|
+
title={modalTitle}
|
|
149
|
+
confirmText={confirmText}
|
|
150
|
+
cancelText={cancelText}
|
|
151
|
+
/>
|
|
152
|
+
</>
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const styles = StyleSheet.create({
|
|
157
|
+
field: {
|
|
158
|
+
borderWidth: 1,
|
|
159
|
+
borderRadius: 10,
|
|
160
|
+
paddingHorizontal: 16,
|
|
161
|
+
paddingVertical: 14,
|
|
162
|
+
alignItems: 'center',
|
|
163
|
+
},
|
|
164
|
+
fieldDisabled: {
|
|
165
|
+
opacity: 0.5,
|
|
166
|
+
},
|
|
167
|
+
fieldText: {
|
|
168
|
+
fontSize: 16,
|
|
169
|
+
fontWeight: '500',
|
|
170
|
+
},
|
|
171
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { BSDateValue } from '../../core/types';
|
|
2
|
+
import type { LocaleCode, CalendarLocale, NumeralSystem } from '../../core/locale';
|
|
3
|
+
import type { CalendarTheme } from '../../theme/types';
|
|
4
|
+
import type { CalendarMarkedDate } from '../NepaliCalendar/types';
|
|
5
|
+
|
|
6
|
+
export type NepaliDatePickerProps = {
|
|
7
|
+
value?: BSDateValue | null;
|
|
8
|
+
defaultValue?: BSDateValue;
|
|
9
|
+
onChange?: (date: BSDateValue) => void;
|
|
10
|
+
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
|
|
14
|
+
locale?: LocaleCode | CalendarLocale;
|
|
15
|
+
numerals?: NumeralSystem;
|
|
16
|
+
|
|
17
|
+
displayFormat?: string;
|
|
18
|
+
|
|
19
|
+
minDate?: BSDateValue;
|
|
20
|
+
maxDate?: BSDateValue;
|
|
21
|
+
|
|
22
|
+
markedDates?: Record<string, CalendarMarkedDate>;
|
|
23
|
+
disabledDates?: string[] | ((date: BSDateValue) => boolean);
|
|
24
|
+
|
|
25
|
+
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
26
|
+
|
|
27
|
+
theme?: Partial<CalendarTheme>;
|
|
28
|
+
colorScheme?: 'light' | 'dark' | 'system';
|
|
29
|
+
|
|
30
|
+
modalTitle?: string;
|
|
31
|
+
confirmText?: string;
|
|
32
|
+
cancelText?: string;
|
|
33
|
+
|
|
34
|
+
onOpen?: () => void;
|
|
35
|
+
onClose?: () => void;
|
|
36
|
+
|
|
37
|
+
testID?: string;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export type DatePickerModalProps = {
|
|
41
|
+
visible: boolean;
|
|
42
|
+
|
|
43
|
+
value?: BSDateValue | null;
|
|
44
|
+
defaultValue?: BSDateValue;
|
|
45
|
+
|
|
46
|
+
onChange?: (date: BSDateValue) => void;
|
|
47
|
+
onConfirm?: (date: BSDateValue) => void;
|
|
48
|
+
onCancel?: () => void;
|
|
49
|
+
onClose?: () => void;
|
|
50
|
+
|
|
51
|
+
locale?: LocaleCode | CalendarLocale;
|
|
52
|
+
numerals?: NumeralSystem;
|
|
53
|
+
|
|
54
|
+
minDate?: BSDateValue;
|
|
55
|
+
maxDate?: BSDateValue;
|
|
56
|
+
|
|
57
|
+
markedDates?: Record<string, CalendarMarkedDate>;
|
|
58
|
+
disabledDates?: string[] | ((date: BSDateValue) => boolean);
|
|
59
|
+
|
|
60
|
+
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
61
|
+
|
|
62
|
+
theme?: Partial<CalendarTheme>;
|
|
63
|
+
colorScheme?: 'light' | 'dark' | 'system';
|
|
64
|
+
|
|
65
|
+
title?: string;
|
|
66
|
+
confirmText?: string;
|
|
67
|
+
cancelText?: string;
|
|
68
|
+
|
|
69
|
+
testID?: string;
|
|
70
|
+
};
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import React, { useState, useMemo, useCallback, useEffect } from 'react';
|
|
2
|
+
import { Pressable, Text, StyleSheet } from 'react-native';
|
|
3
|
+
import { isValidBSDate, isBSDateInSupportedRange } from '../../core/validation';
|
|
4
|
+
import { useCalendarTheme } from '../../theme';
|
|
5
|
+
import { safeFormatBSDate, warnOutOfRangeInDev, warnMinMaxInDev } from '../../utils';
|
|
6
|
+
import { RangePickerModal } from './RangePickerModal';
|
|
7
|
+
import type { NepaliRangePickerProps, DateRangeValue } from './types';
|
|
8
|
+
|
|
9
|
+
export function NepaliRangePicker({
|
|
10
|
+
value,
|
|
11
|
+
defaultValue,
|
|
12
|
+
onChange,
|
|
13
|
+
placeholder = 'Select date range',
|
|
14
|
+
disabled = false,
|
|
15
|
+
locale,
|
|
16
|
+
numerals,
|
|
17
|
+
displayFormat = 'yyyy-MM-dd',
|
|
18
|
+
minDate,
|
|
19
|
+
maxDate,
|
|
20
|
+
markedDates,
|
|
21
|
+
disabledDates,
|
|
22
|
+
weekStartsOn,
|
|
23
|
+
allowSameDay = true,
|
|
24
|
+
theme,
|
|
25
|
+
colorScheme,
|
|
26
|
+
modalTitle,
|
|
27
|
+
confirmText,
|
|
28
|
+
cancelText,
|
|
29
|
+
clearText,
|
|
30
|
+
onOpen,
|
|
31
|
+
onClose,
|
|
32
|
+
testID,
|
|
33
|
+
}: NepaliRangePickerProps) {
|
|
34
|
+
const [modalVisible, setModalVisible] = useState(false);
|
|
35
|
+
const calendarTheme = useCalendarTheme({ colorScheme, theme });
|
|
36
|
+
|
|
37
|
+
const isControlled = value !== undefined;
|
|
38
|
+
const [internalValue, setInternalValue] = useState<DateRangeValue>(
|
|
39
|
+
defaultValue ?? { start: null, end: null }
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (value?.start) {
|
|
44
|
+
if (!isValidBSDate(value.start)) {
|
|
45
|
+
if (__DEV__) {
|
|
46
|
+
console.warn(
|
|
47
|
+
'react-native-bikram-sambat: Invalid start date provided to NepaliRangePicker.',
|
|
48
|
+
value.start
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
} else if (!isBSDateInSupportedRange(value.start)) {
|
|
52
|
+
warnOutOfRangeInDev(value.start, { min: 2000, max: 2090 });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (value?.end) {
|
|
56
|
+
if (!isValidBSDate(value.end)) {
|
|
57
|
+
if (__DEV__) {
|
|
58
|
+
console.warn(
|
|
59
|
+
'react-native-bikram-sambat: Invalid end date provided to NepaliRangePicker.',
|
|
60
|
+
value.end
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
} else if (!isBSDateInSupportedRange(value.end)) {
|
|
64
|
+
warnOutOfRangeInDev(value.end, { min: 2000, max: 2090 });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}, [value]);
|
|
68
|
+
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
warnMinMaxInDev(minDate, maxDate);
|
|
71
|
+
}, [minDate, maxDate]);
|
|
72
|
+
|
|
73
|
+
const currentValue = isControlled ? value : internalValue;
|
|
74
|
+
|
|
75
|
+
const displayText = useMemo(() => {
|
|
76
|
+
if (!currentValue || (!currentValue.start && !currentValue.end)) {
|
|
77
|
+
return placeholder;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const startStr = currentValue.start
|
|
81
|
+
? safeFormatBSDate(currentValue.start, displayFormat, locale, numerals)
|
|
82
|
+
: null;
|
|
83
|
+
const endStr = currentValue.end
|
|
84
|
+
? safeFormatBSDate(currentValue.end, displayFormat, locale, numerals)
|
|
85
|
+
: null;
|
|
86
|
+
|
|
87
|
+
if (startStr && endStr) return `${startStr} → ${endStr}`;
|
|
88
|
+
if (startStr) return `${startStr} → ...`;
|
|
89
|
+
return placeholder;
|
|
90
|
+
}, [currentValue, placeholder, displayFormat, locale, numerals]);
|
|
91
|
+
|
|
92
|
+
const handleOpen = useCallback(() => {
|
|
93
|
+
if (disabled) return;
|
|
94
|
+
setModalVisible(true);
|
|
95
|
+
onOpen?.();
|
|
96
|
+
}, [disabled, onOpen]);
|
|
97
|
+
|
|
98
|
+
const handleClose = useCallback(() => {
|
|
99
|
+
setModalVisible(false);
|
|
100
|
+
onClose?.();
|
|
101
|
+
}, [onClose]);
|
|
102
|
+
|
|
103
|
+
const handleChange = useCallback(
|
|
104
|
+
(range: DateRangeValue) => {
|
|
105
|
+
if (!isControlled) {
|
|
106
|
+
setInternalValue(range);
|
|
107
|
+
}
|
|
108
|
+
onChange?.(range);
|
|
109
|
+
},
|
|
110
|
+
[isControlled, onChange]
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
const handleClear = useCallback(() => {
|
|
114
|
+
if (!isControlled) {
|
|
115
|
+
setInternalValue({ start: null, end: null });
|
|
116
|
+
}
|
|
117
|
+
onChange?.({ start: null, end: null });
|
|
118
|
+
}, [isControlled, onChange]);
|
|
119
|
+
|
|
120
|
+
const accessibilityLabel = useMemo(() => {
|
|
121
|
+
if (disabled) return `${placeholder}, disabled`;
|
|
122
|
+
if (currentValue?.start) {
|
|
123
|
+
const startStr = safeFormatBSDate(currentValue.start, displayFormat, locale, numerals);
|
|
124
|
+
const endStr = currentValue.end
|
|
125
|
+
? safeFormatBSDate(currentValue.end, displayFormat, locale, numerals)
|
|
126
|
+
: null;
|
|
127
|
+
if (startStr && endStr) return `${startStr} to ${endStr}`;
|
|
128
|
+
if (startStr) return `${startStr}, start date selected`;
|
|
129
|
+
}
|
|
130
|
+
return placeholder;
|
|
131
|
+
}, [currentValue, placeholder, displayFormat, locale, numerals, disabled]);
|
|
132
|
+
|
|
133
|
+
return (
|
|
134
|
+
<>
|
|
135
|
+
<Pressable
|
|
136
|
+
style={[
|
|
137
|
+
styles.field,
|
|
138
|
+
{
|
|
139
|
+
borderColor: calendarTheme.colors.fieldBorder,
|
|
140
|
+
backgroundColor: calendarTheme.colors.fieldBackground,
|
|
141
|
+
},
|
|
142
|
+
disabled && styles.fieldDisabled,
|
|
143
|
+
]}
|
|
144
|
+
onPress={handleOpen}
|
|
145
|
+
disabled={disabled}
|
|
146
|
+
accessibilityRole="button"
|
|
147
|
+
accessibilityLabel={accessibilityLabel}
|
|
148
|
+
accessibilityState={{ disabled }}
|
|
149
|
+
testID={testID}
|
|
150
|
+
>
|
|
151
|
+
<Text
|
|
152
|
+
style={[
|
|
153
|
+
styles.fieldText,
|
|
154
|
+
{
|
|
155
|
+
color: currentValue?.start
|
|
156
|
+
? calendarTheme.colors.text
|
|
157
|
+
: calendarTheme.colors.placeholderText,
|
|
158
|
+
},
|
|
159
|
+
]}
|
|
160
|
+
>
|
|
161
|
+
{displayText}
|
|
162
|
+
</Text>
|
|
163
|
+
</Pressable>
|
|
164
|
+
|
|
165
|
+
<RangePickerModal
|
|
166
|
+
visible={modalVisible}
|
|
167
|
+
value={currentValue}
|
|
168
|
+
defaultValue={defaultValue}
|
|
169
|
+
onChange={handleChange}
|
|
170
|
+
onClose={handleClose}
|
|
171
|
+
onClear={handleClear}
|
|
172
|
+
locale={locale}
|
|
173
|
+
numerals={numerals}
|
|
174
|
+
minDate={minDate}
|
|
175
|
+
maxDate={maxDate}
|
|
176
|
+
markedDates={markedDates}
|
|
177
|
+
disabledDates={disabledDates}
|
|
178
|
+
weekStartsOn={weekStartsOn}
|
|
179
|
+
allowSameDay={allowSameDay}
|
|
180
|
+
theme={theme}
|
|
181
|
+
colorScheme={colorScheme}
|
|
182
|
+
title={modalTitle}
|
|
183
|
+
confirmText={confirmText}
|
|
184
|
+
cancelText={cancelText}
|
|
185
|
+
clearText={clearText}
|
|
186
|
+
/>
|
|
187
|
+
</>
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const styles = StyleSheet.create({
|
|
192
|
+
field: {
|
|
193
|
+
borderWidth: 1,
|
|
194
|
+
borderRadius: 10,
|
|
195
|
+
paddingHorizontal: 16,
|
|
196
|
+
paddingVertical: 14,
|
|
197
|
+
alignItems: 'center',
|
|
198
|
+
},
|
|
199
|
+
fieldDisabled: {
|
|
200
|
+
opacity: 0.5,
|
|
201
|
+
},
|
|
202
|
+
fieldText: {
|
|
203
|
+
fontSize: 16,
|
|
204
|
+
fontWeight: '500',
|
|
205
|
+
},
|
|
206
|
+
});
|