1.0.0 • Published 8 years ago

vue-idatepicker v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

Vue-idatepicker

Vue datepicker component. Compatible with Vue 2.x

Requirements

Example

Screenshot

Usage

<template>
  <datepicker :date="date" :required="true" :readonly="false" @datechange="doSomething">
    <i class="my-icon" />
  </datepicker>
</template>

<script>
import Datepicker from 'vue-idatepicker'

export default {
  components: {
    Datepicker
  },
  data () {
    return {
      datepickerOptions: {
        emptyDay: 'Day',
        emptyMonth: 'Month',
        emptyYear: 'Year',
        clear: 'Clear date',
        months: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
        startDate: new Date(1950, 5, 5),
        finishDate: new Date (2050, 5, 5),
        styles: {
          pickerWidth: '90%',
          pickerShadow: '3px 4px 18px 0px rgba(115, 115, 115, 0.6)',
          clearColor: 'blue',
          selectedBackground: 'blue',
          selectedColor: 'white',
          disabledColor: 'gray',
          placeholderColor: 'gray',
          textColor: 'black'
        }
      }
    }
  },
  methods: {
    doSomething (err, date) {
      if (err) {
        // your validation messages
      } else {
        // do something with date
      }
    }
  }
})
</script>

Available props

PropTypeDefaultDescription
dateNumberDate value in seconds elapsed since 1 January 1970 00:00:00 UTC
readonlyBooleanDo not show picker, date only
requiredBooleanfalseTo show asterisk
optionsObjectDatepicker options
options.emptyDayString'day'Translation for day
options.emptyMonthString'month'Translation for month
options.emptyYearString'year'Translation for year
options.clearString'clear'Translation for clear button
options.monthsArrayTranslation for month names
options.startDateDatenew Date(1897, 0, 1)Min date
options.finishDateDatenew Date()Max date
options.stylesObjectStyles for some inner parts
options.styles.pickerWidthString'100%'Width of picker
options.styles.pickerShadowStringnullShadow of picker
options.styles.clearColorString'#358ed7'Color of clear button
options.styles.selectedBackgroundString'#358ed7'Background color of selected item
options.styles.selectedColorString'#fff'Color of selected item
options.styles.disabledColorString'gray'Color of disabled item
options.styles.placeholderColorString'gray'Color of stub elements
options.styles.textColorString'#1b212b'Color of other text

Available events

EventOutputDescription
datechangeObject/null, Date/nullEmits on outside click with two arguments - error and result.

Error Object

error = {
  day: Boolean,
  month: Boolean,
  year: Boolean
}

Slots

There is one default slot, where you can place icons, validations or any additional html

License

The MIT License