1.7.2 • Published 1 year ago

vue-month-picker v1.7.2

Weekly downloads
983
License
MIT
Repository
github
Last release
1 year ago

NPM version NPM downloads

vue-month-picker

A lightweight month picker for Vue 2 with no dependencies.

VueMonthPicker

Install

npm

npm install --save vue-month-picker

yarn

yarn add --save vue-month-picker

Usage

Bundler (Webpack, Rollup)

import Vue from 'vue'
import { MonthPicker } from 'vue-month-picker'
import { MonthPickerInput } from 'vue-month-picker'

Vue.use(MonthPicker)
Vue.use(MonthPickerInput)

Examples

Input

<template>
  <month-picker-input :no-default="true"></month-picker-input>
</template>

<script>
import { MonthPickerInput } from 'vue-month-picker'

export default {
 components: {
  MonthPickerInput
 }
}
</script>

Inline

<template>
 <p>{{ date.month }}</p>
  <month-picker @change="showDate"></month-picker>
</template>

<script>
import { MonthPicker } from 'vue-month-picker'

export default {
 data() {
  return {
   date: {
    from: null,
    to: null,
    month: null,
    year: null
   }
  }
 },
 components: {
  MonthPicker
 },
 methods: {
  showDate (date) {
   this.date = date
  }
 }
}
</script>

Api

The MonthPicker and the MonthPickerInput shares the same props and events.

Props

PropTypeDefaultDescription
langStringenThe language of the months.
monthsArray[]Custom months if language is unsupported.
default-monthIntegerThe default selected month of the month picker. To show the month picker unselected, use the no-default prop.
default-yearIntegerThe default year of the month picker.
no-defaultBooleanfalseShow the month picker unselected.
show-yearBooleanfalseShow the year picker.
editable-yearBooleanfalseYear appears as a input field.
clearableBooleanfalsePossible to clear the chosen month.
variantStringdefaultColor variant. Currently supports default and dark.
year-onlyBooleanfalseHide the months so it acts as a pure year picker
max-dateDatenullSet a max date. Higher dates will be disabled.
min-dateDatenullSet a min date. Lower dates will be disabled.
date-formatString"%n, %Y"Set a display format for non-ranged dates.
input-pre-filledBooleanfalseOnly applies for <month-picker-input>. Input will be pre filled if default-year and default-month is set.

Events

EventReturnsDescription
@changeObjectIndicates that the value has been changed. NB, this will fire when a default value has been selected when the month picker is mounted. Use the input event if you want the value the user has selected.
@change-yearNumberIndicates that the year has been changed. Will emit the year value.
@inputObjectIndicates that the value has been changed by the user.
@clearIndicates that user have cleared the selected value

Date object

Change and input events returns a date object with the following properties:

  • from: Start of the month.
  • to: End of the month.
  • month: Selected month.
  • monthIndex: Selected month index.
  • year: Selected year.
  • rangeFrom: Selected month index range from.
  • rangeTo: Selected month index range to.
  • rangeFromMonth: Selected month from.
  • rangeToMonth: Selected to month.

Translations

Available languages

AbbrLanguage
afAfrikaans
arArabic
csCzech
daDanish
deGerman
elGreek
enEnglish
esSpanish
etEstonian
fiFinnish
frFrench
hiHindi
hrCroatian
huHungarian
idIndonesian
isIcelandic
itItalian
jaJapanese
kmKhmer
koKorean
kuKurdish
ltLithuanian
lvLatvian
msMalay
neNepali
nlDutch
noNorwegian
paPanjabi
plPolish
ptPortuguese
ruRussian
svSwedish
skSlovak
slSlovenian
soSomali
srSerbian
sqAlbanian
thThai
trTurkish
ukUkrainian
urUrdu
viVietnamese
yiYiddish
zhChinese
zuZulu

My language is unsupported

You could add it in the languages.js file and create a pull request. You could also create a issue about the missing language. If you don't want to do that you can use the months property and supply your own array of 12 string values.

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request

Development

Poi was used to develop this component.

poi

License

The MIT License (MIT)

1.7.2

1 year ago

1.7.1

2 years ago

1.7.0

2 years ago

1.6.0

2 years ago

1.5.1

2 years ago

1.5.0

3 years ago

1.4.0

4 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.6

4 years ago

1.2.5

4 years ago

1.2.4

5 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago