Skip to content

Commit 9a1b973

Browse files
authored
Merge pull request #1 from charliekassel/master
Update local branch
2 parents dde6b26 + 41b786a commit 9a1b973

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+7914
-1326
lines changed

.babelrc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
{
2-
"presets": ["es2015", "stage-2"],
2+
"presets": [
3+
["env", { "modules": false }],
4+
"stage-2"
5+
],
36
"plugins": ["transform-runtime"],
4-
"comments": false
7+
"comments": false,
8+
"env": {
9+
"test": {
10+
"presets": ["env", "stage-2"],
11+
"plugins": [ "istanbul" ]
12+
}
13+
}
514
}

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true

.eslintrc.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// http://eslint.org/docs/user-guide/configuring
2+
13
module.exports = {
24
root: true,
35
parser: 'babel-eslint',

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ node_modules
33
npm-debug.log
44
.vscode
55
.coveralls.yml
6-
test/coverage/*
76
dist/build.js
8-
dist/build.js.map
7+
dist/build.js.map
8+
test/unit/coverage
9+
yarn-debug.log*
10+
yarn-error.log*

.postcssrc.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// https://github.com/michael-ciniawsky/postcss-load-config
2+
3+
module.exports = {
4+
"plugins": {
5+
// to edit target browsers: use "browserlist" field in package.json
6+
"autoprefixer": {}
7+
}
8+
}

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
language: node_js
22
node_js:
3+
- "7"
34
- "6"
4-
- "5"
5-
after_script: "cat ./test/coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js"
5+
after_script: "cat ./test/unit/coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js"

CONTRIBUTING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Contributions are welcome :)
2+
3+
Please add tests and run the linter.

README.md

Lines changed: 107 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
![](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)
44

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`
68

79
## Demo
810

9-
https://www.webpackbin.com/bins/-KfeGHToc68NnMnmlwJ7
11+
https://www.webpackbin.com/bins/-KhQbtTSVuU6r8VCrIdC
1012

1113
## Install
1214

@@ -50,32 +52,60 @@ Use `v-model` for two-way binding
5052
```
5153
Emits events
5254
``` 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">
5456
```
5557
Inline always open version
5658
``` html
5759
<datepicker :inline="true"></datepicker>
5860
```
5961
## Available props
6062

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+
76104

77105
## Date formatting
78106

107+
#### String formatter
108+
79109
NB. This is not very robust at all - use at your own risk! Needs a better implementation.
80110

81111
| Token | Desc | Example |
@@ -91,8 +121,24 @@ NB. This is not very robust at all - use at your own risk! Needs a better implem
91121
| yy | two digit year | 16 |
92122
| yyyy | four digit year | 2016 |
93123

124+
#### Function formatter
94125

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
96142
Dates can disabled in a number of ways.
97143

98144
``` html
@@ -106,14 +152,21 @@ var state = {
106152
new Date(2016, 9, 16),
107153
new Date(2016, 9, 17),
108154
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+
}]
110163
}
111164
}
112165
</script>
113166
<datepicker :disabled="state.disabled"></datepicker>
114167
```
115168

116-
#### Highlight Dates
169+
## Highlight Dates
117170
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.
118171
Note: Both `to` and `from` properties are require to define a range of dates to highlight
119172

@@ -136,7 +189,13 @@ var state = {
136189
```
137190

138191

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.
140199

141200
``` html
142201
<datepicker language="es"></datepicker>
@@ -145,30 +204,42 @@ Available languages
145204

146205
| Abbr | Language | |
147206
| ----------- |------------------|----------|
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 | |
148216
| en | English | *Default*|
149217
| es | Spanish | |
218+
| fa | Persian (Farsi) | |
150219
| fi | Finnish | |
151220
| fr | French | |
221+
| he | Hebrew | |
222+
| hu | Hungarian | |
152223
| hr | Croatian | |
224+
| id | Indonesian | |
225+
| is | Icelandic | |
153226
| 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 | |
157232
| nb-no | Norwegian Bokmål | |
158-
| cs | Czech | |
233+
| nl | Dutch | |
234+
| pl | Polish | |
159235
| pt-br | Portuguese-Brazil| |
160236
| ro | Romanian | |
161-
| vi | Vietnamese | |
162-
| zh | Chinese | |
163-
| ja | Japanese | |
164-
| he | Hebrew | |
165237
| ru | Russian | |
238+
| sk | Slovak | |
166239
| sl-si | Slovenian | |
167240
| sv | Swedish | |
168241
| 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 | |

build/build.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
require('./check-versions')()
2+
3+
process.env.NODE_ENV = 'production'
4+
5+
var ora = require('ora')
6+
var rm = require('rimraf')
7+
var path = require('path')
8+
var chalk = require('chalk')
9+
var webpack = require('webpack')
10+
var config = require('../config')
11+
var webpackConfig = require('./webpack.prod.conf')
12+
13+
var spinner = ora('building for production...')
14+
spinner.start()
15+
16+
rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
17+
if (err) throw err
18+
webpack(webpackConfig, function (err, stats) {
19+
spinner.stop()
20+
if (err) throw err
21+
process.stdout.write(stats.toString({
22+
colors: true,
23+
modules: false,
24+
children: false,
25+
chunks: false,
26+
chunkModules: false
27+
}) + '\n\n')
28+
29+
console.log(chalk.cyan(' Build complete.\n'))
30+
console.log(chalk.yellow(
31+
' Tip: built files are meant to be served over an HTTP server.\n' +
32+
' Opening index.html over file:// won\'t work.\n'
33+
))
34+
})
35+
})

build/check-versions.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
var chalk = require('chalk')
2+
var semver = require('semver')
3+
var packageConfig = require('../package.json')
4+
var shell = require('shelljs')
5+
function exec (cmd) {
6+
return require('child_process').execSync(cmd).toString().trim()
7+
}
8+
9+
var versionRequirements = [
10+
{
11+
name: 'node',
12+
currentVersion: semver.clean(process.version),
13+
versionRequirement: packageConfig.engines.node
14+
},
15+
]
16+
17+
if (shell.which('npm')) {
18+
versionRequirements.push({
19+
name: 'npm',
20+
currentVersion: exec('npm --version'),
21+
versionRequirement: packageConfig.engines.npm
22+
})
23+
}
24+
25+
module.exports = function () {
26+
var warnings = []
27+
for (var i = 0; i < versionRequirements.length; i++) {
28+
var mod = versionRequirements[i]
29+
if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
30+
warnings.push(mod.name + ': ' +
31+
chalk.red(mod.currentVersion) + ' should be ' +
32+
chalk.green(mod.versionRequirement)
33+
)
34+
}
35+
}
36+
37+
if (warnings.length) {
38+
console.log('')
39+
console.log(chalk.yellow('To use this template, you must update following to modules:'))
40+
console.log()
41+
for (var i = 0; i < warnings.length; i++) {
42+
var warning = warnings[i]
43+
console.log(' ' + warning)
44+
}
45+
console.log()
46+
process.exit(1)
47+
}
48+
}

0 commit comments

Comments
 (0)