├── .gitignore
├── LICENSE
├── README.md
├── babel.config.js
├── package-lock.json
├── package.json
├── public
└── index.html
├── screenshot.png
└── src
├── App.vue
├── components
├── DateRangePicker.vue
└── DateRangePickerCalendar.vue
└── main.js
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 | /dist
4 |
5 | # local env files
6 | .env.local
7 | .env.*.local
8 |
9 | # Log files
10 | npm-debug.log*
11 | yarn-debug.log*
12 | yarn-error.log*
13 |
14 | # Editor directories and files
15 | .idea
16 | .vscode
17 | *.suo
18 | *.ntvs*
19 | *.njsproj
20 | *.sln
21 | *.sw*
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Antoine Matyja
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # vue-date-range-picker
2 | A vue component using Bootstrap 4 styles for date range selection
3 |
4 | 
5 |
6 | [Live demo (jsfiddle)](https://jsfiddle.net/Owumaro/qw7mpfr8/)
7 |
8 | ### Features
9 |
10 | - Date range selection
11 | - Compare feature: select a second date range
12 | - No integration: DIY with your favorite vue components or js libraries
13 | - Bootstrap 4 styles (requires Bootstrap 4 CSS)
14 | - Returns Moment.js instances (requires moment.js)
15 |
16 | ## Installation
17 |
18 | ```
19 | npm install --save @owumaro/vue-date-range-picker
20 | ```
21 |
22 | ## Usage
23 |
24 | ### Webpack
25 |
26 | #### JavaScript
27 | ```js
28 | // Import the component
29 | import DateRangePicker from '@owumaro/vue-date-range-picker'
30 |
31 | export default {
32 | // Register the component
33 | components: { DateRangePicker },
34 |
35 | // Create a method for the submit event
36 | methods: {
37 | updateRanges: function(range) {
38 | ...
39 | }
40 | },
41 | ...
42 | }
43 | ```
44 |
45 | #### HTML template
46 | ```html
47 |
48 | ```
49 |
50 | ## API
51 |
52 | ### Events
53 |
54 | As the component needs to transmit multiple values (`startDate`, `endDate`, `compare`, `startDateCompare`, `endDateCompare`), it can not use `v-model`.
55 |
56 | Instead, it triggers 2 events:
57 | - `submit`: when the submit button is clicked; provides an `Object` argument with the 5 attributes mentioned above
58 | - `cancel`: when the cancel button is clicked
59 |
60 | ### Props
61 |
62 | Prop | Type | Default | Description
63 | -----|------|---------|------------
64 | `calendar-count` | `Number` | `2` | Number of calendars to display
65 | `allow-compare` | `Boolean` | `true` | Enable/disable the comparison feature
66 | `ranges` | `Object` | `{ currentMonth: { ... }, lastMonth: { ... } }` | Predefined ranges displayed in select menu(s)
67 | `default-range-select` | `String` | `currentMonth` | Key of the range to select by default
68 | `default-range-select-compare` | `String` | `lastMonth` | Key of the range to select by default (compare)
69 |
70 | ## Development
71 |
72 | ### Project setup
73 | ```
74 | npm install
75 | ```
76 |
77 | ### Compiles and hot-reloads for development
78 | ```
79 | npm run serve
80 | ```
81 |
82 | ### Compiles and minifies
83 | ```
84 | npm run build
85 | ```
86 |
87 | ## Inspiration
88 |
89 | - Google Analytics date range picker
90 | - https://github.com/dangrossman/daterangepicker
91 |
92 | ## TODO
93 | - Tests
94 | - CSS without bootstrap dependency
--------------------------------------------------------------------------------
/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: [
3 | '@vue/app'
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@owumaro/vue-date-range-picker",
3 | "version": "0.1.0",
4 | "description": "A date range picker",
5 | "author": "Owumaro",
6 | "main": "dist/vue-date-range-picker.js",
7 | "scripts": {
8 | "serve": "vue-cli-service serve",
9 | "build": "vue-cli-service build --target lib --name vue-date-range-picker src/components/DateRangePicker.vue",
10 | "lint": "vue-cli-service lint"
11 | },
12 | "dependencies": {
13 | "moment": "^2.23.0"
14 | },
15 | "devDependencies": {
16 | "@fortawesome/fontawesome-svg-core": "^1.2.17",
17 | "@fortawesome/free-solid-svg-icons": "^5.8.1",
18 | "@fortawesome/vue-fontawesome": "^0.1.6",
19 | "@vue/cli-plugin-babel": "^3.5.0",
20 | "@vue/cli-plugin-eslint": "^3.5.0",
21 | "@vue/cli-service": "^3.5.0",
22 | "@vue/eslint-config-standard": "^4.0.0",
23 | "babel-eslint": "^10.0.1",
24 | "bootstrap": "^4.3.1",
25 | "bootstrap-vue": "^2.0.0-rc.15",
26 | "eslint": "^5.8.0",
27 | "eslint-plugin-vue": "^5.0.0",
28 | "jquery": "^3.3.1",
29 | "vue": "^2.6.10",
30 | "vue-template-compiler": "^2.6.10"
31 | },
32 | "repository": {
33 | "type": "git",
34 | "url": "git+https://github.com/Owumaro/vue-date-range-picker.git"
35 | },
36 | "license": "MIT",
37 | "eslintConfig": {
38 | "root": true,
39 | "env": {
40 | "node": true
41 | },
42 | "extends": [
43 | "plugin:vue/essential",
44 | "@vue/standard"
45 | ],
46 | "rules": {
47 | "space-before-function-paren": [
48 | "error",
49 | "never"
50 | ]
51 | },
52 | "parserOptions": {
53 | "parser": "babel-eslint"
54 | }
55 | },
56 | "postcss": {
57 | "plugins": {
58 | "autoprefixer": {}
59 | }
60 | },
61 | "browserslist": [
62 | "> 1%",
63 | "last 2 versions",
64 | "not ie <= 8"
65 | ]
66 | }
67 |
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | vue-date-range-picker
9 |
10 |
11 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Owumaro/vue-date-range-picker/6dee5a43c2f259bb6d6ac140a9a371675445153e/screenshot.png
--------------------------------------------------------------------------------
/src/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
Vue date range picker demo
4 |
5 |
Inline integration
6 |
7 |
8 |
9 |
10 |
Modal integration
11 |
12 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
Popover integration
24 |
25 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
95 |
96 |
103 |
--------------------------------------------------------------------------------
/src/components/DateRangePicker.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
20 |
21 |
22 |
23 |
24 |
25 |
29 |
30 |
31 |
36 |
37 |
38 |
39 |
44 |
45 |
51 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
322 |
323 |
359 |
--------------------------------------------------------------------------------
/src/components/DateRangePickerCalendar.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
8 |
9 |
10 | {{ displayMonth.format('MMMM YYYY') }}
11 |
12 |
13 |
16 |
17 |
18 |
19 |
{{ day.format('ddd') }}
20 |
21 |
22 |
23 |
25 | {{ day.format('D') }}
26 |
27 |
28 |
29 |
30 |
31 |
116 |
117 |
148 |
--------------------------------------------------------------------------------
/src/main.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import App from './App.vue'
3 |
4 | Vue.config.productionTip = false
5 |
6 | new Vue({
7 | render: h => h(App)
8 | }).$mount('#app')
9 |
--------------------------------------------------------------------------------