2
2
3
3
![ ] ( https://travis-ci.org/charliekassel/vuejs-datepicker.svg?branch=master ) [ ![ Coverage Status] ( https://coveralls.io/repos/github/charliekassel/vuejs-datepicker/badge.svg?branch=master )] ( https://coveralls.io/github/charliekassel/vuejs-datepicker?branch=master )
4
4
5
- A datepicker Vue component. Compatible with Vue 1.x and Vue 2.x
5
+ A datepicker Vue component. Compatible with Vue 2.x
6
+
7
+ NB. Vue 1.x was supported up to version v0.9.9. If you want to use this component with 1.x you can install with ` npm install vuejs-datepicker@0.9.9 `
6
8
7
9
## Demo
8
10
9
- https://www.webpackbin.com/bins/-KfeGHToc68NnMnmlwJ7
11
+ https://www.webpackbin.com/bins/-KhQbtTSVuU6r8VCrIdC
10
12
11
13
## Install
12
14
@@ -50,32 +52,60 @@ Use `v-model` for two-way binding
50
52
```
51
53
Emits events
52
54
``` html
53
- <datepicker v-on:selected =" doSomethingInParentComponentFunction" v-on:opened =" datepickerOpenedFunction" >
55
+ <datepicker v-on:selected =" doSomethingInParentComponentFunction" v-on:opened =" datepickerOpenedFunction" v-on:closed = " datepickerClosedFunction " >
54
56
```
55
57
Inline always open version
56
58
``` html
57
59
<datepicker :inline =" true" ></datepicker >
58
60
```
59
61
## Available props
60
62
61
- | Prop | Type | Default | Description |
62
- | ---------------| --------------| -------------| -------------------------------------|
63
- | value | Date/String | | Date value of the datepicker |
64
- | name | String | | input name property |
65
- | id | String | | input id |
66
- | format | String | dd MMM yyyy | Date formatting string |
67
- | language | String | en | Translation for days and months |
68
- | disabled | Object | | See below for configuration |
69
- | placeholder | String | | input placeholder text |
70
- | inline | Boolean | | to show the datepicker always open |
71
- | input-class | String | | css class applied to the input el |
72
- | wrapper-class | String | | css class applied to the outer div |
73
- | monday-first | Boolean | false | To start the week on Monday |
74
- | clear-button | Boolean | false | Show an icon for clearing the date |
75
- | disabled-picker | Boolean | false | If true, disable Datepicker on screen |
63
+ | Prop | Type | Default | Description |
64
+ | -----------------------| -----------------| -------------| ------------------------------------------|
65
+ | value | Date\| String | | Date value of the datepicker |
66
+ | name | String | | Input name property |
67
+ | id | String | | Input id |
68
+ | format | String\| Function| dd MMM yyyy | Date formatting string or function |
69
+ | full-month-name | Boolean | false | To show the full month name |
70
+ | language | String | en | Translation for days and months |
71
+ | disabled | Object | | See below for configuration |
72
+ | placeholder | String | | Input placeholder text |
73
+ | inline | Boolean | | To show the datepicker always open |
74
+ | calendar-class | String\| Object | | CSS class applied to the calendar el |
75
+ | input-class | String\| Object | | CSS class applied to the input el |
76
+ | wrapper-class | String\| Object | | CSS class applied to the outer div |
77
+ | monday-first | Boolean | false | To start the week on Monday |
78
+ | clear-button | Boolean | false | Show an icon for clearing the date |
79
+ | clear-button-icon | String | | Use icon for button (ex: fa fa-times) |
80
+ | calendar-button | Boolean | false | Show an icon that that can be clicked |
81
+ | calendar-button-icon | String | | Use icon for button (ex: fa fa-calendar) |
82
+ | bootstrapStyling | Boolean | false | Output bootstrap styling classes |
83
+ | initial-view | String | 'day' | If 'month' or 'year', open on that view |
84
+ | disabled-picker | Boolean | false | If true, disable Datepicker on screen |
85
+ | required | Boolean | false | Sets html required attribute on input |
86
+ | day-view-only | Boolean | false | If true, month and year views won't show |
87
+
88
+ ## Events
89
+
90
+ These events are emitted on actions in the datepicker
91
+
92
+ | Event | Output | Description |
93
+ | -------------------| ------------| --------------------------------------|
94
+ | opened | | The picker is opened |
95
+ | closed | | The picker is closed |
96
+ | selected | Date\| null | A date has been selected |
97
+ | selectedDisabled | Object | A disabled date has been selected |
98
+ | input | Date\| null | Input value has been modified |
99
+ | cleared | | Selected date has been cleared |
100
+ | changedMonth | Object | Month page has been changed |
101
+ | changedYear | Object | Year page has been changed |
102
+ | changedDecade | Object | Decade page has been changed |
103
+
76
104
77
105
## Date formatting
78
106
107
+ #### String formatter
108
+
79
109
NB. This is not very robust at all - use at your own risk! Needs a better implementation.
80
110
81
111
| Token | Desc | Example |
@@ -91,8 +121,24 @@ NB. This is not very robust at all - use at your own risk! Needs a better implem
91
121
| yy | two digit year | 16 |
92
122
| yyyy | four digit year | 2016 |
93
123
124
+ #### Function formatter
94
125
95
- #### Disabled Dates
126
+ Delegates date formatting to provided function.
127
+ Function will be called with date and it has to return formated date as a string.
128
+ This allow us to use moment, date-fns, globalize or any other library to format date.
129
+
130
+ ``` html
131
+ <script >
132
+ methods: {
133
+ customFormatter (date ) {
134
+ return moment (date).format (' MMMM Do YYYY, h:mm:ss a' );
135
+ }
136
+ }
137
+ </script >
138
+ <datepicker :format =" customFormatter" ></datepicker >
139
+ ```
140
+
141
+ ## Disabled Dates
96
142
Dates can disabled in a number of ways.
97
143
98
144
``` html
@@ -106,14 +152,21 @@ var state = {
106
152
new Date (2016 , 9 , 16 ),
107
153
new Date (2016 , 9 , 17 ),
108
154
new Date (2016 , 9 , 18 )
109
- ]
155
+ ],
156
+ ranges: [{ // Disable dates in given ranges (exclusive).
157
+ from: new Date (2016 , 11 , 25 ),
158
+ to: new Date (2016 , 11 , 30 )
159
+ }, {
160
+ from: new Date (2017 , 1 , 12 ),
161
+ to: new Date (2017 , 2 , 25 )
162
+ }]
110
163
}
111
164
}
112
165
</script >
113
166
<datepicker :disabled =" state.disabled" ></datepicker >
114
167
```
115
168
116
- #### Highlight Dates
169
+ ## Highlight Dates
117
170
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.
118
171
Note: Both ` to ` and ` from ` properties are require to define a range of dates to highlight
119
172
@@ -136,7 +189,13 @@ var state = {
136
189
```
137
190
138
191
139
- #### Translations
192
+ ## Translations
193
+
194
+ Contributing guide - please use appropriate code from this [ list] ( http://www.iana.org/assignments/language-subtag-registry/language-subtag-registry ) as the translation property.
195
+
196
+ - Add your language object to the DateLanguages.js file. Please keep in alphabetical order.
197
+ - Add the Language to the available languages in the readme file.
198
+ - Run ` npm run lint ` to make sure your code formatting is in line with the required code style.
140
199
141
200
``` html
142
201
<datepicker language =" es" ></datepicker >
@@ -145,30 +204,42 @@ Available languages
145
204
146
205
| Abbr | Language | |
147
206
| ----------- | ------------------| ----------|
207
+ | ar | Arabic | |
208
+ | bg | Bulgarian | |
209
+ | bs | Bosnian | |
210
+ | ca | Catalan | |
211
+ | cs | Czech | |
212
+ | da | Danish | |
213
+ | de | German | |
214
+ | ee | Estonian | |
215
+ | el | Greek | |
148
216
| en | English | * Default* |
149
217
| es | Spanish | |
218
+ | fa | Persian (Farsi) | |
150
219
| fi | Finnish | |
151
220
| fr | French | |
221
+ | he | Hebrew | |
222
+ | hu | Hungarian | |
152
223
| hr | Croatian | |
224
+ | id | Indonesian | |
225
+ | is | Icelandic | |
153
226
| it | Italian | |
154
- | nl | Dutch | |
155
- | de | German | |
156
- | da | Danish | |
227
+ | ja | Japanese | |
228
+ | ko | Korean | |
229
+ | lt | Lithuanian | |
230
+ | lv | Latvian | |
231
+ | mn | Mongolian | |
157
232
| nb-no | Norwegian Bokmål | |
158
- | cs | Czech | |
233
+ | nl | Dutch | |
234
+ | pl | Polish | |
159
235
| pt-br | Portuguese-Brazil| |
160
236
| ro | Romanian | |
161
- | vi | Vietnamese | |
162
- | zh | Chinese | |
163
- | ja | Japanese | |
164
- | he | Hebrew | |
165
237
| ru | Russian | |
238
+ | sk | Slovak | |
166
239
| sl-si | Slovenian | |
167
240
| sv | Swedish | |
168
241
| th | Thai | |
169
- | bg | Bulgarian | |
170
- | lt | Lithuanian | |
171
- | pl | Polish | |
172
- | ar | Arabic | |
173
- | ee | Estonian | |
174
- | ko | Korean | |
242
+ | tr | Turkish | |
243
+ | uk | Ukrainian | |
244
+ | vi | Vietnamese | |
245
+ | zh | Chinese | |
0 commit comments