Giter Site home page Giter Site logo

damienroche / vue-mj-daterangepicker Goto Github PK

View Code? Open in Web Editor NEW
60.0 5.0 39.0 1.84 MB

๐Ÿ—“Vue.js date range picker with multiples ranges and presets (vue 2.x)

Home Page: https://damienroche.github.io/vue-mj-daterangepicker/

JavaScript 21.76% HTML 1.49% Vue 75.43% TypeScript 1.06% CSS 0.27%
vuejs daterangepicker datepicker vue2 date-picker

vue-mj-daterangepicker's Introduction

vue-mj-daterangepicker

Size Limit example

Installation

You need Vue.js version 2.0+.

1 Install via npm

npm install vue-mj-daterangepicker
yarn add vue-mj-daterangepicker

2 Import and use

import Vue from 'vue'
import DateRangePicker from 'vue-mj-daterangepicker'
import 'vue-mj-daterangepicker/dist/vue-mj-daterangepicker.css'

...

Vue.use(DateRangePicker)

Props

Name Type Default Description
locale String en set the locale ['de', 'es', en', 'fr', 'ru']
from String null ISO-8601 date of start range
to String null ISO-8601 date of end range
begin String null ISO-8601 date to display since beginning range
allowFrom String null ISO-8601 date to disable selection of all dates before (strict)
allowTo String null ISO-8601 date to disable selection of all dates after (strict)
past Boolean true allow/disallow user to select past dates
future Boolean true allow/disallow user to select future dates
panel String null choose which panel to be open by default
panels Array [ 'range', 'week', 'month', 'quarter', 'year' ] choose which panels to be available
yearsCount Number 2 number of past/future years to display in year panel
showControls Boolean true show bottom controls
theme Object see customize section customize colors
width String 'auto' set component width
resetTitle String 'Reset' change Reset button title
submitTitle String 'Submit' change Submit button title
presets Object see preset section select which presets to be available
rangeDisplayed String 'to' select which range is visible when calendar is displayed

Customize

theme = {
  primary: '#3297DB',
  secondary: '#2D3E50',
  ternary: '#93A0BD',
  border: '#e6e6e6',
  light: '#ffffff',
  dark: '#000000',
  hovers: {
    day: '#CCC',
    range: '#e6e6e6'
  }
}

Presets

available presets : ['custom', 'today', 'yesterday', 'tomorrow', 'last7days', 'next7days', 'last30days', 'next30days', 'last90days', 'next90days', 'last365days', 'next365days', 'forever']

warning: forever need begin props to be set.

Events

This datepicker emit three events, @update, @select and @reset

@update is triggered when submit button is clicked. @select is triggered when a range is selected, can be useful if you don't want to show bottom controls (with showControls = false) @reset is triggered when reset button is clicked

All return an object with the start and end date, plus the active panel

{
  to: '2019-04-23T10:26:00.996Z',
  from: '2018-04-23T10:26:00.996Z'
  panel: 'range'
}

Examples

<template>
  <date-range-picker :from="$route.query.from" :to="$route.query.to" :panel="$route.query.panel" @update="update"/>
</template>

<script>

export default {
  methods: {
    update(values) {
      this.$router.push({ query: Object.assign({}, this.$route.query, {
        to: values.to,
        from: values.from,
        panel: values.panel
      }) })
    }
  }
}
</script>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.