0.0.14 • Published 7 years ago

simple-vue-datepicker v0.0.14

Weekly downloads
43
License
MIT
Repository
github
Last release
7 years ago

Datepicker

simple-vue-datepicker

Implement a very simple calendar-based datepicker

Derived and stripped down from https://github.com/charliekassel/vuejs-datepicker

A datepicker Vue component. Compatible with Vue 2.x

N.B. - this is in a very raw intermediate state and is not meant for general public consumption at this point. I'm working on another project and will be cleaning this up over time but for now:

  1. it's not tested except for my specific use cases
  2. the documentation is inaccurate - it has not been scrubbed
  3. it's only partially stripped down - there are lots of relics

Install

$ npm install simple-vue-datepicker --save
import Datepicker from 'simple-vue-datepicker';

Vue.component('my-component', {
    components: {
        Datepicker
    }
});

Usage

<datepicker></datepicker>

value prop sets the selectedDate. should be a Date object. defaults to null - no date selected.

<script>
var state = {
    date: new Date(2016, 9,  16)
}
</script>
<datepicker :value="state.date"></datepicker>

Use v-model for two-way binding

<datepicker v-model="state.date"></datepicker>

Emits events

Some of these might still work

<datepicker v-on:selected="doSomethingInParentComponentFunction" v-on:opened="datepickerOpenedFunction" v-on:closed="datepickerClosedFunction">

Inline always open version

<datepicker :inline="true"></datepicker>

Available props

PropTypeDefaultDescription
valueDate/StringDate value of the datepicker
languageStringenTranslation for days and months
disabledObjectSee below for configuration
inlineBooleanTo show the datepicker always open
initialViewDateDate/StringvalueYear/month to initially show on calendar
mondayFirstBooleanfalseShow Monday as first day of week

Events

These events are emitted on actions in the datepicker

EventOutputDescription
openedThe picker is opened
closedThe picker is closed
selectedDate|nullA date has been selected
clearedSelected date has been cleared

Disabled Dates

Dates can disabled in a number of ways.

<script>
var state = {
    disabled: {
        to: new Date(2016, 0, 5), // Disable all dates up to specific date
        from: new Date(2016, 0, 26), // Disable all dates after specific date
        days: [6, 0], // Disable Saturday's and Sunday's
        dates: [ // Disable an array of dates
            new Date(2016, 9, 16),
            new Date(2016, 9, 17),
            new Date(2016, 9, 18)
        ]
    }
}
</script>
<datepicker :disabled="state.disabled"></datepicker>

Highlight Dates

Dates can be highlighted (e.g. for marking an appointment) in a number of ways. Important: You can only highlight dates that aren't disabled. Note: Both to and from properties are required to define a range of dates to highlight

<script>
var state = {
    highlighted: {
        to: new Date(2016, 0, 5), // Highlight all dates up to specific date
        from: new Date(2016, 0, 26), // Highlight all dates after specific date
        days: [6, 0], // Highlight Saturday's and Sunday's
        dates: [ // Highlight an array of dates
            new Date(2016, 9, 16),
            new Date(2016, 9, 17),
            new Date(2016, 9, 18)
        ]
    }
}
</script>
<datepicker :highlighted="state.highlighted"></datepicker>

Translations

Contributing guide - please use appropriate code from this list as the translation property.

<datepicker language="es"></datepicker>

Available languages

AbbrLanguage
arArabic
bgBulgarian
bsBosnian
csCzech
daDanish
deGerman
eeEstonian
enEnglishDefault
esSpanish
fiFinnish
frFrench
heHebrew
huHungarian
hrCroatian
idIndonesian
isIcelandic
itItalian
jaJapanese
koKorean
ltLithuanian
nb-noNorwegian Bokmål
nlDutch
plPolish
pt-brPortuguese-Brazil
roRomanian
ruRussian
skSlovak
sl-siSlovenian
svSwedish
thThai
trTurkish
ukUkrainian
viVietnamese
zhChinese
0.0.14

7 years ago

0.0.13

7 years ago

0.0.12

7 years ago

0.0.11

7 years ago

0.0.10

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago