Skip to content

Commit 4ad1c76

Browse files
committed
Added isAutoCloseable functionality
1 parent 165b943 commit 4ad1c76

File tree

5 files changed

+23
-5
lines changed

5 files changed

+23
-5
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ ___
141141
| calendarsCount | Number | 1 | 3 | Count of calendars, working only is prop isMultiple |
142142
| isSeparately | Boolean | false | true | Enable separately calendars |
143143
| isModal | Boolean | false | true | Enable modal calendar function |
144+
| isAutoCloseable | Boolean | false | true | Hide picker(calendar) if date has been selected |
144145
| isTypeable | Boolean | false | true | Enable manually date typing function, working only with prop isModal |
145146
| changeMonthFunction | Boolean | false | true | Enable changed month with list, function |
146147
| changeYearFunction | Boolean | false | true | Enable changed year with list, function |

src/Demo.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66
:date-format="'dd/mm/yyyy'"
77
:is-multiple="true"
88
:calendars-count="1"
9-
:with-time-picker="true"
9+
:with-time-picker="false"
1010
:change-month-function="true"
11+
:disabled-dates="['10/10/2019']"
1112
v-slot:default="props"
13+
:is-modal="true"
14+
:is-auto-closeable="true"
1215
>
1316
{{ props.day.day }}
1417
<span :class="{'green-point': props.day.day === 5, 'orange-point': props.day.day === 9, 'green-line': props.day.day === 11}"></span>

src/assets/scss/calendar.scss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,11 +498,10 @@ input.vfc-single-input {
498498

499499
&.vfc-disabled {
500500
margin: auto;
501-
background-color: rgba(0, 0, 0, 0.2);
501+
color: rgba(0, 0, 0, 0.2);
502502
border-radius: 50%;
503503
opacity: 1;
504504
z-index: 2;
505-
color: $white;
506505
}
507506

508507
&:after {

src/components/FunctionalCalendar.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,12 +508,22 @@
508508
let diffDays = Math.round(Math.abs((firstDate.getTime() - secondDate.getTime()) / (oneDay)));
509509
510510
this.$emit('selectedDaysCount', diffDays);
511+
512+
// Is Auto Closeable
513+
if (this.fConfigs.isModal && this.fConfigs.isAutoCloseable) {
514+
this.showCalendar = false;
515+
}
511516
}
512517
513518
this.$emit('input', this.calendar);
514519
} else if (this.fConfigs.isDatePicker) {
515520
this.calendar.selectedDate = item.date;
516521
this.$emit('input', this.calendar);
522+
523+
// Is Auto Closeable
524+
if (this.fConfigs.isModal && this.fConfigs.isAutoCloseable) {
525+
this.showCalendar = false;
526+
}
517527
} else if (this.fConfigs.isMultipleDatePicker) {
518528
if (this.calendar.selectedDates.find(date => date.date === item.date)) {
519529
let dateIndex = this.calendar.selectedDates.findIndex(date => date.date === item.date);

src/mixins/propsAndData.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,11 @@ export const propsAndData = {
9898
},
9999
hiddenElements: {
100100
type: Array
101-
}
101+
},
102+
isAutoCloseable: {
103+
type: Boolean,
104+
default: false,
105+
},
102106
},
103107
data() {
104108
return {
@@ -192,7 +196,8 @@ export const propsAndData = {
192196
monthNames: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
193197

194198
transition: true,
195-
hiddenElements: []
199+
hiddenElements: [],
200+
isAutoCloseable: false,
196201
}
197202
}
198203
}

0 commit comments

Comments
 (0)