Skip to content

Commit

Permalink
Merge pull request #41 from kleinrein/fix/default-month
Browse files Browse the repository at this point in the history
Fix correct pre-fill
  • Loading branch information
kleinrein committed Sep 3, 2020
2 parents 3644ae9 + d679af0 commit 39181f1
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
29 changes: 15 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,21 @@ _The MonthPicker and the MonthPickerInput shares the same props and events._

### Props

| Prop | Type | Default | Description |
| ------------- | ------- | ------- | ------------------------------------------------------------------------------------------------------------- |
| lang | String | en | The language of the months. |
| months | Array | [] | Custom months if language is unsupported. |
| default-month | Integer | | The default selected month of the month picker. To show the month picker unselected, use the no-default prop. |
| default-year | Integer | | The default year of the month picker. |
| no-default | Boolean | false | Show the month picker unselected. |
| show-year | Boolean | false | Show the year picker. |
| editable-year | Boolean | false | Year appears as a input field. |
| clearable | Boolean | false | Possible to clear the chosen month. |
| variant | String | default | Color variant. Currently supports default and dark. |
| year-only | Boolean | false | Hide the months so it acts as a pure year picker |
| max-date | Date | null | Set a max date. Higher dates will be disabled. |
| min-date | Date | null | Set a mih date. Higher dates will be disabled. |
| Prop | Type | Default | Description |
| ---------------- | ------- | ------- | ------------------------------------------------------------------------------------------------------------- |
| lang | String | en | The language of the months. |
| months | Array | [] | Custom months if language is unsupported. |
| default-month | Integer | | The default selected month of the month picker. To show the month picker unselected, use the no-default prop. |
| default-year | Integer | | The default year of the month picker. |
| no-default | Boolean | false | Show the month picker unselected. |
| show-year | Boolean | false | Show the year picker. |
| editable-year | Boolean | false | Year appears as a input field. |
| clearable | Boolean | false | Possible to clear the chosen month. |
| variant | String | default | Color variant. Currently supports default and dark. |
| year-only | Boolean | false | Hide the months so it acts as a pure year picker |
| max-date | Date | null | Set a max date. Higher dates will be disabled. |
| min-date | Date | null | Set a mih date. Higher dates will be disabled. |
| input-pre-filled | Boolean | false | Only applies for `<month-picker-input>`. Input will be pre filled if default-year and default-month is set. |

### Events

Expand Down
4 changes: 3 additions & 1 deletion example/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@
:max-date="maxDate !== null ? new Date(maxDate) : null"
:min-date="minDate !== null ? new Date(minDate) : null"
:year-only="isYearOnly"
:no-default="true"
:default-month="8"
:default-year="2020"
:input-pre-filled="true"
@change="showDate"
/>
</div>
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-month-picker",
"version": "1.3.1",
"version": "1.3.2",
"main": "src/index.js",
"description": "A simple and elegant month picker for Vue",
"scripts": {
Expand All @@ -19,7 +19,10 @@
"email": "rein@live.no",
"url": "https://www.andreasrein.net/"
},
"repository": "github:kleinrein:vue-month-picker",
"repository": {
"type": "git",
"url": "git+https://github.com/kleinrein/vue-month-picker.git"
},
"license": "MIT",
"devDependencies": {
"eslint": "^7.7.0",
Expand Down
2 changes: 1 addition & 1 deletion src/MonthPickerInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default {
},
mounted() {
if (this.inputPreFilled && this.defaultMonth !== null && this.defaultYear !== null) {
this.selectedDate = `${this.monthsByLang[this.defaultMonth]}, ${this.defaultYear}`
this.selectedDate = `${this.monthsByLang[this.defaultMonth - 1]}, ${this.defaultYear}`
}
},
methods: {
Expand Down

0 comments on commit 39181f1

Please sign in to comment.