Calendar component

Overview

vue-calendar-picker

Calendar component

vue-calendar-picker screenshot

vue-calendar-picker demo on jsfiddle

Example - basic

<template>
    <calendar></calendar>
</template>

<script>

import {calendar} from 'vue-calendar-picker'

export default {
    components: {
        calendar: calendar
    }
}

</script>

Install

npm install --save vue-calendar-picker

Features

  • zoom from decade view to hour view (decade, year, month, week, day, hour)
  • localized (see supported locale list)
  • autodetect the first day of the week
  • animated (zoom & slide)
  • multiple calendar views (side-by-side)
  • display one-time events and date/time period
  • date/time period selection
  • touch screen support
  • only one dependancy: date-fns, a Modern JavaScript date utility library

vue-calendar-picker has 3 available components:

  • calendar.vue: simple calendar.
  • calendarEvents.vue: calendar.vue + one-time events and date/time periods display.
  • calendarRange.vue: calendarEvents.vue + range selection.

Conventions

  • date ranges are inclusive, exclusive ([start, end[)

API - calendar.vue

Properties

:locale string, default: navigator.language

The locale of the calendar. Impacts the days names, month names and first day ofthe week. supported locale list. Locale name must be uppercase.

:compact boolean, default: false

Enable compact mode. Use less UI space.

:initialView number, default: 6 (month view)

Initial view zoom.

:initialCurrent Date, default: new Date

Initial view date.

:itemClass function(range), default: empty function

Called for each calendar cell. The retun valus is used as className of the cell.

:viewCount number, default: 1

Allow to display multiple calendar views side-by-side.

:showOverlappingDays boolean, default: viewCount === 1

In the month view, show days belonging to the preceding and following month.

Events

@action (eventObject)

eventObject has the following properties:

eventType string
  • 'down': mousedown or touchstart
  • 'up': mouseup or touchend
  • 'tap': click or tap
  • 'press': dblclick or longtap
  • 'over': mouseover or touchmove
eventActive boolean

Indicates that the pointer is active: a mouse button is down or the finger touches the screen.

keyActive boolean

Indicates that the shift or ctrl or alt or meta key is down. Always false on touch-screen devices.

range { start: Date, end: Date }

The date range of the item

rangeType string

The range name: 'minute', 'hour', 'day', 'week', 'month', 'year'.

Slots

default slot scope: itemRange, layout / default: empty

The content of calendar cells.

itemRange { start: Date, end: Date }

The time range of the the cell.

layout string

The layout of the content, either 'horizontal' or 'vertical'.

Styling

vue-calendar-picker can by styled easily, all css selectors are prefixed with .calendar.

example
.calendar {
    border: 2px solid #000;
    border-radius: 0.5em;
    padding: 0.5em;
}

UI details

  • click on date part in the calendar header area to modify it (zoom out)
  • click or double-click on the cell to zoom in. (from month view, use double-click to zoom in)

API - calendarEvents.vue

Properties

:locale - see calendar.vue API.

:compact - see calendar.vue API.

:initialView - see calendar.vue API.

:initialCurrent - see calendar.vue API.

:itemClass - see calendar.vue API.

:events Array for { color: CSS color, start: Date, end: Date }

A list of one-time events and date/time periods to display in the calendar.
One-time events has the same start and end date.

:selection { start: Date, end: Date }

The current calendar selection. For display only.

Events

@action (eventObject)

eventObject has the same properties that calendar.vue added:

calendarEvent object

A reference to a calendar event (see :events property) related to the mouse/touch event, otherwise undefined.

UI details

  • event range are colored lines
  • event point are big dots

API - calendarRange.vue

Allow user selection. The selection property object is modified according to the user's selection.

Properties

:locale - see calendar.vue API.

:compact - see calendar.vue API.

:initialView - see calendar.vue API.

:initialCurrent - see calendar.vue API.

:itemClass - see calendar.vue API.

:events - see calendarEvents.vue API.

:selection - see calendarEvents.vue API.

:useTwoCalendars boolean, default: false

Display two calendars side-by-side to make selection easier.

Events

@action (eventObject)

eventObject has the same properties that calendar.vue.

UI details

  • use mousedown + move or tap + move to select a range (also across calendars)
  • use ctrl + click to update the selection from the nearest end point (disbled on touch screens)

Browser support

Same browser support as Vue.js 2

Example - advanced

<template>
    <calendar-range :events="calendarEvents" :selection="calendarSelection"></calendar-range>
</template>

<script>

import {calendarRange} from 'vue-calendar-picker'

export default {
    components: {
        calendarRange: calendarRange
    },
    data() {
        return {
            calendarEvents: [
                // periods
                { color:'#aaf', start: new Date(2016, 9, 5, 0,0,0,0), end: new Date(2017, 4, 15, 0,0,0,0) },
                { color:'#afa', start: new Date(2016, 9, 5, 0,0,0,0), end: new Date(2017, 4, 13, 0,0,0,0) },
                { color:'#faa', start: new Date(2017, 4, 8, 12,30, 0,0), end: new Date(2017, 4, 9, 6,30, 0,0) },
                // one-time
                { color:'#faa', start: new Date(2017, 4, 2, 0,0,0,0), end: new Date(2017, 4, 2, 0,0,0,0) },
                { color:'#aaa', start: new Date(2017, 4, 2, 0,0,0,0), end: new Date(2017, 4, 2, 0,0,0,0) },
            ],
            calendarSelection: {
                start: new Date(2017, 4, 2), end: new Date(2017, 4, 7, 12)
            }
        }
    }
}
</script>

Demo

vue-calendar-picker demo

Credits

Franck Freiburger

Comments
  • [Vue warn]: Failed to mount component

    [Vue warn]: Failed to mount component

    Thanks for this component; it looks really useful, but I cannot get it to work in a simple npm+webpack+vue project. Console gives this error:

    [Vue warn]: Failed to mount component: template or render function not defined.
    
    found in
    
    ---> <Calendar>
           <App> at src/App.vue
             <Root>
    

    Sample project created with vue init webpack calendar (chose Runtime + Compiler option for Vue).

    This is the default App.vue created by the init script above, removing HelloWorld component (which works) for your calendar component:

    <template>
      <div id="app">
        <calendar/>
      </div>
    </template>
    
    <script>
    import {calendar} from 'vue-calendar-picker'
    
    export default {
      name: 'app',
      components: {
        calendar: calendar
      }
    }
    </script>
    
    <style>
    </style>
    

    Maybe I'm doing something wrong here? Any advice is most welcome.

    bug 
    opened by nebaughman 1
  • Cannot find module './zh/index.js

    Cannot find module './zh/index.js

    • there is a errlog Error in render function: "Error: Cannot find module './zh/index.js'."

    • I think the reason is here. ‘src/mixin.js’

    • The specific code location is here

    default property

    locale:{

    type:String,

    default: (navigator.language || navigator.userLanguage).substr(0,2).toUpperCase()

    validator: function(value) { return value === value.toUpperCase(); }

    }

    opened by sevensung 1
  • Wrong package name in import line in example

    Wrong package name in import line in example

    Your example line has

    import { calendarRange } from 'vue-calendar'
    

    but the package name is vue-calendar-picker so the line should be:

    import { calendarRange } from 'vue-calendar-picker'
    
    opened by Pistos 1
  • Set/change current view date

    Set/change current view date

    I am using calendarRange, and am programmatically updating the selection, and that works just fine. However, sometimes that selection is not visible in the current view (e.g. looking at June, and the selection is the first week of May). How can I update the current month to go to, say, the start date of the selection?

    I've tried this, but it doesn't work (only snippets shown, for brevity):

        <calendar-range                                                                                                                         
          :events="calendarEvents"                                                                                                              
          :selection="calendarSelection"                                                                                                        
          :initialCurrent="currentCalendarDate"                                                                                                 
        ></calendar-range>
    
        currentCalendarDate: function () {                                                                                                      
          return this.currentCalendarMoment.toDate()                                                                                            
        },
    
        this.currentCalendarMoment = moment('2017-05-01')
    
    enhancement 
    opened by Pistos 0
  • Styling the currently selected date in calendar.vue component

    Styling the currently selected date in calendar.vue component

    Great plugin!

    I noticed you can style the calendar ranges, but I can't figure out what class to use to style the currently selected date in the regular calendar.vue component. I noticed the parent spans have "today" and "notInMonth" classes, but nothing for the selected date. Any ideas on how i can do this?

    opened by jelazos7 0
  • Wrong css selector in calendarEvents.vue

    Wrong css selector in calendarEvents.vue

    I guess, the class selectors should be "horizontal" and "vertical" instead of "horizontalLayout" and "verticalLayout". In purified css the current selectors are skipped, hence the eventRange line is not shown.

    question 
    opened by bluemoon24 4
  • Add property for zooming limits

    Add property for zooming limits

    First of, this is a great package. Thanks for sharing. Would be nice, if a something was added where the zoom-level could be limited. For instance, I just need navigation down to days (i.e. month view) and want to prevent users from going to day view.

    enhancement 
    opened by bluemoon24 0
Owner
Franck Freiburger
Freelance IT developer
Franck Freiburger
Calendar component

vue-calendar-picker Calendar component vue-calendar-picker demo on jsfiddle Example - basic <template> <calendar></calendar> </template> <script>

Franck Freiburger 47 Nov 24, 2022
A vue component for lunar calendar.

vue-lunar-calendar A vue component for lunar calendar. Uses Moment.js for date operations. This is the Korean lunar calendar. It is different from Chi

Kim WooHyun 70 Aug 20, 2022
Simple Vue component to show a month-grid calendar with events

VueSimpleCalendar Introduction vue-simple-calendar is a flexible, themeable, lightweight calendar component for Vue that supports multi-day scheduled

Richard Tallent 762 Jan 3, 2023
A lightweight calendar component for Vue2

vue2-calendar Check out the demo here on Code Sandbox: Introduction This is a simple and small event calendar component for Vue js. It is very lightwe

Vincent 55 May 2, 2022
A simple infinite calendar component in Vue 2

vue-infinite-calendar A simple infinite calendar component in Vue 2 Build Setup # install dependencies npm install # serve with hot reload at localho

Rares S 15 Feb 28, 2022
A calendar component for Vue.js

calendar Chinese This is a calendar component based on vue.js . support custom content. No dependencies. Currently, It only supports month view. You c

Kylin 47 Aug 16, 2022
vue 2.x calendar component

vue2-calendar vue 2 calendar, datepicker component which supported lunar or date event Live Demo >> This project is not only a vue component, but also

Terry Cai 485 Dec 18, 2022
Vue.js Functional Calendar | Component/Package

Vue Functional Calendar Modern calendar and datepicker module for Vue.js Demo Demo: https://y3jnxov469.codesandbox.io/ Lightweight, high-performance c

Manuk 425 Dec 27, 2022
📅 A feature-rich calendar component, support multiple modes and gesture sliding. For vue 3.0+

?? A calendar component for vue3.0. Support gesture sliding, range selection, according to the week switch...

飞翔的荷兰人 434 Jan 3, 2023
a horizontal calendar component for Vue.js

a horizontal calendar component for Vue.js

jacques 37 Aug 10, 2022
A simple vue calendar component. Base for further development and styling.

vue-simple-calendar A simple vue calendar component with minimal css. A base for further development/styling. DEMO Dependencies date-fns, lodash-es In

Roman Ranniew 6 Jun 15, 2022
vue calendar fullCalendar. no jquery required. Schedule events management

##vue-fullcalendar Works for Vue2 now. This is a fullCalendar component based on vue.js . No Jquery or fullCalendar.js required. Currently, It only su

Sunny Wang 1.5k Dec 18, 2022
A simple events calendar for Vue2, no dependencies except Vue2.

vue-event-calendar A simple events calendar for Vue2, no dependencies except Vue2. responsive & mobile first. Live Demo Here 中文文档 Requirements vue: ^2

Geoff Zhu 633 Nov 11, 2022
An elegant calendar and datepicker plugin for Vue.

An elegant calendar and datepicker plugin for Vuejs. npm i --save v-calendar Documentation For full documentation, visit vcalendar.io. Attributes High

Nathan Reyes 3.7k Dec 31, 2022
Full calendar base on Vue2 and momentjs.

Vue2 Calendar Component Full calendar base on Vue2 and dayjs. Support month and week view. Custom date item style with scopeSlots. 中文文档 ?? Live demo I

Kit 75 Nov 11, 2022
A full event display calendar for the Quasar framework that has multiple viewing formats.

Daykeep Calendar An event display calendar for the Quasar framework. Formerly known as Quasar Calendar, Daykeep Calendar for Quasar is a Quasar-flavor

Stormseed 260 Nov 29, 2022
Vue.js wrapper for TOAST UI Calendar

Vue TOAST UI Calendar A Vue.js wrapper for TOAST UI Calendar Installation npm install --save tui-calendar @lkmadushan/vue-tuicalendar Usage Example Tr

Kalpa Madushan Perera 129 Aug 13, 2022
Toast UI Calendar for Vue

TOAST UI Calendar for Vue This is Vue component wrapping TOAST UI Calendar. ?? Table of Contents Collect statistics on the use of open source Install

NHN 195 Dec 6, 2022
A Vue JS full calendar, no dependency, no BS. :metal:

vue-cal A Vue JS full calendar, no dependency, no BS. ?? Installation npm i vue-cal Vue 3 npm i vue-cal@next Demo & Documentation antoniandre.github

Antoni 982 Dec 29, 2022