Skip to content

Commit 6ad0e07

Browse files
Add maxDate functionality
1 parent 67446be commit 6ad0e07

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

dist/vue-rangedate-picker.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vue-rangedate-picker.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/RangedatePicker.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<ul v-for="r in 6" :class="[s.days]" :key="r">
3434
<li :class="[{[s.daysSelected]: isDateSelected(r, i, 'second', startNextMonthDay, endNextMonthDate),
3535
[s.daysInRange]: isDateInRange(r, i, 'second', startNextMonthDay, endNextMonthDate),
36-
[s.dateDisabled]: isDateDisabled(r, i, startNextMonthDay, endNextMonthDate)}]"
36+
[s.dateDisabled]: isDateDisabled(r, i, startNextMonthDay, endNextMonthDate), [s.dateAfterMax]: isDateAfterMax(startNextMonthDay, endNextMonthDate)}]"
3737
v-for="i in numOfDays" :key="i" v-html="getDayCell(r, i, startNextMonthDay, endNextMonthDate)"
3838
@click="selectSecondItem(r, i)"></li>
3939
</ul>
@@ -211,10 +211,15 @@
211211
background: #eee;
212212
color: #000;
213213
}
214-
li.calendar_days--disabled{
214+
li.calendar_days--disabled {
215215
pointer-events: none;
216216
}
217217
218+
li.calendar_days--after-max {
219+
pointer-events: none;
220+
background: #eee;
221+
}
222+
218223
li.calendar_days_selected {
219224
background: #005a82;
220225
color: #fff;

src/js/rangedate-picker.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ const defaultStyle = {
4545
firstDate: 'calendar_month_left',
4646
secondDate: 'calendar_month_right',
4747
presetRanges: 'calendar_preset-ranges',
48-
dateDisabled: 'calendar_days--disabled'
48+
dateDisabled: 'calendar_days--disabled',
49+
dateAfterMax: 'calendar_days--after-max'
4950
}
5051

5152
const defaultPresets = function (i18n = defaultI18n) {
@@ -181,6 +182,10 @@ export default {
181182
cancelButtonHidden: {
182183
type: String,
183184
default: 'true'
185+
},
186+
maxDate: {
187+
type: Date,
188+
default: () => null
184189
}
185190
},
186191
data () {
@@ -354,6 +359,10 @@ export default {
354359
// bound by > 0 and < last day of month
355360
return !(result > 0 && result <= endMonthDate)
356361
},
362+
isDateAfterMax (startMonthDay, endMonthDate) {
363+
if (!this.maxDate) return false
364+
return (endMonthDate > this.maxDate)
365+
},
357366
goPrevMonth () {
358367
const prevMonth = new Date(this.activeYearStart, this.activeMonthStart, 0)
359368
this.activeMonthStart = prevMonth.getMonth()

0 commit comments

Comments
 (0)