0.1.6 • Published 5 years ago

@giliweb/vue-date-range-picker v0.1.6

Weekly downloads
8
License
MIT
Repository
github
Last release
5 years ago

vue-date-range-picker

A vue component using Bootstrap 4 styles for date range selection

Vue-Treeselect Screenshot

Live demo (jsfiddle)

Features

  • Date range selection
  • Compare feature: select a second date range
  • No integration: DIY with your favorite vue components or js libraries
  • Bootstrap 4 styles (requires Bootstrap 4 CSS)
  • Returns Moment.js instances (requires moment.js)

Installation

npm install --save @owumaro/vue-date-range-picker

Usage

Webpack

JavaScript

// Import the component
import DateRangePicker from '@owumaro/vue-date-range-picker'

export default {
  // Register the component
  components: { DateRangePicker },
  
  // Create a method for the submit event
  methods: {
    updateRanges: function(range) {
      ...
    }
  },
  ...
}

HTML template

<date-range-picker v-on:submit="updateRanges" />

Browser

Vue.use(DateRangePicker)

API

Events

As the component needs to transmit multiple values (startDate, endDate, compare, startDateCompare, endDateCompare), it can not use v-model.

Instead, it triggers 2 events:

  • submit: when the submit button is clicked; provides an Object argument with the 5 attributes mentioned above
  • cancel: when the cancel button is clicked

Props

PropTypeDefaultDescription
calendar-countNumber2Number of calendars to display
allow-compareBooleantrueEnable/disable the comparison feature
rangesObject{ currentMonth: { ... }, lastMonth: { ... } }Predefined ranges displayed in select menu(s)
default-range-selectStringcurrentMonthKey of the range to select by default
default-range-select-compareStringlastMonthKey of the range to select by default (compare)

Development

npm install
npm run dev

Inspiration

TODO

  • Tests
  • CSS without bootstrap dependency