1.0.2 • Published 4 years ago

v-year-calendar v1.0.2

Weekly downloads
356
License
Apache-2.0
Repository
github
Last release
4 years ago

v-year-calendar

Official Vue.js wrapper for the year-calendar widget. https://year-calendar.github.io/

npm.io

CircleCI NPM

This library is also available for:

Pure javascript React.js

Installation

You can get the widget using the following methods:

  • From the GitHub repository
  • From the Node package manager, using the following command: npm install v-year-calendar
  • From Yarn, using the following command: yarn add v-year-calendar
  • From the CDN, using the following script: <script src="https://unpkg.com/v-year-calendar@latest/dist/v-year-calendar.umd.min.js"></script>

Usage

You can create a calendar using the following javascript code :

<template>
    <Calendar></Calendar>
</template>

<script>
import Calendar from 'v-year-calendar';

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

Using props

You can specify props to customize the calendar:

<template>
    <Calendar render-style="background" :min-date="new Date()"></Calendar>
</template>

Available props

Option nameDescriptionTypeDefault value
allow-overlapSpecifies whether the user can select a range which overlapping an other element present in the datasource.booleantrue
always-half-daySpecifies whether the beginning and the end of each range should be displayed as half selected day.booleanfalse
context-menu-itemsSpecifies the items of the default context menu.array[]
custom-day-rendererSpecify a custom renderer for data source. Works only with the style set to "custom". This function is called duringender for each day containing at least one event.Render functionnull
custom-data-source-rendererSpecify a custom renderer for days. This function is called during render for each day.Render functionnull
data-sourceThe elements that must be displayed on the calendar.array or function[]
disabled-daysThe days that must be displayed as disabled.array[]
disabled-week-daysThe days of the week that must be displayed as disabled (0 for Sunday, 1 for Monday, etc.).array[]
display-disabled-data-sourceSpecifies whether the data source must be rendered on disabled days.booleanfalse
display-headerSpecifies whether the calendar header is displayed.booleantrue
display-week-numberSpecifies whether the weeks number are displayed.booleanfalse
enable-context-menuSpecifies whether the default context menu must be displayed when right clicking on a day.booleanfalse
enable-range-selectionSpecifies whether the range selection is enabled.booleanfalse
hidden-week-daysThe days of the week that must not be displayed (0 for Sunday, 1 for Monday, etc.).array[]
languageThe language/culture used for calendar rendering.Stringen
loading-templateA custom loading templateStringnull
max-dateThe date until which days are enabled.Datenull
min-dateThe date from which days are enabled.Datenull
round-range-limitsSpecifies whether the beginning and the end of each range should be displayed as rounded cells.booleanfalse
styleSpecifies the style used for displaying datasource ("background", "border" or "custom").stringborder
week-startThe starting day of the week. This option overrides the parameter define in the language file.number0
yearThe year displayed by the calendar.numberCurrent year

Available events

Event nameDescriptionParameter
click-dayFunction fired when a day is clicked.{ date, events }
day-context-menuFunction fired when a day is right clicked.{ date, events }
mouse-on-dayFunction fired when the mouse enter on a day.{ date, events }
mouse-out-dayFunction fired when the mouse leaves a day.{ date, events }
render-endFunction fired when the calendar rendering is ended.{ currentYear }
select-rangeFunction fired when a date range is selected.{ startDate, endDate }
year-changedFunction fired when the visible year of the calendar is changed.{ currentYear }

Language

If you want to use the calendar in a different language, you should import the locale file corresponding to the language you want to use, and then set the language prop of the calendar:

import Calendar from 'v-year-calendar';
import 'v-year-calendar/locales/v-year-calendar.fr';

OR

<script src="https://unpkg.com/v-year-calendar@latest/dist/v-year-calendar.umd.min.js"></script>
<script src="https://unpkg.com/v-year-calendar@latest/locales/v-year-calendar.fr.js"></script>

Then

<template>
    <Calendar language="fr"></Calendar>
</template>

The list of available languages is available here

What next

Check the examples page to discover all the functionalities.