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>

vue-mj-daterangepicker's People

Contributors

damienroche avatar devsaider avatar lamaeats avatar piccard21 avatar tusaeff avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

vue-mj-daterangepicker's Issues

Year panel selection with future false breaks

Year panel selection with future false causes browser to toss the long script warning. even if I set the yearsCount to 0. It should simply not show the future years but the right count of years in the past.

the 'currentPanel' is not updated when updating the 'panel' prop

By default i want month and week panel to be available but when you click a certain button i have written code to update the 'panel' prop. But the calander is not updated and when i look what is stored in the 'currentPanel' data variable it is still month and week. Is it possible to update this?

Namespace for element classes

Hello, it's very common now a days to use webpack to filter-out unused classes from css files. Adding a namespace so that all styles related to this component, specially since the DOM isn't present on html files which is what webpack looks over. having a consistent namespace for classes would make it very easy to whistlist classes

Month Range

Is this library support to select the month range?

other locales

Is possible to add other locales like 'es'?

Thanks

[Enhancement] Is it possible click on month or year

Is it possible that if user open week panel and if he wants to change the year or month of opened calendar then on click on month it will open month panel from which they can select month and the functionality of selecting week for that panel remain same.

How to add a new language?

I'd like to add a new language, but I currently have no clue on how to do that.

Can I add a language without having to change the source code?

$attrs is readonly error

I have used the same code as described in the example. (in laravel-vue working project). After istalation i saw this errors in browser console:[Vue warn]: $attrs is readonly and [Vue warn]: $attrs is readonly and [Vue warn]: $listeners is readonly.
Before this error wasnt exists((( Is this problem from datepicker or this depends on some special config of my app? Thanks

presets buttons only work on first DateRangePicker in v-for loop

<div v-for="(Device,key) in Devices" :key="key">
<date-range-picker :ref="Device.Id"  @update="update" :theme="dateRangeTheme"  :from="Device.startDate" :to="Device.endDate" :presets='presets' :panels="['range', 'week', 'month']"/>
</div>

Only the first iteration of the date-range-picker component allows me to change the presets. The others don't respond when I click the input button. Although the Submit and Reset ranges buttons work still. I'm not receiving any errors in my console.

Show the range from begin month

Hi, Damien!
You made a great date range picker!
I have a question about start and finish range date begin.

What's the point?
Today is 09 March. I set the date range from 15 March to 05 April and save it.
Then I refresh the page, after page is loaded I see that current month setted as April (because the end range is next month and i do not see March), it would be better if calendar could begin from Start range - March!

What I see when page is loaded: (End of the range)
image

What i expected to see: (Start of the range)
image

I try to use begin param with a start date, but it does not help.

<date-range-picker 
    ref="rangepicker"
    :begin="'{{ $item->start }}'"
    :from="'{{ $item->start }}'" 
    :to="'{{ $item->finish }}'" 
    :past="false" 
/>

Btw, it would be useful to add a Home icon (or a method to quickly back to the current day, but without it selected)

Present sets!

The ability to select a date range not from today but from an arbitrary date of 3 months? or year? it would be nice to present

The date-range-picker does not even show-up.

First of all thanks to the wonderful plugin. The design looks very neat and superb.

The picker does not even show up in the component I have used.
I have used the same code as described in the example.
There are no errors in the console though.

<date-range-picker begin="2016-02-19T00:00:00.000+01:00" :from="from" :to="to" :panel="panel" :theme="theme"/>

<script>

export default {
  name: "SampleComponent",
  data: () => ({
    to: '2019-04-23T10:26:00.996Z',
    from: '2018-04-23T10:26:00.996Z',
    panel: 'range',
    theme: {
      primary: '#46C3A3',
      secondary: '#2D3E50',
      ternary: '#93A0BD',
      light: '#ffffff',
      border: '#e6e6e6',
      dark: '#000000',
      hovers: {
        day: '#CCC',
        range: '#e6e6e6'
      }
    }
  }),
  methods: {
    update(values) {
      this.$router.push({
        query: Object.assign({}, this.$route.query, {
          to: values.to,
          from: values.from,
          panel: values.panel
        })
      });
    }
  }
};

</script>

The initialisation is done in the application.js

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

Vue.use(DateRangePicker)

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.