Skip to content

API Overview — Vue 2

This page summarizes the public API surface of nepali-datepicker-vue2.

Package Exports

js
// Default export
import NepaliDatepicker from 'nepali-datepicker-vue2'

// Named export
import { NepaliDatePicker } from 'nepali-datepicker-vue2'

CSS Entry

js
import 'nepali-datepicker-vue2/main.css'

This stylesheet must be imported once in your application entry file. It provides all styles for the input, calendar popup, day grid, month/year selectors, and animations.

Component Registration

vue
<script>
import NepaliDatepicker from 'nepali-datepicker-vue2'

export default {
  components: { NepaliDatepicker }
}
</script>

Global

js
import Vue from 'vue'
import NepaliDatepicker from 'nepali-datepicker-vue2'

Vue.component('NepaliDatepicker', NepaliDatepicker)

v-model Contract

The Vue 2 component follows Vue 2's v-model convention:

AspectValue
Propvalue
Eventinput

This means v-model="date" is equivalent to:

vue
<NepaliDatepicker :value="date" @input="date = $event" />

Vue 3 Difference

In Vue 3, the contract uses modelValue prop and update:modelValue event. If migrating, update your bindings accordingly.

Internal Dependencies

The component uses nepali-date-library internally for all date calculations.

Key imports from the library:

ImportPurpose
NepaliDateCore date object for BS date operations
MONTH_ENArray of English month names (Baisakh, Jestha, …)
WEEK_SHORT_ENShort weekday names (Su, Mo, …)
NEPALI_DATE_MAPLookup table of days-per-month for every supported BS year

Rendering Architecture

The Vue 2 component renders the calendar popup inline inside the component's own DOM using position: absolute. This differs from the Vue 3 version which uses <Teleport>.

Implications:

  • The calendar may be clipped by parent elements with overflow: hidden
  • Positioning is relative to the component's nearest positioned ancestor
  • No automatic viewport-aware repositioning

CSS Class Reference

All internal CSS classes that can be targeted for customization:

ClassElement
.nepali-datepickerRoot wrapper
.calendar-inputText input field
.calendar-input-divInput container
.calendarCalendar popup
.calendar__headHeader row (navigation)
.calendar__header_labelMonth/year text
.calendar__header_selectorClickable month/year label
.calendar__weeksWeekday header row
.calendar__weekdayIndividual weekday label
.calendar__daysDay grid
.calendar__dayIndividual day cell
.selectedCurrently selected day
.todayToday's date
.not_current_monthDay from adjacent month
.calendar__monthsMonth selector grid
.calendar_monthIndividual month option
.calendar__yearsYear selector grid
.calendar__yearIndividual year option
.calendar__toggle_buttonNavigation arrow buttons
.calendar__day_spacerEmpty spacer cell at calendar boundaries

CSS Class Naming Difference

Vue 2 uses simpler class names (e.g. .selected, .today) while Vue 3 prefixes everything with calendar__ (e.g. .calendar__selected, .calendar__today). Keep this in mind if migrating styles.

Released under the MIT License.