0.5.0 • Published 4 years ago

vux-datepicker v0.5.0

Weekly downloads
23
License
-
Repository
github
Last release
4 years ago

Vux Datepicker

A datepicker Vue component. Compatible with Vue 2.x

NB. Vue 2.x was supported up to version v0.1.0. If you want to use this component with Vue 1.x you can install with npm install vux-datepicker@0.5.0

Demo

To view demo examples locally clone the repo and run npm install && npm run serve

alt text alt text

Install

npm install vux-datepicker --save

Usage

import VueDatepicker  from 'vux-datepicker'
import 'font-awesome/css/font-awesome.css'
import 'vux-datepicker/vuex-datepicker.css'
Vue.use(VueDatepicker)

Basic Usage

<template>
  <div id="app">
    <vux-datepicker />
  </div>
</template>

<script>

export default {
  name: 'App',
}
</script>

With more props

<template>
 <vux-date-picker format="DD-MM-YYYY"
                       lang="en"
                       v-model="value"
                       @nextpressed="nextPressed"
                       @prevpressed="prevPressed"
                       @change="onDateChange"
                       color="#aa66cc"
      />
</template>
<script>
export default {
  name: 'App',
  data () {
    return {
      value: ''
    }
  },
  methods: {
    onDateChange (date) {
      console.log(date)
    },
    nextPressed (date) {
      console.log(date)
    },
    prevPressed (date) {
      console.log(date)
    }
  }
}
</script>

Available props

PropTypeDefaultDescription
valueDateDate value of the datepicker
colorStringHex Color Format
formatStringDD MM YYYYDate formatting string or function
langStringenTranslation for days and months
current-dateStringDD MM YYYYSet Date as Default
disabledBooleanfalseIf true, disable Datepicker on screenString'year'If set, higher-level views won't show

Events

These events are emitted on actions in the datepicker

EventOutputDescription
nextpressedNULLThe picker is press next
prevpressedNULLThe picker is press previous
changeDateA date has been changed
inputDateA date has been changed / update

Date formatting

String formatter

NB. This is not very robust at all - use at your own risk! Needs a better implementation.

TokenDescExample
dday1
dd0 prefixed day01
Dabbr dayMon
sudate suffixst, nd, rd
Mmonth number (1 based)1 (for Jan)
MM0 prefixed month01
MMMabbreviated month nameJan
MMMMmonth nameJanuary
yytwo digit year16
yyyyfour digit year2016

Language

Available languages

AbbrLanguage
afAfrikaans
bnBengali
arArabic
bgBulgarian
bsBosnian
caCatalan
csCzech
daDanish
deGerman
eeEstonian
elGreek
enEnglishDefault
esSpanish
faPersian (Farsi)
fiFinnish
foFaroese
frFrench
geGeorgia
glGalician
heHebrew
huHungarian
hrCroatian
idIndonesian
isIcelandic
itItalian
jaJapanese
kkKazakh
koKorean
lbLuxembourgish