npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

v2-datepicker

v3.1.1

Published

A simple datepicker component based Vue 2.x

Readme

npm-version license

中文 README

v2-datepicker

A simple datepicker component based Vue 2.x.

Installation

npm:

npm i --save v2-datepicker

or yarn

yarn add  v2-datepicker

Get Started

import Vue from 'vue';
import 'v2-datepicker/lib/index.css';   // v2 need to improt css
import V2Datepicker from 'v2-datepicker';

Vue.use(V2Datepicker)
// basic
<v2-datepicker v-model="val"></v2-datepicker>
<v2-datepicker-range v-model="val2"></v2-datepicker-range>

//setting
<v2-datepicker-range v-model="val" lang="en" format="yyyy-MM-DD" :picker-options="pickerOptions"></v2-datepicker-range>
<v2-datepicker v-model="val2" format="yyyy-MM-DD" :picker-options="pickerOptions2"></v2-datepicker>

export default {
    data () {
        return {
            pickerOptions: {
                    shortcuts: [{
                        text: 'Latest Week',
                        onClick (picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
                            picker.$emit('pick', [start, end]);
                        }
                    }, {
                        text: 'Latest Month',
                        onClick (picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
                            picker.$emit('pick', [start, end]);
                        }
                    }, {
                        text: 'Latest Three Month',
                        onClick (picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
                            picker.$emit('pick', [start, end]);
                        }
                    }]
                },
            pickerOptions2: {
                shortcuts: [{
                    text: 'Today',
                    onClick (picker) {
                        picker.$emit('pick', new Date());
                    }
                }, {
                    text: 'Yesterday',
                    onClick (picker) {
                        const date = new Date();
                        date.setTime(date.getTime() - 3600 * 1000 * 24);
                        picker.$emit('pick', date);
                    }
                }, {
                    text: 'A week ago',
                    onClick (picker) {
                        const date = new Date();
                        date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
                        picker.$emit('pick', date);
                    }
                }]
            }
        }
    }
}

More demo to visit here.

On Demand Import

This feature just apply to v2

You need to install babel-plugin-on-demand-import:

npm i babel-plugin-on-demand-import -D

Then add it to your .babelrc:

// v2
{
    // ...
    "plugins": [
        ["on-demand-import" {
            "libraryName": "v2-datepicker"
        }]
    ]
}

// v3
{
    // ...
    "plugins": [
        ["on-demand-import" {
            "libraryName": "v2-datepicker",
            "libraryName": "lib/components"
        }]
    ]
}
// Only import DatePicker component
import { DatePicker } from 'v2-datepicker';
Vue.use(DatePicker);

<v2-datepicker v-model="val"></v2-datepicker>

// Only import DatePickerRange component
import { DatePickerRange } from 'v2-datepicker';
Vue.use(DatePickerRange);

<v2-datepicker-range v-model="val2"></v2-datepicker-range>

Custom Locales

The components native supports only two languages: cn(chinese) and en(english) since v3.1.0, if you want to custom locale, do it by customLocals prop:

<template>
  <v2-datepicker format="MM/DD/YYYY" :lang="lang" :customLocals="locals" v-model="date"></v2-datepicker>
</template>

// js
import locals from 'path/to/your/locals'
export default {
  data () {
    return {
      lang: 'it',
      locales
    }
  }
}

// locales.js
export default {
  'it': {
    'months': {
        'original': ['Gennaio', 'Febbraio', 'Marzo', 'Aprile', 'Maggio', 'Giugno', 'Luglio', 'Agosto', 'Settembre', 'Ottobre', 'Novembre', 'Dicembre'],
        'abbr': ['Gen', 'Feb', 'Mar', 'Apr', 'Mag', 'Giu', 'Lug', 'Ago', 'Set', 'Ott', 'Nov', 'Dic']
    },
    'days': ['Dom', 'Lun', 'Mar', 'Mer', 'Gio', 'Ven', 'Sab']
  },
  'lang-key': {
     'months': {
        'original': ['value1', 'value2', '...'],
        'abbr': ['value1', 'value2', '...']
     },
     'days': ['value1', 'value2', '...']
  }
}

Available Props

The v2-datepicker component

| Attribute | Type | Accepted Values | Default | Description | | :--: | :--: | :--: | :--: | :--: | | value | Date | anything accepted by new Date() | - | default date of the date-picker | | lang | String | cn(chinese)/en(english) | cn | set local language of the date-picker | | customLocals | Object | - | {} | custom locale | | format | String | year yyyy/YYYY, month MM, day dd | yyyy/MM/dd | format of the displayed value in the span box | | placeholder | String | - | 选择日期/Choosing date... | placeholder text | | disabled | Boolean | - | false | disabled date-picker | | picker-options | Object | - | {} | additional options, check the table below | | render-row | Number | 6/7 | 7 | render rows of datepicker | | default-value | Date | anything accepted by new Date() | - | default date of the calendar |

The v2-daterange-picker component

| Attribute | Type | Accepted Values | Default | Description | | :--: | :--: | :--: | :--: | :--: | | value | Array | anything accepted by new Date() | - | default date of the daterange-picker | | lang | String | cn(chinese)/en(english) | cn | set local language of the daterange-picker | | customLocals | Object | - | {} | custom locale | | format | String | year yyyy/YYYY, month MM, day dd | yyyy/MM/dd | format of the displayed value in the span box | | placeholder | String | - | 开始时间-结束时间/Choosing date range... | placeholder text | | disabled | Boolean | - | false | disabled daterange-picker | | range-separator | String | - | '-' | range separator| | unlink-panels | Boolean | - | false | unlink two date-panels in range-picker| | picker-options | Object | - | {} | additional options, check the table below | | default-value | Date | anything accepted by new Date() | - | default date of the calendar |

Picker Options

| Attribute | Type | Accepted Values | Default | Description | | :--: | :--: | :--: | :--: | :--: | | shortcuts | Object[] | - | - | a { text, onClick } object array to set shortcut options, check the table below | | disabledDate | Function | - | - | a function determining if a date is disabled with that date as its parameter. Should return a Boolean |

shortcuts

| Attribute | Type | Accepted Values | Default | Description | | :--: | :--: | :--: | :--: | :--: | | text | String | - | - | title of the shortcut | | onClick | Function | - | - | callback function, triggers when the shortcut is clicked |

Event

| Event Name | Description | Parameters | | :--: | :--: | :--: | | change | triggers when the selected value changes | component's binding value |

Development

git clone [email protected]:dwqs/v2-datepicker.git

cd v2-datepicker

npm i

npm start

LICENSE

MIT