1.0.0 • Published 1 year ago

vue-inline-calendar v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Vue3 Inline Calendar

The simple, functional inline calendar component for Vue3 (you can find the version for Vue2 here) based on Intersection Observer API — just drag and scroll to get future and past dates.

Installation

npm i vue-inline-calendar -S

or

yarn add vue-inline-calendar

Usage

Options API

<template>
    <div id="app">
        <vue-inline-calendar @update:selected-date="selectedDate = $event" />
    </div>
</template>

<script>
import VueInlineCalendar from 'vue-inline-calendar';
import "vue-inline-calendar/dist/style.css";

export default {
  name: 'App',
  components: {
    VueInlineCalendar
  },
  data() {
    return {
      selectedDate: null
    }
  },
}
</script>

Composition API

<template>
    <div id="app">
        <vue-inline-calendar @update:selected-date="selectedDate = $event" />
    </div>
</template>

<script>
import { ref } from 'vue;
import VueInlineCalendar from 'vue-inline-calendar';
import "vue-inline-calendar/dist/style.css";

export default {
  name: 'App',
  components: {
    VueInlineCalendar
  },
  setup() {
    const selectedDate = ref(null);
    
    return {
        selectedDate
    }
}
</script>

Available props

Prop nameDescriptionTypeDefault value
selectedDateInitial selected dateDatenull
selectedRangeInitial selected range of datesObjectnull
daysRangeNumber of days, which will be loaded on scrollNumber7
itemWidthWidth of date element (.date-item)Number80
itemsGapDistance between date elementsNumber10
localeA string with a BCP 47 language tagString"en-US"
scrollSpeedSpeed of dates scrollNumber4
disableWeekendsExcluding weekends from selectionBooleanfalse
specMinDateMinimum allowed dateDatenull
specMaxDateMaximum allowed dateDatenull
disablePastDaysExcluding dates before today's date from selectionBooleanfalse
disableNextDaysExcluding dates after today's date from selectionBooleanfalse
isRangeSetting up range mode — selection of start and end datesBooleanfalse
showYearShowing of the current year (pass false, if you want to hide the year)Booleantrue
showMonthShowing of the date's month (pass false, if you want to hide the month)Booleantrue
showWeekdayShowing of the date's weekend (pass false, if you want to hide the weekend)Booleantrue
enableMousewheelScrollEnabling of the calendar scrolling when using the mousewheelBooleanfalse

Available events

Event nameDescriptionPayload
update:selected-dateFires on date selectionSelected date (instance of Date object)
update:selected-rangeFires on date range selection (when endDate is selected)Object with startDate and endDate keys and dates as values: {startDate: this.startDate, endDate: this.endDate }

License

MIT License

Support the author

If you would like to support me and my work, you can make a donation via Buy Me a Coffee (link at the section Sponsor this project) or with cryptocurrency:

PlatformAddress
Bitcoinbc1q0rygfalnctew4cla3ed9wfw2pv0uh4r0eyfuag
Ethereum/Tether USDT (TRC20)0x38b3822213c6BDCc01eF770442F5BF0842AB740f
Litecoinltc1qdgs0jult63k6ggjzaedh3er2z7w70aktl5j2wu