Giter Club home page Giter Club logo

vue-datepicker's Introduction

vue-datepicker [DEPRECATED]

calendar and datepicker component with material design for Vue.js

Demo

The demo page is HERE.

Screenshot

Requirements

Installation

npm

$ npm install vue-datepicker

Usage

<script>
// for Vue 1.0
import myDatepicker from 'vue-datepicker/vue-datepicker-1.vue'

// for Vue 2.0
import myDatepicker from 'vue-datepicker'

export default {
  data () {
    return {
      // for Vue 1.0
      starttime: '',
      endtime: '2016-01-19',
      testTime: '',
      multiTime: '',

      // for Vue 2.0
      startTime: {
        time: ''
      },
      endtime: {
        time: ''
      }

      option: {
        type: 'day',
        week: ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'],
        month: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
        format: 'YYYY-MM-DD',
        placeholder: 'when?',
        inputStyle: {
          'display': 'inline-block',
          'padding': '6px',
          'line-height': '22px',
          'font-size': '16px',
          'border': '2px solid #fff',
          'box-shadow': '0 1px 3px 0 rgba(0, 0, 0, 0.2)',
          'border-radius': '2px',
          'color': '#5F5F5F'
        },
        color: {
          header: '#ccc',
          headerText: '#f00'
        },
        buttons: {
          ok: 'Ok',
          cancel: 'Cancel'
        },
        overlayOpacity: 0.5, // 0.5 as default
        dismissible: true // as true as default
      },
      timeoption: {
        type: 'min',
        week: ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'],
        month: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
        format: 'YYYY-MM-DD HH:mm'
      },
      multiOption: {
        type: 'multi-day',
        week: ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'],
        month: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
        format:"YYYY-MM-DD HH:mm"
      },
      limit: [{
        type: 'weekday',
        available: [1, 2, 3, 4, 5]
      },
      {
        type: 'fromto',
        from: '2016-02-01',
        to: '2016-02-20'
      }]
    }
  },
  components: {
    'date-picker': myDatepicker
  }
}
</script>
<template>
  <div class="card">

    <!-- for Vue 1.0 -->
    <div class="row">
      <span>Departure Date:</span>
      <date-picker :time.sync="starttime" :option="option" :limit="limit"></date-picker>
    </div>

    <!-- for Vue 2.0 -->
    <div class="row">
      <span>Departure Date:</span>
      <date-picker :date="startTime" :option="option" :limit="limit"></date-picker>
    </div>

  </div>
</template>

API

  • Option
  • type
  type: 'day' // 'min', 'multi-day'

  • format
format: 'YYYY-MM-DD HH:mm'
  • placeholder
placeholder: 'when?'
  • week
 week: ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su']
  • month
  month: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August','September', 'October', 'November', 'December']
  • wrapperClass
wrapperClass: ''
  • inputClass
inputClass: ''
  • inputStyle
inputStyle: {
  'display': 'inline-block',
  'padding': '6px',
  'line-height': '22px',
  'font-size': '16px',
  'border': '2px solid #fff',
  'box-shadow': '0 1px 3px 0 rgba(0, 0, 0, 0.2)',
  'border-radius': '2px',
  'color': '#5F5F5F'
}
  • color
  color: {
    header: '#ccc',
    headerText: '#f00'
  }
  • buttons
buttons: {
  ok: 'OK',
  cancel: 'Cancel'
}
  • animate
  overlayOpacity: 0.5, // 0.5 as default
  dismissible: true // as true as default
  • limit
  • from sometime to sometime(when from/to is empty, days before/after end/start time will be available)
limit: {
  type:'fromto',
  from:'2016-01-10',
  to:'2016-01-30'
}
  • weekdays
limit:{
  type: 'weekday',
  available: [1, 2, 3, 4, 5] 
}

prop

  • Vue 1.0
time: '' // string
<date-picker :time.sync="time" :limit="limit"></date-picker>
  • Vue 2.0
date: {
  time: '' // string
}
<date-picker :date="date" :limit="limit"></date-picker>

License

The MIT License

vue-datepicker's People

Contributors

asvae avatar beenotung avatar biangbiang avatar dnxbf321 avatar elijan avatar georgthomassen avatar hilongjw avatar ish- avatar jwahdatehagh avatar lukaszb avatar ozee31 avatar pavel-mironchik avatar sopamo avatar stephaneleroy avatar trollepierre 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  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  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

vue-datepicker's Issues

引入该插件后项目体积剧增

我的项目本来js文件打包后只有2MB多,引入本插件后就变成4.5MB了,在node_module文件里查看,发现项目本身不大,但是引入的lodash库文件却大的吓人:2MB,我去lodash官方看了,其实下载lodash也就22kb,但不知为何到了npm中就变得如此巨大了,望优化一下,非常喜欢这个插件。

How to catch "change" event from a parent component?

Vue version: 1.0.28

If I'm using it as a child component, how can I grab the chosen date? I did

<date-picker v-on:change="setFromDueDate($event)" :time.sync="''" :option="datepicker.option"></date-picker>

But if I log the event, it appears as undefined.

methods: {
    setFromDueDate: function (event) {
        console.log(event);
    }
}

I see that inside the component it's using $emit to trigger events, but shouldn't it be using $dispatch instead, so that the parent can grab the event?

Limit weekday, following month is selectable

Hi. Thank you for the great date picker!

Sorry, I am a non-Chinese speaker. There is an issue with the limit on weekdays where you see the following month.

If I limit the weekday like:

{
      type: 'weekday',
      available: [1, 2, 3, 4, 5]
}

I get the correct result for the current month only.

screen shot 2016-08-05 at 12 19 26

Notice that this month is un selectable. In this example, we can see the start of September. This IS selectable and it shouldn't be.

I hope that make sense. If this is a different issue, let me know and I will move this to another issue.

Cheers - Love the datepicker - Thank you!!

Initial Time Not Formatted

I'm using this to display the D.O.B of a user and I'm getting the data from the database in 2016-08-22T12:39:29+0300 such a format. During the initial display, before interacting with the date picker, the date is displayed as above instead of 2016-08-22 (YYYY-MM-DD). This can be easily rectified by adding a coerce to the time property

time: { type: String, required: true, coerce(val) { if (val) { return _moment(val).format('YYYY-MM-DD') } return${val} }, }

I'll create a PR with this

How to set color on date

I want to set color for dates or date range when initialize the calendar (ex: 1-1-2017 is red, 21-1-2017 is blue). Could you please guide me how to config or implement them ??

Date range picker

This is a great package. Hope you have the option date range picker. Thanks

z-index too low

The z-index for the datapicker is way too low, it appears behind most of my page elements.

About hours and minute

Hi, I just downloaded the component and it works great, however I have some things to say :

The minutes should be between 00 and 59 instead of being between 01 and 60 :It cause to have an invalid date with moment if you set the minutes to 60

I would also suggest strongly to do the same for the hours : hours are from 00 to 23, so it doesn't cause confusion and we are getting closer to ISO 8601 https://en.wikipedia.org/wiki/ISO_8601

Thanks !

Remove the default style

I don't think you should have default styles for the input element in the component. It's great that we are able to override the styles with the component config (and you already have the styles in the documentation). But when I'm using the component with any other library the date fields will look different which is definitely not what I want.

If you want, I can create a pull request.

Color customisation

It would be nice to have easy custom color on the component.

The problem I see at the moment is that you are using !important flags in your css that can't be overriden.

Either you can find a way to remove them, OR we can pass props to the component for the colors.

Support for days of previous/next month

It would be nice to support the remaining days of a week with the last and first days of the next and previous month. I looked at the source, and I'm not sure how I would implement it.

Option to set input field to read-only

I want to prevent the user from freely typing whatever he wants, so that only viable value of this input is the date he selected.

I don't see this option in the docs, and it would be very helpful.

Can there be better design for mobile

Hi,

Thanks for your work, It is awesome.

One request, can there be better design for mobile, currently it takes whole width in the mobile and you can not see anything else on the screen once this is open, like this:

screen shot 2017-01-27 at 3 38 21 pm

On desktop also it comes in the center of the screen, should be just coming below the date field.

Customize 'class' of input

Nice Component.

While I being try to customize the style of the default <input/>, using 'inputStyle' seem a little bit complicated.

A prop of setting 'class' of the <input/> will be very handy for customize .

Will you accept a PR of it?

How can I use other format?

How can I use the other format? Such as: 'MM/DD/YYYY', I tried to change it in the config but no luck.

Thanks

Can show total datapicker section at once

Hi, thanks for your work and i met this problem.
Error imge
Like the picture show, i can't control the timepicker show totally at once. At first time, it only show the left part of timepicker, then wait for little time you can see all the time picker. I read your code and cannot find the problem. Which i can't understand is this situation not showed at sure time. Did you met this problem also?

throw error: this.selectedDays.$remove is not a function

Used with Vue 2.0, when multi-day select one day and unselect it

throw erro : this.selectedDays.$remove is not a function in vue-datepicker.vue at

 if (obj.checked === true) {
          obj.checked = false;
          this.selectedDays.$remove(ctime);
        }

I think because in Vue 2.0 The $remove() method has been deleted

I do't know why the demo is work fine.

finally I modify the code to

        if (obj.checked === true) {
          obj.checked = false;
          // this.selectedDays.$remove(ctime);
          this.selectedDays.splice(this.selectedDays.indexOf(ctime), 1)
        }

it work fine

multi-day invalid date after initial selection

Hi,

Using Vue2 I have this:

option: {
type: 'multi-day',
week: ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'],
month: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
format: 'DD/MM/YYYY',
placeholder: 'Due from...',
buttons: {
ok: 'Ok',
cancel: 'Cancel'
}
}

When I select the date, I can select 2 dates with no problem BUT the format is ignored and after the initial selection, if I select the date box again I get an Invalid Date message where the year / month should be. Clicking the arrow takes me to the correct month but if I try and select a different range, it adds the dates to the array and doesn't clear the existing ones.

Cannot find origin source code

Your .es6.vue is not really a es6-like code.
And there are also babel compiled lines in it .

'use strict';
Object.defineProperty(exports, "__esModule", {
  value: true
});
var _moment = require('moment');
var _moment2 = _interopRequireDefault(_moment);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

Perhaps your pushed the wrong file ?

设置limit Bug

配置如下:

limit: [{
  type: 'weekday',
  available: [1, 2, 3, 4, 5]
}, {
  type: 'fromto',
  from: '2016-05-15'
}]

我默认不填to就是允许>= from的时间,有以下问题:

  • 只能选择2016-05-15之后一周的时间

to设置为2017-05-15后,只有当月是正确的,其他月份比如4月、6月的日期可点

How to make the limit dynamically?

I have a demand: a startTime && a endTime ,when startTime picked the endTime should not > the startTime, off course if endTime picked the startTime should not < the endTime , How Should I do?.....when I declare @change function to return false the value in the input also changed....

Input customisation

It would be pretty nice to add some customisation to the input :

  • add a class
  • change the placeholder
  • add a label

That would lead to better flexibility :)

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.