Socket
Socket
Sign inDemoInstall

vue-hotel-datepicker

Package Overview
Dependencies
13
Maintainers
2
Versions
100
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.0.0-beta.12 to 4.0.0-beta.13

27

.prettierrc.json

@@ -5,30 +5,7 @@ {

"singleQuote": true,
"tabWidth": 4,
"tabWidth": 2,
"useTabs": false,
"semi": false,
"trailingComma": "all",
"insertPragma": false,
"overrides": [
{
"files": [
"*.php",
"*.yml",
"*.yaml"
],
"options": {
"tabWidth": 4
}
},
{
"files": [
"*.js"
],
"options": {
"tabWidth": 4
}
}
],
"plugins": [
"eslint-plugin-prettier"
]
"insertPragma": false
}

6

package.json
{
"name": "vue-hotel-datepicker",
"version": "4.0.0-beta.12",
"version": "4.0.0-beta.13",
"description": "A responsive date range picker for Vue.js that displays the number of nights selected and allow several useful options like custom check-in/check-out rules, localization support and more",

@@ -56,5 +56,5 @@ "author": "krystalcampioni <hello@krystalcampioni.com>",

"eslint": "^6.8.0",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-prettier": "^3.3.0",
"eslint-plugin-vue": "^6.2.2",
"prettier": "^1.19.1",
"prettier": "^2.2.1",
"sass": "^1.26.10",

@@ -61,0 +61,0 @@ "sass-loader": "^8.0.2",

@@ -62,3 +62,4 @@ [![dependencies Status](https://david-dm.org/krystalcampioni/vue-hotel-datepicker.svg)](https://david-dm.org/krystalcampioni/vue-hotel-datepicker) [![devDependencies Status](https://david-dm.org/krystalcampioni/vue-hotel-datepicker/dev-status.svg)](https://david-dm.org/krystalcampioni/vue-hotel-datepicker?type=dev)

|**disabledDates**|`Array`|`[]`|An array of strings in this format: `YYYY-MM-DD`. All the dates passed to the list will be disabled.
|**disabledDaysOfWeek**|`Array`|`[]`|An array of strings in this format: `['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']`. All the days passed to the list will be disabled. (Before final release it will be changed to lower case english names).
|**disabledDaysOfWeek**|`Array`|`[]`| **DEPRECATED**: An array of strings in this format: `['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']`. All the days passed to the list will be disabled. It depends on the translated names.
|**disabledWeekDays**|`Object`|`{}`| An object with the following properties: `sunday`, `monday`, `tuesday`, `wednesday`, `thursday`, `friday`, `saturday`, the value indicates if that day is disabled (true) or enabled (false).
|**displayClearButton**|`Boolean`|`true`|If set to true, displays a clear button on the right side of the input if there are dates set.

@@ -65,0 +66,0 @@ |**enableCheckout**|`Boolean`|`false`|If `true`, allows the checkout on a disabled date.

@@ -5,215 +5,223 @@ /* eslint-disable vars-on-top */

export default {
getNextDate(datesArray, referenceDate) {
const now = new Date(referenceDate)
let closest = Infinity
getNextDate(datesArray, referenceDate) {
const now = new Date(referenceDate)
let closest = Infinity
datesArray.forEach(d => {
const date = new Date(d)
datesArray.forEach((d) => {
const date = new Date(d)
if (date >= now && date < closest) {
closest = d
}
})
if (date >= now && date < closest) {
closest = d
}
})
if (closest === Infinity) {
return null
}
if (closest === Infinity) {
return null
}
return closest
},
nextDateByDayOfWeek(weekDay, referenceDate) {
const newReferenceDate = new Date(referenceDate)
let newWeekDay = weekDay.toLowerCase()
const days = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday']
const referenceDateDay = newReferenceDate.getDay()
return closest
},
nextDateByDayOfWeek(weekDay, referenceDate) {
const newReferenceDate = new Date(referenceDate)
let newWeekDay = weekDay.toLowerCase()
// const days = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday']
const days = this.i18n['day-names']
const referenceDateDay = newReferenceDate.getDay()
for (let i = 7; i--; ) {
if (newWeekDay === days[i]) {
newWeekDay = i <= referenceDateDay ? i + 7 : i
break
}
}
for (let i = 7; i--; ) {
if (newWeekDay === days[i]) {
newWeekDay = i <= referenceDateDay ? i + 7 : i
break
}
}
const daysUntilNext = newWeekDay - referenceDateDay
const daysUntilNext = newWeekDay - referenceDateDay
return newReferenceDate.setDate(newReferenceDate.getDate() + daysUntilNext)
},
nextDateByDayOfWeekArray(daysArray, referenceDate) {
const tempArray = []
return newReferenceDate.setDate(newReferenceDate.getDate() + daysUntilNext)
},
nextDateByDayOfWeekArray(daysArray, referenceDate) {
const tempArray = []
for (let i = 0; i < daysArray.length; i++) {
tempArray.push(new Date(this.nextDateByDayOfWeek(daysArray[i], referenceDate)))
}
for (let i = 0; i < daysArray.length; i++) {
tempArray.push(new Date(this.nextDateByDayOfWeek(daysArray[i], referenceDate)))
}
return this.getNextDate(tempArray, referenceDate)
},
countDays(start, end) {
const oneDay = 24 * 60 * 60 * 1000
const firstDate = new Date(start)
const secondDate = new Date(end)
return this.getNextDate(tempArray, referenceDate)
},
nextDateByDayOfWeekObject(days, referenceDate) {
const daysArray = Object.entries(days)
.map((e) => (e[1] ? e[0] : false))
.filter((v) => v)
return Math.round(Math.abs((firstDate.getTime() - secondDate.getTime()) / oneDay))
},
addDays(date, quantity) {
const result = new Date(date)
return this.nextDateByDayOfWeekArray(daysArray, referenceDate)
},
countDays(start, end) {
const oneDay = 24 * 60 * 60 * 1000
const firstDate = new Date(start)
const secondDate = new Date(end)
result.setDate(result.getDate() + quantity)
return Math.round(Math.abs((firstDate.getTime() - secondDate.getTime()) / oneDay))
},
addDays(date, quantity) {
const result = new Date(date)
return result
},
getDayDiff(d1, d2) {
const t2 = new Date(d2).getTime()
const t1 = new Date(d1).getTime()
result.setDate(result.getDate() + quantity)
return parseInt((t2 - t1) / (24 * 3600 * 1000), 10)
},
getFirstDay(date, firstDayOfWeek) {
const firstDay = this.getFirstDayOfMonth(date)
let offset = 0
return result
},
getDayDiff(d1, d2) {
const t2 = new Date(d2).getTime()
const t1 = new Date(d1).getTime()
if (firstDayOfWeek > 0) {
offset = firstDay.getDay() === 0 ? -7 + firstDayOfWeek : firstDayOfWeek
}
return parseInt((t2 - t1) / (24 * 3600 * 1000), 10)
},
getFirstDay(date, firstDayOfWeek) {
const firstDay = this.getFirstDayOfMonth(date)
let offset = 0
return new Date(firstDay.setDate(firstDay.getDate() - (firstDay.getDay() - offset)))
},
getFirstDayOfMonth(date) {
return new Date(date.getFullYear(), date.getMonth(), 1)
},
getNextMonth(date) {
let nextMonth
if (firstDayOfWeek > 0) {
offset = firstDay.getDay() === 0 ? -7 + firstDayOfWeek : firstDayOfWeek
}
if (date.getMonth() === 11) {
nextMonth = new Date(date.getFullYear() + 1, 0, 1)
} else {
nextMonth = new Date(date.getFullYear(), date.getMonth() + 1, 1)
}
return new Date(firstDay.setDate(firstDay.getDate() - (firstDay.getDay() - offset)))
},
getFirstDayOfMonth(date) {
return new Date(date.getFullYear(), date.getMonth(), 1)
},
getNextMonth(date) {
let nextMonth
return nextMonth
},
handleTouchStart(evt) {
this.isTouchMove = false
if (date.getMonth() === 11) {
nextMonth = new Date(date.getFullYear() + 1, 0, 1)
} else {
nextMonth = new Date(date.getFullYear(), date.getMonth() + 1, 1)
}
if (this.isOpen) {
this.xDown = evt.touches[0].clientX
this.yDown = evt.touches[0].clientY
}
},
handleTouchMove(evt) {
if (!this.xDown || !this.yDown) {
this.isTouchMove = false
return nextMonth
},
handleTouchStart(evt) {
this.isTouchMove = false
return
}
if (this.isOpen) {
this.xDown = evt.touches[0].clientX
this.yDown = evt.touches[0].clientY
}
},
handleTouchMove(evt) {
if (!this.xDown || !this.yDown) {
this.isTouchMove = false
this.isTouchMove = true
this.xUp = evt.touches[0].clientX
this.yUp = evt.touches[0].clientY
},
handleTouchEnd() {
if (!this.isTouchMove) {
return
}
return
}
if (!this.xDown || !this.yDown) {
return
}
this.isTouchMove = true
this.xUp = evt.touches[0].clientX
this.yUp = evt.touches[0].clientY
},
handleTouchEnd() {
if (!this.isTouchMove) {
return
}
const xDiff = this.xDown - this.xUp
const yDiff = this.yDown - this.yUp
if (!this.xDown || !this.yDown) {
return
}
if (Math.abs(xDiff) < Math.abs(yDiff) && yDiff > 0 && !this.isPreventedMaxMonth) {
this.renderNextMonth()
} else {
this.renderPreviousMonth()
}
const xDiff = this.xDown - this.xUp
const yDiff = this.yDown - this.yUp
this.xDown = null
this.yDown = null
},
validateDateBetweenTwoDates(fromDate, toDate, givenDate) {
const getvalidDate = d => {
const formatDateAt00 = new Date(d).setHours(0, 0, 0, 0)
if (Math.abs(xDiff) < Math.abs(yDiff) && yDiff > 0 && !this.isPreventedMaxMonth) {
this.renderNextMonth()
} else {
this.renderPreviousMonth()
}
return new Date(formatDateAt00)
}
this.xDown = null
this.yDown = null
},
validateDateBetweenTwoDates(fromDate, toDate, givenDate) {
const getvalidDate = (d) => {
const formatDateAt00 = new Date(d).setHours(0, 0, 0, 0)
return getvalidDate(givenDate) <= getvalidDate(toDate) && getvalidDate(givenDate) >= getvalidDate(fromDate)
},
validateDateBetweenDate(fromDate, givenDate) {
const getvalidDate = d => {
return new Date(d)
}
return new Date(formatDateAt00)
}
return getvalidDate(givenDate) <= getvalidDate(fromDate)
},
getMonthDiff(d1, d2) {
const newD1 = new Date(d1)
const newD2 = new Date(d2)
const d1Y = newD1.getFullYear()
const d2Y = newD2.getFullYear()
const d1M = newD1.getMonth()
const d2M = newD2.getMonth()
return getvalidDate(givenDate) <= getvalidDate(toDate) && getvalidDate(givenDate) >= getvalidDate(fromDate)
},
validateDateBetweenDate(fromDate, givenDate) {
const getvalidDate = (d) => {
return new Date(d)
}
return d2M + 12 * d2Y - (d1M + 12 * d1Y)
},
shortenString(arr, sLen) {
const newArr = []
return getvalidDate(givenDate) <= getvalidDate(fromDate)
},
getMonthDiff(d1, d2) {
const newD1 = new Date(d1)
const newD2 = new Date(d2)
const d1Y = newD1.getFullYear()
const d2Y = newD2.getFullYear()
const d1M = newD1.getMonth()
const d2M = newD2.getMonth()
for (let i = 0, len = arr.length; i < len; i++) {
newArr.push(arr[i].substr(0, sLen))
}
return d2M + 12 * d2Y - (d1M + 12 * d1Y)
},
shortenString(arr, sLen) {
const newArr = []
return newArr
},
getDaysArray(start, end) {
for (
// eslint-disable-next-line no-var
var arr = [], dt = new Date(start);
dt <= end;
dt.setDate(dt.getDate() + 1)
) {
arr.push(new Date(dt))
}
for (let i = 0, len = arr.length; i < len; i++) {
newArr.push(arr[i].substr(0, sLen))
}
// eslint-disable-next-line block-scoped-var
return arr
},
dateFormater(date, format) {
const f = format || 'YYYY-MM-DD'
return newArr
},
getDaysArray(start, end) {
for (
// eslint-disable-next-line no-var
var arr = [], dt = new Date(start);
dt <= end;
dt.setDate(dt.getDate() + 1)
) {
arr.push(new Date(dt))
}
if (date) {
return fecha.format(date, f)
}
// eslint-disable-next-line block-scoped-var
return arr
},
dateFormater(date, format) {
const f = format || 'YYYY-MM-DD'
return ''
},
pluralize(countOfDays, periodType = 'night') {
if (periodType === 'week') {
return countOfDays > 7 ? this.i18n.weeks : this.i18n.week
}
if (date) {
return fecha.format(date, f)
}
return countOfDays !== 1 ? this.i18n.nights : this.i18n.night
},
isDateLessOrEquals(time1, time2) {
return new Date(time1) < new Date(time2)
},
compareDay(day1, day2) {
const date1 = fecha.format(new Date(day1), 'YYYYMMDD')
const date2 = fecha.format(new Date(day2), 'YYYYMMDD')
return ''
},
pluralize(countOfDays, periodType = 'night') {
if (periodType === 'week') {
return countOfDays > 7 ? this.i18n.weeks : this.i18n.week
}
if (date1 > date2) {
return 1
}
return countOfDays !== 1 ? this.i18n.nights : this.i18n.night
},
isDateLessOrEquals(time1, time2) {
return new Date(time1) < new Date(time2)
},
compareDay(day1, day2) {
const date1 = fecha.format(new Date(day1), 'YYYYMMDD')
const date2 = fecha.format(new Date(day2), 'YYYYMMDD')
if (date1 === date2) {
return 0
}
if (date1 > date2) {
return 1
}
if (date1 < date2) {
return -1
}
if (date1 === date2) {
return 0
}
return null
},
if (date1 < date2) {
return -1
}
return null
},
}
export default {
night: 'Night',
nights: 'Nights',
week: 'Week',
weeks: 'Weeks',
'day-names': ['Sun', 'Mon', 'Tue', 'Wed', 'Thur', 'Fri', 'Sat'],
'check-in': 'Check-in',
'check-out': 'Check-out',
'month-names': [
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December',
],
tooltip: {
halfDayCheckIn: 'Available CheckIn',
halfDayCheckOut: 'Available CheckOut',
saturdayToSaturday: 'Only Saturday to Saturday',
sundayToSunday: 'Only Sunday to Sunday',
minimumRequiredPeriod: '%{minNightInPeriod} %{night} minimum.',
},
night: 'Night',
nights: 'Nights',
week: 'Week',
weeks: 'Weeks',
'day-names': ['Sun', 'Mon', 'Tue', 'Wed', 'Thur', 'Fri', 'Sat'],
'check-in': 'Check-in',
'check-out': 'Check-out',
'month-names': [
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December',
],
tooltip: {
halfDayCheckIn: 'Available CheckIn',
halfDayCheckOut: 'Available CheckOut',
saturdayToSaturday: 'Only Saturday to Saturday',
sundayToSunday: 'Only Sunday to Sunday',
minimumRequiredPeriod: '%{minNightInPeriod} %{night} minimum.',
},
}
export default {
night: 'Noche',
nights: 'Noches',
week: 'Semana',
weeks: 'Semanas',
'day-names': ['Dom', 'Lun', 'Mar', 'Mié', 'Jue', 'Vie', 'Sáb'],
'check-in': 'Arribo',
'check-out': 'Partida',
'month-names': [
'Enero',
'Febrero',
'Marzo',
'Abril',
'Mayo',
'Junio',
'Julio',
'Agosto',
'Septiembre',
'Octubre',
'Noviembre',
'Diciembre',
],
tooltip: {
halfDayCheckIn: 'Arribo Disponible',
halfDayCheckOut: 'Partida Disponible',
saturdayToSaturday: 'Sólo Sábados a Sábados',
sundayToSunday: 'Sólo Domingo a Domingo',
minimumRequiredPeriod: '%{minNightInPeriod} %{night} mínimo.',
},
night: 'Noche',
nights: 'Noches',
week: 'Semana',
weeks: 'Semanas',
'day-names': ['Dom', 'Lun', 'Mar', 'Mié', 'Jue', 'Vie', 'Sáb'],
'check-in': 'Arribo',
'check-out': 'Partida',
'month-names': [
'Enero',
'Febrero',
'Marzo',
'Abril',
'Mayo',
'Junio',
'Julio',
'Agosto',
'Septiembre',
'Octubre',
'Noviembre',
'Diciembre',
],
tooltip: {
halfDayCheckIn: 'Arribo Disponible',
halfDayCheckOut: 'Partida Disponible',
saturdayToSaturday: 'Sólo Sábados a Sábados',
sundayToSunday: 'Sólo Domingo a Domingo',
minimumRequiredPeriod: '%{minNightInPeriod} %{night} mínimo.',
},
}
export default {
night: 'Nuit',
nights: 'Nuits',
week: 'Semaine',
weeks: 'Semaines',
'check-in': 'Départ',
'check-out': 'Arrivée',
'day-names': ['Lu', 'Ma', 'Me', 'Je', 'Ve', 'Sa', 'Di'],
'month-names': [
'Janvier',
'Février',
'Mars',
'Avril',
'Mai',
'Juin',
'Juillet',
'Août',
'Septembre',
'Octobre',
'Novembre',
'Décembre',
],
tooltip: {
halfDayCheckIn: 'Réservation possible',
halfDayCheckOut: 'Réservation possible',
saturdayToSaturday: 'Du samedi au samedi uniquement',
sundayToSunday: 'Du dimanche au dimanche uniquement',
minimumRequiredPeriod: '%{minNightInPeriod} %{night} minimum',
},
night: 'Nuit',
nights: 'Nuits',
week: 'Semaine',
weeks: 'Semaines',
'check-in': 'Départ',
'check-out': 'Arrivée',
'day-names': ['Lu', 'Ma', 'Me', 'Je', 'Ve', 'Sa', 'Di'],
'month-names': [
'Janvier',
'Février',
'Mars',
'Avril',
'Mai',
'Juin',
'Juillet',
'Août',
'Septembre',
'Octobre',
'Novembre',
'Décembre',
],
tooltip: {
halfDayCheckIn: 'Réservation possible',
halfDayCheckOut: 'Réservation possible',
saturdayToSaturday: 'Du samedi au samedi uniquement',
sundayToSunday: 'Du dimanche au dimanche uniquement',
minimumRequiredPeriod: '%{minNightInPeriod} %{night} minimum',
},
}
export default {
night: 'Noite',
nights: 'Noites',
week: 'Semana',
weeks: 'Semanas',
'day-names': ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sab'],
'check-in': 'Chegada',
'check-out': 'Partida',
'month-names': [
'Janeiro',
'Fevereiro',
'Março',
'Abril',
'Maio',
'Junho',
'Julho',
'Agosto',
'Setembro',
'Outubro',
'Novembro',
'Dezembro',
],
tooltip: {
halfDayCheckIn: 'Chegada possíveis',
halfDayCheckOut: 'Partida possíveis',
saturdayToSaturday: 'Sábado a Sábado apenas',
sundayToSunday: 'Domingo a domingo apenas',
minimumRequiredPeriod: '%{minNightInPeriod} %{night} mínimo.',
},
night: 'Noite',
nights: 'Noites',
week: 'Semana',
weeks: 'Semanas',
'day-names': ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sab'],
'check-in': 'Chegada',
'check-out': 'Partida',
'month-names': [
'Janeiro',
'Fevereiro',
'Março',
'Abril',
'Maio',
'Junho',
'Julho',
'Agosto',
'Setembro',
'Outubro',
'Novembro',
'Dezembro',
],
tooltip: {
halfDayCheckIn: 'Chegada possíveis',
halfDayCheckOut: 'Partida possíveis',
saturdayToSaturday: 'Sábado a Sábado apenas',
sundayToSunday: 'Domingo a domingo apenas',
minimumRequiredPeriod: '%{minNightInPeriod} %{night} mínimo.',
},
}

@@ -7,3 +7,3 @@ import Vue from 'vue'

new Vue({
render: h => h(App),
render: (h) => h(App),
}).$mount('#app')

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc