|
| 1 | +# VueJS Functional Calendar (Date Picker, Date Range) |
| 2 | + |
| 3 | +[](https://travis-ci.org/ManukMinasyan/vue-functional-calendar) |
| 4 | +[](https://www.npmjs.com/package/vue-functional-calendar) |
| 5 | +[](https://www.npmjs.com/package/vue-functional-calendar) |
| 6 | + |
| 7 | +## Demo |
| 8 | + |
| 9 | +Demo: https://y3jnxov469.codesandbox.io/ |
| 10 | + |
| 11 | +[](https://codesandbox.io/s/y3jnxov469?hidenavigation=1) |
| 12 | + |
| 13 | +<img src="https://manukminasyan.github.io/vue-functional-calendar/public/demo.png"/> |
| 14 | + |
| 15 | +# |
| 16 | +* Lightweight, high performance calendar component based on Vue.js |
| 17 | +* Small memory usage, good performance, good style, and high scalability |
| 18 | +* Native js development, no third-party library introduced |
| 19 | +* Date Picker, Date Range, Multiple Calendars, Modal Calendar |
| 20 | + |
| 21 | +## Install |
| 22 | + |
| 23 | +``` |
| 24 | +npm i vue-functional-calendar --save |
| 25 | +``` |
| 26 | + |
| 27 | +## Usage |
| 28 | + |
| 29 | +### Import Component |
| 30 | +```javascript |
| 31 | +// Introduced in vue file |
| 32 | +import FunctionalCalendar from 'vue-functional-calendar'; |
| 33 | +```` |
| 34 | + |
| 35 | +### Component Settings |
| 36 | +````javascript |
| 37 | +export default { |
| 38 | + components: { |
| 39 | + FunctionalCalendar |
| 40 | + }, |
| 41 | + data() { |
| 42 | + return { |
| 43 | + calendarData: {} |
| 44 | + } |
| 45 | + } |
| 46 | +} |
| 47 | +```` |
| 48 | + |
| 49 | +### Template Usage |
| 50 | +````html |
| 51 | +<FunctionalCalendar |
| 52 | + // v-model="calendarData" |
| 53 | + |
| 54 | + // v-on:changedMonth="changedMonth" |
| 55 | + // v-on:changedYear="changedYear" |
| 56 | + |
| 57 | + // :sundayStart="true" |
| 58 | + // :date-format="'dd/mm/yyyy'" |
| 59 | + // :is-date-range="true" |
| 60 | + // :is-date-picker="true" |
| 61 | + :...: |
| 62 | +></FunctionalCalendar> |
| 63 | +```` |
| 64 | + |
| 65 | +## Usage With Configs |
| 66 | +### Component Settings |
| 67 | +````javascript |
| 68 | +export default { |
| 69 | + components: { |
| 70 | + FunctionalCalendar |
| 71 | + }, |
| 72 | + data() { |
| 73 | + return { |
| 74 | + calendarData: {}, |
| 75 | + calendarConfigs: { |
| 76 | + sundayStart: false, |
| 77 | + dateFormat: 'dd/mm/yyyy', |
| 78 | + isDatePicker: false, |
| 79 | + isDateRange: false |
| 80 | + } |
| 81 | + } |
| 82 | + }, |
| 83 | +} |
| 84 | +```` |
| 85 | + |
| 86 | +### Template Usage |
| 87 | +````html |
| 88 | +<FunctionalCalendar |
| 89 | + // v-model="calendarData" |
| 90 | + // :configs="calendarConfigs" |
| 91 | +></FunctionalCalendar> |
| 92 | +```` |
| 93 | + |
| 94 | +### A note on markDates |
| 95 | +The `markedDates` property **must** be in JavaScript Date format, e.g, no leading zeroes on month and days. |
| 96 | + |
| 97 | +✅ Correct: 1/12/2019 |
| 98 | +❎ Incorrect: 01/12/2019 |
| 99 | + |
| 100 | +## Available props |
| 101 | +| Prop | Type | Default | Example | Description | |
| 102 | +|-------------------------------|-----------------|-------------|-------------|------------------------------------------| |
| 103 | +| sundayStart | Boolean | false | true | Week start sunday | |
| 104 | +| newCurrentDate | Date | new Date() | new Date(2019,10,11) | Calendar Current Date | |
| 105 | +| limits | [Object, Boolean] | false | {min: '31/10/2019', max: '31/12/2019'} | Set calendar show, and marked dates limits. | |
| 106 | +| placeholder | [String, Boolean] | false | 'yyyy/mm/dd' | Date input placeholder | |
| 107 | +| dateFormat | String | 'dd/mm/yyyy' | 'yyyy/mm/dd' | Date formatting string | |
| 108 | +| leftAndRightDays | Boolean | true | false | Show or hide left and right days, prev or next months | |
| 109 | +| isDatePicker | Boolean | false | true | Enable or disable date picker | |
| 110 | +| isDateRange | Boolean | false | true | Enable or disable date range | |
| 111 | +| isMultiple | Boolean | false | true | Enable multiple calendar function | |
| 112 | +| calendarsCount | Number | 1 | 3 | Count of calendars, working only is prop isMultiple | |
| 113 | +| isModal | Boolean | false | true | Enable modal calendar function | |
| 114 | +| isTypeable | Boolean | false | true | Enable manually date typing function, working only with prop isModal | |
| 115 | +| changeMonthFunction | Boolean | false | true | Enable changed month with list, function | |
| 116 | +| changeYearFunction | Boolean | false | true | Enable changed year with list, function | |
| 117 | +| applyStylesheet | Boolean | true | false | Disable default styles | |
| 118 | +| markedDates | Array | [] | ['10/12/2018', '12/12/2018'] OR [{date: '10/1/2019', class: 'marked-class'},{date: '12/1/2019', class: 'marked-class-2'}] | Marked dates array | |
| 119 | +| markedDateRange | Object | {start: false, end: false} | {start: '12/12/2018', end: '20/12/2018'} | Marked date with range | |
| 120 | +| disabledDayNames | Array | [] | ['Su','We'] | Disabled Days Of Week | |
| 121 | +| disabledDates | Array | [] | ['24/12/2018','27/12/2018'] | Disabled Dates | |
| 122 | +| dayNames | Array | ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'] | ['Monday', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Sunday'] | Week Day Names | |
| 123 | +| monthNames | Array | ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"] | ["Jan.", "Feb.", "Mar", "Apr.", "May", "Jun.", "Jul.", "Aug.", "Sept.", "Oct.", "Nov.", "Dec."] | Month names | |
| 124 | + |
| 125 | +### Events |
| 126 | + |
| 127 | +| Event | Output | Description | |
| 128 | +| :------------- | :------------- | :-----------------------------------------------------------: |
| 129 | +| changedMonth |Date | Month page has been changed |
| 130 | +| changedYear |Date | Year page has been changed |
| 131 | +| selectedDaysCount |Number | Get number of days between date range dates |
| 132 | +| opened | | The picker is opened |
| 133 | +| closed | | The picker is closed |
| 134 | +##### Add the ref attribute to the Calendar tab, exposing three methods to switch the month directly |
| 135 | +````javascript |
| 136 | +For example: <FunctionalCalendar ref="Calendar"></FunctionalCalendar> |
| 137 | + |
| 138 | + ✅ this.$refs.Calendar.PreMonth(); //Call method implementation to go to previous month |
| 139 | + ✅ this.$refs.Calendar.NextMonth(); //Call method implementation to go to next month |
| 140 | + ✅ this.$refs.Calendar.PreYear(); //Call method implementation to go to previous year |
| 141 | + ✅ this.$refs.Calendar.NextYear(); //Call method implementation to go to next year |
| 142 | + ✅ this.$refs.Calendar.ChooseDate('2018-12-12'); //Call method implementation to go to a date |
| 143 | +```` |
| 144 | + |
| 145 | +## Other |
| 146 | +* The following Demo.vue has a demo for reference. |
0 commit comments