├── .babelrc ├── .eslintignore ├── .eslintrc.json ├── .gitignore ├── README.md ├── build ├── webpack.dev.config.js └── webpack.prod.config.js ├── examples ├── App.vue ├── index.html └── main.js ├── lib └── .gitkeep ├── package.json └── src ├── Datepicker.vue ├── assets └── images │ ├── arrow-left-white.svg │ ├── arrow-right-white.svg │ └── light-arrow-down.svg └── index.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "es2015", "es2017" 4 | ], 5 | "plugins": [ 6 | "transform-es2015-modules-commonjs" 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules/* 2 | build/* -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "parser": "babel-eslint", 3 | "env": { 4 | "browser": true, 5 | "commonjs": true, 6 | "es6": true, 7 | "node": true 8 | }, 9 | "parserOptions": { 10 | "ecmaVersion": 8, 11 | "sourceType": "module" 12 | }, 13 | "rules": { 14 | "no-const-assign": "warn", 15 | "no-this-before-super": "warn", 16 | "no-undef": "warn", 17 | "no-unreachable": "warn", 18 | "no-unused-vars": "warn", 19 | "constructor-super": "warn", 20 | "valid-typeof": "warn", 21 | "semi": [ 22 | "warn", 23 | "never" 24 | ], 25 | "quotes": [ 26 | "warn", 27 | "single" 28 | ], 29 | "arrow-parens": 0, 30 | "generator-star-spacing": 0, 31 | "space-before-function-paren": 0 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | dist 4 | lib/* 5 | !lib/.gitkeep 6 | .vscode 7 | npm-debug.log 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vue-datepicker 2 | 3 | This is yet another vue datepicker component. 4 | 5 | ## Install 6 | 7 | Use npm to download code: 8 | 9 | ``` 10 | npm install hsy-vue-datepicker -S 11 | ``` 12 | 13 | then import it into your project, add below code into your `main.js`: 14 | 15 | ```js 16 | import Datepicker from 'hsy-vue-datepicker' 17 | 18 | Vue.use(Datepicker) 19 | ``` 20 | 21 | ## Usage 22 | 23 | It supports single date mode, you just need to bind your date with `v-model`: 24 | 25 | ```html 26 | 31 | 32 | 41 | ``` 42 | 43 | also, there is a date-range mode, you just need to specify the mode with prop `mode`: 44 | 45 | ```html 46 | 51 | 52 | 61 | ``` 62 | 63 | it contains a hot-realod example for your preview or dev, run it follow: 64 | 65 | ```sh 66 | $ cd your-clone-dir 67 | $ npm install 68 | $ npm run dev 69 | ``` 70 | 71 | ## Props 72 | 73 | | Prop | Description | Type | Accepted Values | Default | 74 | |:----------------|:-------------------------------------------------|:-----------------------------------|:----------------|:---------| 75 | | value | dates to be manipulated | String/Moment/Date/Array of former | -- | moment() | 76 | | mode | mode of picker | String | date/daterange | date | 77 | | cssClass | css class to be appended to component $el | String | -- | -- | 78 | | placeholder | placeholder | String | -- | -- | 79 | | cbDate0Error | callback for error input from user of begin date | -- | -- | | 80 | | cbDate1Error | callback for error input from user of end date | -- | -- | | 81 | | cbCancelClicked | callback for cancel button clicked | -- | -- | -- | 82 | 83 | ## Demo 84 | 85 | [Demo](http://vue-demo.hsiaosiyuan.com/#/datepicker) 86 | 87 | ## Screenshot 88 | 89 | 90 | -------------------------------------------------------------------------------- /build/webpack.dev.config.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | var HtmlWebpackPlugin = require('html-webpack-plugin') 3 | 4 | module.exports = { 5 | entry: './examples/main.js', 6 | resolve: { 7 | extensions: ['.js', '.vue', '.json'], 8 | alias: { 9 | main: path.resolve(__dirname, '../src') 10 | }, 11 | }, 12 | output: { 13 | path: path.resolve(__dirname, '../dist/dev'), 14 | publicPath: '/', 15 | filename: 'index.js' 16 | }, 17 | devServer: { 18 | contentBase: path.resolve(__dirname, '../dist/dev'), 19 | compress: false, 20 | port: 8080 21 | }, 22 | plugins: [ 23 | new HtmlWebpackPlugin({ 24 | filename: path.resolve(__dirname, '../dist/dev/index.html'), 25 | template: 'examples/index.html', 26 | inject: true 27 | }) 28 | ], 29 | module: { 30 | loaders: [{ 31 | test: /\.vue$/, 32 | loader: 'vue-loader' 33 | }, { 34 | test: /\.js$/, 35 | loaders: ['babel-loader', 'eslint-loader'], 36 | exclude: /node_modules/ 37 | }, { 38 | test: /\.css$/, 39 | loader: 'style-loader!css-loader' 40 | }, { 41 | test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, 42 | loader: 'url-loader', 43 | query: { 44 | limit: 10000, 45 | name: 'img/[name].[hash:7].[ext]' 46 | } 47 | }, { 48 | test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, 49 | loader: 'url-loader', 50 | query: { 51 | limit: 10000, 52 | name: 'fonts/[name].[hash:7].[ext]' 53 | } 54 | }] 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /build/webpack.prod.config.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | 3 | module.exports = { 4 | entry: './src/index.js', 5 | devtool: 'source-map', 6 | resolve: { 7 | extensions: ['.js', '.vue', '.json'] 8 | }, 9 | output: { 10 | path: path.resolve(__dirname, '../lib'), 11 | filename: 'index.js', 12 | libraryTarget: 'commonjs2' 13 | }, 14 | module: { 15 | loaders: [{ 16 | test: /\.vue$/, 17 | loader: 'vue-loader' 18 | }, { 19 | test: /\.js$/, 20 | loaders: ['babel-loader', 'eslint-loader'], 21 | exclude: /node_modules/ 22 | }, { 23 | test: /\.css$/, 24 | loader: 'style-loader!css-loader' 25 | }, { 26 | test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, 27 | loader: 'url-loader', 28 | query: { 29 | limit: 10000, 30 | name: 'img/[name].[hash:7].[ext]' 31 | } 32 | }, { 33 | test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, 34 | loader: 'url-loader', 35 | query: { 36 | limit: 10000, 37 | name: 'fonts/[name].[hash:7].[ext]' 38 | } 39 | }] 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /examples/App.vue: -------------------------------------------------------------------------------- 1 | 11 | 12 | 38 | 39 | 45 | -------------------------------------------------------------------------------- /examples/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | test 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /examples/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import App from './App' 3 | import Datepicker from 'main' 4 | 5 | Vue.use(Datepicker) 6 | 7 | new Vue({ 8 | el: '#app', 9 | render: h => h(App) 10 | }) 11 | -------------------------------------------------------------------------------- /lib/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vue-garden/vue-datepicker/fe9d0095f2cf0eb9cd39190e0b037ac6c383141b/lib/.gitkeep -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hsy-vue-datepicker", 3 | "version": "0.1.3", 4 | "description": "vue datepicker component", 5 | "author": "hsiaosiyuan0 ", 6 | "main": "lib/index.js", 7 | "scripts": { 8 | "dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot --config ./build/webpack.dev.config.js", 9 | "build": "cross-env NODE_ENV=production webpack --progress --hide-modules --config ./build/webpack.prod.config.js", 10 | "prepublish": "npm run build" 11 | }, 12 | "dependencies": { 13 | "moment": "^2.17.1" 14 | }, 15 | "devDependencies": { 16 | "babel-core": "^6.21.0", 17 | "babel-eslint": "^6.1.2", 18 | "babel-loader": "^6.2.10", 19 | "babel-plugin-transform-es2015-modules-commonjs": "^6.18.0", 20 | "babel-preset-es2015": "^6.22.0", 21 | "babel-preset-es2017": "^6.16.0", 22 | "cross-env": "^3.1.4", 23 | "css-loader": "^0.23.0", 24 | "eslint": "^3.12.2", 25 | "eslint-loader": "^1.6.1", 26 | "file-loader": "^0.8.4", 27 | "html-webpack-plugin": "^2.28.0", 28 | "json-loader": "^0.5.4", 29 | "style-loader": "^0.13.1", 30 | "url-loader": "^0.5.7", 31 | "vue": "^2.1.10", 32 | "vue-loader": "^10.3.0", 33 | "vue-style-loader": "^2.0.0", 34 | "vue-template-compiler": "^2.1.10", 35 | "webpack": "^2.2.1", 36 | "webpack-dev-server": "^2.3.0" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Datepicker.vue: -------------------------------------------------------------------------------- 1 | 48 | 49 | 488 | 489 | 731 | -------------------------------------------------------------------------------- /src/assets/images/arrow-left-white.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/assets/images/arrow-right-white.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/assets/images/light-arrow-down.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import Datepicker from './Datepicker' 2 | 3 | const install = (Vue) => { 4 | Vue.component(Datepicker.name, Datepicker) 5 | } 6 | 7 | export default { 8 | version: '0.0.3', 9 | install 10 | } 11 | --------------------------------------------------------------------------------